about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2025-05-27 01:29:18 +0800
committerGitHub <noreply@github.com>2025-05-27 01:29:18 +0800
commit0e710d0883709d34bfbb76f6813a83fa8fb96c23 (patch)
tree84d5b45665cad40db592f0e93bd245b497cd984c /compiler/rustc_mir_transform/src
parentaa9978229eacda5b12f7d18de79f0f72f431f33f (diff)
parent11392f4978fe3a81a87e4fd8abcb78a0dcf166e5 (diff)
downloadrust-0e710d0883709d34bfbb76f6813a83fa8fb96c23.tar.gz
rust-0e710d0883709d34bfbb76f6813a83fa8fb96c23.zip
Rollup merge of #141431 - compiler-errors:open-drop, r=oli-obk
Emit dummy open drop for unsafe binder

Fixes rust-lang/rust#141394

We can't taint the body in wfcheck when we have a `T: Copy` bound failure, so we end up binding MIR here. Emit a dummy open drop so that drop elaboration doesn't fail.

r? oli-obk
Diffstat (limited to 'compiler/rustc_mir_transform/src')
-rw-r--r--compiler/rustc_mir_transform/src/elaborate_drop.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs
index 14f7c2a263b..211e2a92f73 100644
--- a/compiler/rustc_mir_transform/src/elaborate_drop.rs
+++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs
@@ -1278,6 +1278,23 @@ where
             }
             ty::Slice(ety) => self.drop_loop_trio_for_slice(*ety),
 
+            ty::UnsafeBinder(_) => {
+                // Unsafe binders may elaborate drops if their inner type isn't copy.
+                // This is enforced in typeck, so this should never happen.
+                self.tcx().dcx().span_delayed_bug(
+                    self.source_info.span,
+                    "open drop for unsafe binder shouldn't be encountered",
+                );
+                self.elaborator.patch().new_block(BasicBlockData {
+                    statements: vec![],
+                    terminator: Some(Terminator {
+                        source_info: self.source_info,
+                        kind: TerminatorKind::Unreachable,
+                    }),
+                    is_cleanup: self.unwind.is_cleanup(),
+                })
+            }
+
             _ => span_bug!(self.source_info.span, "open drop from non-ADT `{:?}`", ty),
         }
     }