avoid intermediate allocations in show_error macro

This commit is contained in:
Ralf Jung 2022-08-08 11:35:54 -04:00
parent 1164815750
commit b99d7bc77f
3 changed files with 5 additions and 5 deletions

View File

@ -11,7 +11,7 @@
use std::{env, iter};
use crate::{phases::*, util::*};
use crate::phases::*;
fn main() {
// Rustc does not support non-UTF-8 arguments so we make no attempt either.

View File

@ -14,13 +14,13 @@
pub use crate::arg::*;
pub fn show_error(msg: &str) -> ! {
pub fn show_error(msg: &impl std::fmt::Display) -> ! {
eprintln!("fatal error: {msg}");
std::process::exit(1)
}
macro_rules! show_error {
($($tt:tt)*) => { show_error(&format!($($tt)*)) };
($($tt:tt)*) => { crate::util::show_error(&format_args!($($tt)*)) };
}
/// The information to run a crate with the given environment.

View File

@ -152,13 +152,13 @@ fn config(&mut self, config: &mut Config) {
}
}
fn show_error(msg: &str) -> ! {
fn show_error(msg: &impl std::fmt::Display) -> ! {
eprintln!("fatal error: {msg}");
std::process::exit(1)
}
macro_rules! show_error {
($($tt:tt)*) => { show_error(&format!($($tt)*)) };
($($tt:tt)*) => { show_error(&format_args!($($tt)*)) };
}
fn init_early_loggers() {