Use delayed bug for normalization errors in drop elaboration

Normalization can fail from errors from other items so use a delayed
bug instead of checking the body.
This commit is contained in:
Matthew Jasper 2025-04-04 09:58:55 +00:00
parent 71b68da1bd
commit ac45a67297
5 changed files with 70 additions and 10 deletions

View file

@ -266,19 +266,16 @@ where
let tcx = self.tcx();
assert_eq!(self.elaborator.typing_env().typing_mode, ty::TypingMode::PostAnalysis);
// The type error for normalization may have been in dropck: see
// `compute_drop_data` in rustc_borrowck, in which case we wouldn't have
// deleted the MIR body and could have an error here as well.
let field_ty = match tcx
.try_normalize_erasing_regions(self.elaborator.typing_env(), f.ty(tcx, args))
{
Ok(t) => t,
Err(_) => Ty::new_error(
self.tcx(),
self.elaborator
.body()
.tainted_by_errors
.expect("Error in drop elaboration not found by dropck."),
self.tcx().dcx().span_delayed_bug(
self.elaborator.body().span,
"Error normalizing in drop elaboration.",
),
),
};