Refuse to codegen an upstream static.

This commit is contained in:
Camille GILLOT 2022-08-06 23:43:33 +02:00
parent cc4dd6fc9f
commit d3fee8dbf3
5 changed files with 33 additions and 0 deletions

View file

@ -1027,6 +1027,11 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
return false;
}
if let DefKind::Static(_) = tcx.def_kind(def_id) {
// We cannot monomorphize statics from upstream crates.
return false;
}
if !tcx.is_mir_available(def_id) {
bug!("no MIR available for {:?}", def_id);
}