about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
diff options
context:
space:
mode:
authorbeepster4096 <19316085+beepster4096@users.noreply.github.com>2025-07-18 13:11:03 -0700
committerbeepster4096 <19316085+beepster4096@users.noreply.github.com>2025-07-25 13:19:43 -0700
commitba55f20f4341ef5836c1f83beb0f2906e0600dc4 (patch)
tree9bb21f5e162819347256817d47a4f75b572899b3 /compiler/rustc_mir_transform/src
parentc6d740d37ec21bc3429283f03037ee49e9dea44b (diff)
downloadrust-ba55f20f4341ef5836c1f83beb0f2906e0600dc4.tar.gz
rust-ba55f20f4341ef5836c1f83beb0f2906e0600dc4.zip
span_bug instead of handling currently impossible drop case
Diffstat (limited to 'compiler/rustc_mir_transform/src')
-rw-r--r--compiler/rustc_mir_transform/src/elaborate_drop.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs
index 7d4e9412564..df4853c1dcb 100644
--- a/compiler/rustc_mir_transform/src/elaborate_drop.rs
+++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs
@@ -761,16 +761,17 @@ where
 
         let skip_contents = adt.is_union() || adt.is_manually_drop();
         let contents_drop = if skip_contents {
-            if adt.has_dtor(self.tcx()) {
+            if adt.has_dtor(self.tcx()) && self.elaborator.get_drop_flag(self.path).is_some() {
                 // the top-level drop flag is usually cleared by open_drop_for_adt_contents
-                // types with destructors still need an empty drop ladder to clear it
+                // types with destructors would still need an empty drop ladder to clear it
 
-                // currently no rust types can trigger this path in a context where drop flags exist
-                // however, a future box-like "DerefMove" trait would allow it
-                self.drop_ladder_bottom()
-            } else {
-                (self.succ, self.unwind, self.dropline)
+                // however, these types are only open dropped in `DropShimElaborator`
+                // which does not have drop flags
+                // a future box-like "DerefMove" trait would allow for this case to happen
+                span_bug!(self.source_info.span, "open dropping partially moved union");
             }
+
+            (self.succ, self.unwind, self.dropline)
         } else {
             self.open_drop_for_adt_contents(adt, args)
         };