Skip to content
Open
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
5 changes: 4 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ pub fn compiler_entrypoint(at_args: &[String], callbacks: &mut (dyn Callbacks +
let sopts =
config::build_session_options(&mut default_early_dcx, &matches, warn_unspecified_edition);
let ice_file = ice_path_with_config(Some(&sopts.unstable_opts)).clone();
let _ = ICE_COLOR.set(sopts.color);

if let Some(ref code) = matches.opt_str("explain") {
handle_explain(&default_early_dcx, code, sopts.color);
Expand Down Expand Up @@ -1392,6 +1393,7 @@ pub fn catch_with_exit_code<T: Termination>(f: impl FnOnce() -> T) -> ExitCode {
}
}

static ICE_COLOR: OnceLock<ColorConfig> = OnceLock::new();
static ICE_PATH: OnceLock<Option<PathBuf>> = OnceLock::new();

// This function should only be called from the ICE hook.
Expand Down Expand Up @@ -1538,9 +1540,10 @@ fn report_ice(
extra_info: fn(DiagCtxtHandle<'_>),
using_internal_features: &AtomicBool,
) {
let color = ICE_COLOR.get().copied().unwrap_or(ColorConfig::Auto);
let emitter =
Box::new(rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter::new(
stderr_destination(rustc_errors::ColorConfig::Auto),
stderr_destination(color),
));
let dcx = DiagCtxt::new(emitter);
let dcx = dcx.handle();
Expand Down