Move some calls to before calling codegen_crate
`--emit mir`, `#[rustc_symbol_name]` and `#[rustc_def_path]` now run before codegen and thus work even if codegen fails. This can help with debugging.
This commit is contained in:
parent
7d3965e0cd
commit
41f1ed11c2
6 changed files with 24 additions and 25 deletions
|
@ -73,12 +73,6 @@ pub struct TempsDirError;
|
|||
#[diag(interface_out_dir_error)]
|
||||
pub struct OutDirError;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_cant_emit_mir)]
|
||||
pub struct CantEmitMIR {
|
||||
pub error: io::Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_rustc_error_fatal)]
|
||||
pub struct RustcErrorFatal {
|
||||
|
|
|
@ -1078,6 +1078,15 @@ pub(crate) fn start_codegen<'tcx>(
|
|||
codegen_backend: &dyn CodegenBackend,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Box<dyn Any> {
|
||||
// Hook for UI tests.
|
||||
check_for_rustc_errors_attr(tcx);
|
||||
|
||||
// Don't run this test assertions when not doing codegen. Compiletest tries to build
|
||||
// build-fail tests in check mode first and expects it to not give an error in that case.
|
||||
if tcx.sess.opts.output_types.should_codegen() {
|
||||
rustc_symbol_mangling::test::report_symbol_names(tcx);
|
||||
}
|
||||
|
||||
// Don't do code generation if there were any errors. Likewise if
|
||||
// there were any delayed bugs, because codegen will likely cause
|
||||
// more ICEs, obscuring the original problem.
|
||||
|
@ -1085,9 +1094,6 @@ pub(crate) fn start_codegen<'tcx>(
|
|||
guar.raise_fatal();
|
||||
}
|
||||
|
||||
// Hook for UI tests.
|
||||
check_for_rustc_errors_attr(tcx);
|
||||
|
||||
info!("Pre-codegen\n{:?}", tcx.debug_stats());
|
||||
|
||||
let (metadata, need_metadata_module) = rustc_metadata::fs::encode_and_write_metadata(tcx);
|
||||
|
@ -1096,20 +1102,8 @@ pub(crate) fn start_codegen<'tcx>(
|
|||
codegen_backend.codegen_crate(tcx, metadata, need_metadata_module)
|
||||
});
|
||||
|
||||
// Don't run this test assertions when not doing codegen. Compiletest tries to build
|
||||
// build-fail tests in check mode first and expects it to not give an error in that case.
|
||||
if tcx.sess.opts.output_types.should_codegen() {
|
||||
rustc_symbol_mangling::test::report_symbol_names(tcx);
|
||||
}
|
||||
|
||||
info!("Post-codegen\n{:?}", tcx.debug_stats());
|
||||
|
||||
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
|
||||
if let Err(error) = rustc_mir_transform::dump_mir::emit_mir(tcx) {
|
||||
tcx.dcx().emit_fatal(errors::CantEmitMIR { error });
|
||||
}
|
||||
}
|
||||
|
||||
// This must run after monomorphization so that all generic types
|
||||
// have been instantiated.
|
||||
if tcx.sess.opts.unstable_opts.print_type_sizes {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue