1
Fork 0

Auto merge of #105085 - oli-obk:stop_promoting_all_the_things, r=RalfJung

Stop promoting all the things

fixes #91009

r? `@RalfJung`
This commit is contained in:
bors 2022-12-24 14:00:37 +00:00
commit f5c3dfdbbf
10 changed files with 419 additions and 8 deletions

View file

@ -216,12 +216,6 @@ impl<'tcx> Validator<'_, 'tcx> {
return Err(Unpromotable);
}
// We cannot promote things that need dropping, since the promoted value
// would not get dropped.
if self.qualif_local::<qualifs::NeedsDrop>(place.local) {
return Err(Unpromotable);
}
Ok(())
}
_ => bug!(),
@ -262,13 +256,17 @@ impl<'tcx> Validator<'_, 'tcx> {
}
}
} else {
let span = self.body.local_decls[local].source_info.span;
span_bug!(span, "{:?} not promotable, qualif_local shouldn't have been called", local);
false
}
}
fn validate_local(&mut self, local: Local) -> Result<(), Unpromotable> {
if let TempState::Defined { location: loc, uses, valid } = self.temps[local] {
// We cannot promote things that need dropping, since the promoted value
// would not get dropped.
if self.qualif_local::<qualifs::NeedsDrop>(local) {
return Err(Unpromotable);
}
valid.or_else(|_| {
let ok = {
let block = &self.body[loc.block];