Skip to content

Commit 3e0e8be

Browse files
Handle DropAndReplace in const-checking
It runs before the real drop elaboration pass.
1 parent ce2959d commit 3e0e8be

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
8080
trace!("visit_terminator: terminator={:?} location={:?}", terminator, location);
8181

8282
match &terminator.kind {
83-
mir::TerminatorKind::Drop { place: dropped_place, .. } => {
83+
mir::TerminatorKind::Drop { place: dropped_place, .. }
84+
| mir::TerminatorKind::DropAndReplace { place: dropped_place, .. } => {
8485
let dropped_ty = dropped_place.ty(self.body, self.tcx).ty;
8586
if !NeedsNonConstDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
8687
// 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> {
104105
}
105106
}
106107

107-
mir::TerminatorKind::DropAndReplace { .. } => span_bug!(
108-
terminator.source_info.span,
109-
"`DropAndReplace` should be removed by drop elaboration",
110-
),
111-
112108
mir::TerminatorKind::Abort
113109
| mir::TerminatorKind::Call { .. }
114110
| mir::TerminatorKind::Assert { .. }

0 commit comments

Comments
 (0)