1
Fork 0

Emit error instead of ICE when optimized MIR is missing

Closes 51388.
This commit is contained in:
Martin Nordholts 2023-08-29 19:29:14 +02:00
parent e877e2a2c9
commit 456007af12
6 changed files with 44 additions and 3 deletions

View file

@ -192,7 +192,8 @@ use rustc_target::abi::Size;
use std::path::PathBuf;
use crate::errors::{
EncounteredErrorWhileInstantiating, LargeAssignmentsLint, RecursionLimit, TypeLengthLimit,
EncounteredErrorWhileInstantiating, LargeAssignmentsLint, NoOptimizedMir, RecursionLimit,
TypeLengthLimit,
};
#[derive(PartialEq)]
@ -950,7 +951,10 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
}
if !tcx.is_mir_available(def_id) {
bug!("no MIR available for {:?}", def_id);
tcx.sess.emit_fatal(NoOptimizedMir {
span: tcx.def_span(def_id),
crate_name: tcx.crate_name(def_id.krate),
});
}
true