X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_driver%2Fsrc%2Flib.rs;h=02e0b042ad2631eadad94771b4a2dfab2c2defd4;hb=4755c7c60e9496bdc2365854a0f0ec595a569547;hp=f50ad0137b88aacff80bed38c6e5caeccf54cc11;hpb=28081a6aa6a13199e6ee3c09ab544139eb23a3fa;p=rust.git diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index f50ad0137b8..02e0b042ad2 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -43,7 +43,6 @@ use rustc_span::symbol::sym; use rustc_target::json::ToJson; -use std::borrow::Cow; use std::cmp::max; use std::env; use std::ffi::OsString; @@ -296,9 +295,8 @@ fn run_compiler( if let Some(ppm) = &sess.opts.pretty { if ppm.needs_ast_map() { - let expanded_crate = queries.expansion()?.borrow().0.clone(); queries.global_ctxt()?.enter(|tcx| { - pretty::print_after_hir_lowering(tcx, &*expanded_crate, *ppm); + pretty::print_after_hir_lowering(tcx, *ppm); Ok(()) })?; } else { @@ -328,11 +326,15 @@ fn run_compiler( } } - queries.global_ctxt()?; + let mut gctxt = queries.global_ctxt()?; if callbacks.after_expansion(compiler, queries) == Compilation::Stop { return early_exit(); } + // Make sure the `output_filenames` query is run for its side + // effects of writing the dep-info and reporting errors. + gctxt.enter(|tcx| tcx.output_filenames(())); + if sess.opts.output_types.contains_key(&OutputType::DepInfo) && sess.opts.output_types.len() == 1 { @@ -343,7 +345,7 @@ fn run_compiler( return early_exit(); } - queries.global_ctxt()?.enter(|tcx| { + gctxt.enter(|tcx| { let result = tcx.analysis(()); if sess.opts.unstable_opts.save_analysis { let crate_name = tcx.crate_name(LOCAL_CRATE); @@ -360,6 +362,8 @@ fn run_compiler( result })?; + drop(gctxt); + if callbacks.after_analysis(compiler, queries) == Compilation::Stop { return early_exit(); } @@ -1200,29 +1204,20 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { handler.emit_diagnostic(&mut d); } - let mut xs: Vec> = vec![ - "the compiler unexpectedly panicked. this is a bug.".into(), - format!("we would appreciate a bug report: {bug_report_url}").into(), - format!( - "rustc {} running on {}", - util::version_str!().unwrap_or("unknown_version"), - config::host_triple() - ) - .into(), - ]; + handler.emit_note(session_diagnostics::Ice); + handler.emit_note(session_diagnostics::IceBugReport { bug_report_url }); + handler.emit_note(session_diagnostics::IceVersion { + version: util::version_str!().unwrap_or("unknown_version"), + triple: config::host_triple(), + }); if let Some((flags, excluded_cargo_defaults)) = extra_compiler_flags() { - xs.push(format!("compiler flags: {}", flags.join(" ")).into()); - + handler.emit_note(session_diagnostics::IceFlags { flags: flags.join(" ") }); if excluded_cargo_defaults { - xs.push("some of the compiler flags provided by cargo are hidden".into()); + handler.emit_note(session_diagnostics::IceExcludeCargoDefaults); } } - for note in &xs { - handler.note_without_error(note.as_ref()); - } - // If backtraces are enabled, also print the query stack let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0");