Skip to content

Commit ba55f20

Browse files
committed
span_bug instead of handling currently impossible drop case
1 parent c6d740d commit ba55f20

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

compiler/rustc_mir_transform/src/elaborate_drop.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -761,16 +761,17 @@ where
761761

762762
let skip_contents = adt.is_union() || adt.is_manually_drop();
763763
let contents_drop = if skip_contents {
764-
if adt.has_dtor(self.tcx()) {
764+
if adt.has_dtor(self.tcx()) && self.elaborator.get_drop_flag(self.path).is_some() {
765765
// the top-level drop flag is usually cleared by open_drop_for_adt_contents
766-
// types with destructors still need an empty drop ladder to clear it
766+
// types with destructors would still need an empty drop ladder to clear it
767767

768-
// currently no rust types can trigger this path in a context where drop flags exist
769-
// however, a future box-like "DerefMove" trait would allow it
770-
self.drop_ladder_bottom()
771-
} else {
772-
(self.succ, self.unwind, self.dropline)
768+
// however, these types are only open dropped in `DropShimElaborator`
769+
// which does not have drop flags
770+
// a future box-like "DerefMove" trait would allow for this case to happen
771+
span_bug!(self.source_info.span, "open dropping partially moved union");
773772
}
773+
774+
(self.succ, self.unwind, self.dropline)
774775
} else {
775776
self.open_drop_for_adt_contents(adt, args)
776777
};

0 commit comments

Comments
 (0)