Fix ICE on --print=... i/o errors
This commit is contained in:
parent
521de433f4
commit
040e1b6b5f
2 changed files with 68 additions and 40 deletions
20
compiler/rustc_driver_impl/src/print.rs
Normal file
20
compiler/rustc_driver_impl/src/print.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use std::fmt;
|
||||
use std::io::{self, Write as _};
|
||||
|
||||
macro_rules! safe_print {
|
||||
($($arg:tt)*) => {{
|
||||
$crate::print::print(std::format_args!($($arg)*));
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! safe_println {
|
||||
($($arg:tt)*) => {
|
||||
safe_print!("{}\n", std::format_args!($($arg)*))
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) fn print(args: fmt::Arguments<'_>) {
|
||||
if let Err(_) = io::stdout().write_fmt(args) {
|
||||
rustc_errors::FatalError.raise();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue