Skip to content

Commit b99d7bc

Browse files
committed
avoid intermediate allocations in show_error macro
1 parent 1164815 commit b99d7bc

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

cargo-miri/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod version;
1111

1212
use std::{env, iter};
1313

14-
use crate::{phases::*, util::*};
14+
use crate::phases::*;
1515

1616
fn main() {
1717
// Rustc does not support non-UTF-8 arguments so we make no attempt either.

cargo-miri/src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ use serde::{Deserialize, Serialize};
1414

1515
pub use crate::arg::*;
1616

17-
pub fn show_error(msg: &str) -> ! {
17+
pub fn show_error(msg: &impl std::fmt::Display) -> ! {
1818
eprintln!("fatal error: {msg}");
1919
std::process::exit(1)
2020
}
2121

2222
macro_rules! show_error {
23-
($($tt:tt)*) => { show_error(&format!($($tt)*)) };
23+
($($tt:tt)*) => { crate::util::show_error(&format_args!($($tt)*)) };
2424
}
2525

2626
/// The information to run a crate with the given environment.

src/bin/miri.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
152152
}
153153
}
154154

155-
fn show_error(msg: &str) -> ! {
155+
fn show_error(msg: &impl std::fmt::Display) -> ! {
156156
eprintln!("fatal error: {msg}");
157157
std::process::exit(1)
158158
}
159159

160160
macro_rules! show_error {
161-
($($tt:tt)*) => { show_error(&format!($($tt)*)) };
161+
($($tt:tt)*) => { show_error(&format_args!($($tt)*)) };
162162
}
163163

164164
fn init_early_loggers() {

0 commit comments

Comments
 (0)