about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2021-11-30 15:45:16 -0800
committerDylan MacKenzie <ecstaticmorse@gmail.com>2021-11-30 17:25:30 -0800
commit3e0e8be037f79a8d2da521e75e52795727474beb (patch)
tree9b6a6039eb13c89726cc4e688318b522b137ed83
parentce2959da97aa98596ee041a3e42d30e50e3f2d7b (diff)
downloadrust-3e0e8be037f79a8d2da521e75e52795727474beb.tar.gz
rust-3e0e8be037f79a8d2da521e75e52795727474beb.zip
Handle `DropAndReplace` in const-checking
It runs before the real drop elaboration pass.
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs b/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs
index 7a2be3c3bad..c1d47baa405 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs
@@ -80,7 +80,8 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
         trace!("visit_terminator: terminator={:?} location={:?}", terminator, location);
 
         match &terminator.kind {
-            mir::TerminatorKind::Drop { place: dropped_place, .. } => {
+            mir::TerminatorKind::Drop { place: dropped_place, .. }
+            | mir::TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
                 let dropped_ty = dropped_place.ty(self.body, self.tcx).ty;
                 if !NeedsNonConstDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
                     // Instead of throwing a bug, we just return here. This is because we have to
@@ -104,11 +105,6 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
                 }
             }
 
-            mir::TerminatorKind::DropAndReplace { .. } => span_bug!(
-                terminator.source_info.span,
-                "`DropAndReplace` should be removed by drop elaboration",
-            ),
-
             mir::TerminatorKind::Abort
             | mir::TerminatorKind::Call { .. }
             | mir::TerminatorKind::Assert { .. }