Make missing optimized MIR error more informative

This commit is contained in:
Oli Scherer 2025-03-27 12:08:00 +00:00
parent aec7739837
commit c0fe46d6b7
5 changed files with 5 additions and 3 deletions

View file

@ -48,7 +48,7 @@ monomorphize_large_assignments =
.note = The current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
monomorphize_no_optimized_mir =
missing optimized MIR for an item in the crate `{$crate_name}`
missing optimized MIR for `{$instance}` in the crate `{$crate_name}`
.note = missing optimized MIR for this item (was the crate `{$crate_name}` compiled with `--emit=metadata`?)
monomorphize_recursion_limit =

View file

@ -989,6 +989,7 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) ->
tcx.dcx().emit_fatal(NoOptimizedMir {
span: tcx.def_span(def_id),
crate_name: tcx.crate_name(def_id.krate),
instance: instance.to_string(),
});
}

View file

@ -24,6 +24,7 @@ pub(crate) struct NoOptimizedMir {
#[note]
pub span: Span,
pub crate_name: Symbol,
pub instance: String,
}
#[derive(LintDiagnostic)]

View file

@ -10,4 +10,4 @@ fn main() {
rmeta_meta::missing_optimized_mir();
}
//~? ERROR missing optimized MIR for an item in the crate `rmeta_meta`
//~? ERROR missing optimized MIR for `missing_optimized_mir` in the crate `rmeta_meta`

View file

@ -1,4 +1,4 @@
error: missing optimized MIR for an item in the crate `rmeta_meta`
error: missing optimized MIR for `missing_optimized_mir` in the crate `rmeta_meta`
|
note: missing optimized MIR for this item (was the crate `rmeta_meta` compiled with `--emit=metadata`?)
--> $DIR/auxiliary/rmeta-meta.rs:10:1