Rollup merge of #139379 - matthewjasper:drop-elab-normalization, r=compiler-errors

Use delayed bug for normalization errors in drop elaboration

Normalization can fail due to a lot of different earlier errors, so just use span_delayed_bug if normalization failed.

Closes #137287
Closes #135668

r? compiler-errors
This commit is contained in:
Jacob Pratt 2025-04-13 17:37:53 -04:00 committed by GitHub
commit 346d33a5b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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.",
),
),
};