Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use compile_error as print #112401

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,18 @@ use std::str;
use std::sync::OnceLock;
use std::time::Instant;

#[allow(unused_macros)]
macro do_not_use_print($($t:tt)*) {
std::compile_error!(
"Don't use `print` or `println` here, use `safe_print` or `safe_println` instead"
)
}

// This import blocks the use of panicking `print` and `println` in all the code
// below. Please use `safe_print` and `safe_println` to avoid ICE when
// encountering an I/O error during print.
#[allow(unused_imports)]
use std::{compile_error as print, compile_error as println};
use {do_not_use_print as print, do_not_use_print as println};

pub mod args;
pub mod pretty;
Expand Down