Skip to content

Commit 4e84fbf

Browse files
authored
Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko
Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.
2 parents 2428083 + 153bfa0 commit 4e84fbf

File tree

48 files changed

+33
-344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+33
-344
lines changed

compiler/rustc_borrowck/src/invalidation.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
118118
LocalMutationIsAllowed::Yes,
119119
);
120120
}
121-
TerminatorKind::DropAndReplace {
122-
place: drop_place,
123-
value: new_value,
124-
target: _,
125-
unwind: _,
126-
} => {
127-
self.mutate_place(location, *drop_place, Deep);
128-
self.consume_operand(location, new_value);
129-
}
130121
TerminatorKind::Call {
131122
func,
132123
args,

compiler/rustc_borrowck/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -743,15 +743,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
743743
flow_state,
744744
);
745745
}
746-
TerminatorKind::DropAndReplace {
747-
place: drop_place,
748-
value: new_value,
749-
target: _,
750-
unwind: _,
751-
} => {
752-
self.mutate_place(loc, (*drop_place, span), Deep, flow_state);
753-
self.consume_operand(loc, (new_value, span), flow_state);
754-
}
755746
TerminatorKind::Call {
756747
func,
757748
args,
@@ -866,7 +857,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
866857
| TerminatorKind::Assert { .. }
867858
| TerminatorKind::Call { .. }
868859
| TerminatorKind::Drop { .. }
869-
| TerminatorKind::DropAndReplace { .. }
870860
| TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ }
871861
| TerminatorKind::FalseUnwind { real_target: _, unwind: _ }
872862
| TerminatorKind::Goto { .. }

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
435435
//
436436
// What we *actually* generate is a store to a temporary
437437
// for the call (`TMP = call()...`) and then a
438-
// `DropAndReplace` to swap that with `X`
439-
// (`DropAndReplace` has very particular semantics).
438+
// `Drop(X)` followed by `X = TMP` to swap that with `X`.
440439
}
441440
}
442441

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,24 +1312,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13121312
// no checks needed for these
13131313
}
13141314

1315-
TerminatorKind::DropAndReplace { place, value, target: _, unwind: _ } => {
1316-
let place_ty = place.ty(body, tcx).ty;
1317-
let rv_ty = value.ty(body, tcx);
1318-
1319-
let locations = term_location.to_locations();
1320-
if let Err(terr) =
1321-
self.sub_types(rv_ty, place_ty, locations, ConstraintCategory::Assignment)
1322-
{
1323-
span_mirbug!(
1324-
self,
1325-
term,
1326-
"bad DropAndReplace ({:?} = {:?}): {:?}",
1327-
place_ty,
1328-
rv_ty,
1329-
terr
1330-
);
1331-
}
1332-
}
13331315
TerminatorKind::SwitchInt { discr, .. } => {
13341316
self.check_operand(discr, term_location);
13351317

@@ -1629,7 +1611,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16291611
}
16301612
TerminatorKind::Unreachable => {}
16311613
TerminatorKind::Drop { target, unwind, .. }
1632-
| TerminatorKind::DropAndReplace { target, unwind, .. }
16331614
| TerminatorKind::Assert { target, cleanup: unwind, .. } => {
16341615
self.assert_iscleanup(body, block_data, target, is_cleanup);
16351616
if let Some(unwind) = unwind {

compiler/rustc_borrowck/src/used_muts.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
7171
TerminatorKind::Call { destination, .. } => {
7272
self.remove_never_initialized_mut_locals(*destination);
7373
}
74-
TerminatorKind::DropAndReplace { place, .. } => {
75-
self.remove_never_initialized_mut_locals(*place);
76-
}
7774
_ => {}
7875
}
7976

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
499499
TerminatorKind::Yield { .. }
500500
| TerminatorKind::FalseEdge { .. }
501501
| TerminatorKind::FalseUnwind { .. }
502-
| TerminatorKind::DropAndReplace { .. }
503502
| TerminatorKind::GeneratorDrop => {
504503
bug!("shouldn't exist at codegen {:?}", bb_data.terminator());
505504
}

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
543543
| TerminatorKind::Unreachable
544544
| TerminatorKind::Drop { .. }
545545
| TerminatorKind::Assert { .. } => {}
546-
TerminatorKind::DropAndReplace { .. }
547-
| TerminatorKind::Yield { .. }
546+
TerminatorKind::Yield { .. }
548547
| TerminatorKind::GeneratorDrop
549548
| TerminatorKind::FalseEdge { .. }
550549
| TerminatorKind::FalseUnwind { .. } => unreachable!(),

compiler/rustc_codegen_ssa/src/mir/analyze.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKi
295295
TerminatorKind::Call { cleanup: unwind, .. }
296296
| TerminatorKind::InlineAsm { cleanup: unwind, .. }
297297
| TerminatorKind::Assert { cleanup: unwind, .. }
298-
| TerminatorKind::DropAndReplace { unwind, .. }
299298
| TerminatorKind::Drop { unwind, .. } => {
300299
if let Some(unwind) = unwind {
301300
debug!(

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,10 +1305,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13051305
mergeable_succ(),
13061306
),
13071307

1308-
mir::TerminatorKind::DropAndReplace { .. } => {
1309-
bug!("undesugared DropAndReplace in codegen: {:?}", terminator);
1310-
}
1311-
13121308
mir::TerminatorKind::Call {
13131309
ref func,
13141310
ref args,

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
171171
Unreachable => throw_ub!(Unreachable),
172172

173173
// These should never occur for MIR we actually run.
174-
DropAndReplace { .. }
175-
| FalseEdge { .. }
176-
| FalseUnwind { .. }
177-
| Yield { .. }
178-
| GeneratorDrop => span_bug!(
174+
FalseEdge { .. } | FalseUnwind { .. } | Yield { .. } | GeneratorDrop => span_bug!(
179175
terminator.source_info.span,
180176
"{:#?} should have been eliminated by MIR pass",
181177
terminator.kind

0 commit comments

Comments
 (0)