Skip to content

Commit ac86aa5

Browse files
authored
Unrolled build for #148719
Rollup merge of #148719 - Nadrieril:poly-drop-glue, r=saethlin Allow unnormalized types in drop elaboration I work on a [rustc driver](https://github.com/AeneasVerif/charon) that aims to extract the full polymorphic MIR of a crate. Currently the one thing I can't get is drop glue because it fails on unnormalizable types like the fields of `Cow` or `NonZero`. This PR removes the one check for unnormalized types in drop elaboration. It's a `span_delay_bug` so only there to help catch mistakes. I think that's fine to remove? If something downstream relies on types being normalized the right approach is for MIR validation to check for normalized types, not that one random check.
2 parents e22dab3 + b476969 commit ac86aa5

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

compiler/rustc_mir_transform/src/elaborate_drop.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -511,19 +511,12 @@ where
511511
let tcx = self.tcx();
512512

513513
assert_eq!(self.elaborator.typing_env().typing_mode, ty::TypingMode::PostAnalysis);
514-
let field_ty = match tcx.try_normalize_erasing_regions(
515-
self.elaborator.typing_env(),
516-
field.ty(tcx, args),
517-
) {
518-
Ok(t) => t,
519-
Err(_) => Ty::new_error(
520-
self.tcx(),
521-
self.tcx().dcx().span_delayed_bug(
522-
self.elaborator.body().span,
523-
"Error normalizing in drop elaboration.",
524-
),
525-
),
526-
};
514+
let field_ty = field.ty(tcx, args);
515+
// We silently leave an unnormalized type here to support polymorphic drop
516+
// elaboration for users of rustc internal APIs
517+
let field_ty = tcx
518+
.try_normalize_erasing_regions(self.elaborator.typing_env(), field_ty)
519+
.unwrap_or(field_ty);
527520

528521
(tcx.mk_place_field(base_place, field_idx, field_ty), subpath)
529522
})

0 commit comments

Comments
 (0)