Skip to content

Commit 1c1e795

Browse files
committed
remove is_replace field
1 parent 13fdf4c commit 1c1e795

File tree

16 files changed

+27
-97
lines changed

16 files changed

+27
-97
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
941941

942942
// drop and replace might have moved the assignment to the next block
943943
let maybe_additional_statement = if let Some(Terminator {
944-
kind: TerminatorKind::Drop { target: drop_target, is_replace: true, .. },
944+
kind: TerminatorKind::Drop { target: drop_target, .. },
945945
..
946946
}) = self.body[location.block].terminator
947947
{

compiler/rustc_borrowck/src/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
109109
TerminatorKind::SwitchInt { discr, targets: _ } => {
110110
self.consume_operand(location, discr);
111111
}
112-
TerminatorKind::Drop { place: drop_place, target: _, unwind: _, is_replace: _ } => {
112+
TerminatorKind::Drop { place: drop_place, target: _, unwind: _ } => {
113113
self.access_place(
114114
location,
115115
*drop_place,

compiler/rustc_borrowck/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
578578
StatementKind::Assign(box (lhs, rhs)) => {
579579
self.consume_rvalue(location, (rhs, span), flow_state);
580580

581-
self.mutate_place(location, (*lhs, span), AccessDepth::Shallow(None), flow_state);
581+
self.mutate_place(location, (*lhs, span), Shallow(None), flow_state);
582582
}
583583
StatementKind::FakeRead(box (_, place)) => {
584584
// Read for match doesn't access any memory and is used to
@@ -644,7 +644,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
644644
TerminatorKind::SwitchInt { discr, targets: _ } => {
645645
self.consume_operand(loc, (discr, span), flow_state);
646646
}
647-
TerminatorKind::Drop { place, target: _, unwind: _, is_replace: _ } => {
647+
TerminatorKind::Drop { place, target: _, unwind: _ } => {
648648
debug!(
649649
"visit_terminator_drop \
650650
loc: {:?} term: {:?} place: {:?} span: {:?}",

compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
477477
| TerminatorKind::GeneratorDrop => {
478478
bug!("shouldn't exist at codegen {:?}", bb_data.terminator());
479479
}
480-
TerminatorKind::Drop { place, target, unwind: _, is_replace: _ } => {
480+
TerminatorKind::Drop { place, target, unwind: _ } => {
481481
let drop_place = codegen_place(fx, *place);
482482
crate::abi::codegen_drop(fx, source_info, drop_place);
483483

compiler/rustc_codegen_ssa/src/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13051305
MergingSucc::False
13061306
}
13071307

1308-
mir::TerminatorKind::Drop { place, target, unwind, is_replace: _ } => {
1308+
mir::TerminatorKind::Drop { place, target, unwind } => {
13091309
self.codegen_drop_terminator(helper, bx, place, target, unwind, mergeable_succ())
13101310
}
13111311

compiler/rustc_const_eval/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
118118
}
119119
}
120120

121-
Drop { place, target, unwind, is_replace: _ } => {
121+
Drop { place, target, unwind } => {
122122
let frame = self.frame();
123123
let ty = place.ty(&frame.body.local_decls, *self.tcx).ty;
124124
let ty = self.subst_from_frame_and_normalize_erasing_regions(frame, ty)?;

compiler/rustc_middle/src/mir/syntax.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -577,14 +577,7 @@ pub enum TerminatorKind<'tcx> {
577577
/// > The drop glue is executed if, among all statements executed within this `Body`, an assignment to
578578
/// > the place or one of its "parents" occurred more recently than a move out of it. This does not
579579
/// > consider indirect assignments.
580-
Drop {
581-
place: Place<'tcx>,
582-
target: BasicBlock,
583-
unwind: Option<BasicBlock>,
584-
/// This field is only used for better diagnostic and to check MIR drop invariants.
585-
/// It has no effect on the semantics of the `Drop` terminator.
586-
is_replace: bool,
587-
},
580+
Drop { place: Place<'tcx>, target: BasicBlock, unwind: Option<BasicBlock> },
588581

589582
/// Roughly speaking, evaluates the `func` operand and the arguments, and starts execution of
590583
/// the referred to function. The operand types must match the argument types of the function.

compiler/rustc_middle/src/mir/visit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ macro_rules! make_mir_visitor {
486486
place,
487487
target: _,
488488
unwind: _,
489-
is_replace: _,
490489
} => {
491490
self.visit_place(
492491
place,

compiler/rustc_mir_build/src/build/custom/parse/instruction.rs

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
4747
place: self.parse_place(args[0])?,
4848
target: self.parse_block(args[1])?,
4949
unwind: None,
50-
is_replace: false
5150
})
5251
},
5352
@call("mir_call", args) => {

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -624,12 +624,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
624624
this.cfg.terminate(
625625
block,
626626
outer_source_info,
627-
TerminatorKind::Drop {
628-
place: to_drop,
629-
target: success,
630-
unwind: None,
631-
is_replace: false,
632-
},
627+
TerminatorKind::Drop { place: to_drop, target: success, unwind: None },
633628
);
634629
this.diverge_from(block);
635630
block = success;

compiler/rustc_mir_build/src/build/scope.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ impl DropTree {
371371
// The caller will handle this if needed.
372372
unwind: None,
373373
place: drop_data.0.local.into(),
374-
is_replace: false,
375374
};
376375
cfg.terminate(block, drop_data.0.source_info, terminator);
377376
}
@@ -1139,12 +1138,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
11391138
self.cfg.terminate(
11401139
block,
11411140
source_info,
1142-
TerminatorKind::Drop {
1143-
place,
1144-
target: next_target,
1145-
unwind: Some(assign),
1146-
is_replace: true,
1147-
},
1141+
TerminatorKind::Drop { place, target: next_target, unwind: Some(assign) },
11481142
);
11491143

11501144
self.diverge_from(block);
@@ -1248,12 +1242,7 @@ fn build_scope_drops<'tcx>(
12481242
cfg.terminate(
12491243
block,
12501244
source_info,
1251-
TerminatorKind::Drop {
1252-
place: local.into(),
1253-
target: next,
1254-
unwind: None,
1255-
is_replace: false,
1256-
},
1245+
TerminatorKind::Drop { place: local.into(), target: next, unwind: None },
12571246
);
12581247
block = next;
12591248
}

compiler/rustc_mir_dataflow/src/elaborate_drops.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ where
164164
path: D::Path,
165165
succ: BasicBlock,
166166
unwind: Unwind,
167-
is_replace: bool,
168167
}
169168

170169
/// "Elaborates" a drop of `place`/`path` and patches `bb`'s terminator to execute it.
@@ -183,12 +182,11 @@ pub fn elaborate_drop<'b, 'tcx, D>(
183182
succ: BasicBlock,
184183
unwind: Unwind,
185184
bb: BasicBlock,
186-
is_replace: bool,
187185
) where
188186
D: DropElaborator<'b, 'tcx>,
189187
'tcx: 'b,
190188
{
191-
DropCtxt { elaborator, source_info, place, path, succ, unwind, is_replace }.elaborate_drop(bb)
189+
DropCtxt { elaborator, source_info, place, path, succ, unwind }.elaborate_drop(bb)
192190
}
193191

194192
impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
@@ -239,7 +237,6 @@ where
239237
place: self.place,
240238
target: self.succ,
241239
unwind: self.unwind.into_option(),
242-
is_replace: self.is_replace,
243240
},
244241
);
245242
}
@@ -301,7 +298,6 @@ where
301298
place,
302299
succ,
303300
unwind,
304-
is_replace: self.is_replace,
305301
}
306302
.elaborated_drop_block()
307303
} else {
@@ -316,7 +312,6 @@ where
316312
// Using `self.path` here to condition the drop on
317313
// our own drop flag.
318314
path: self.path,
319-
is_replace: self.is_replace,
320315
}
321316
.complete_drop(succ, unwind)
322317
}
@@ -735,7 +730,6 @@ where
735730
place: tcx.mk_place_deref(ptr),
736731
target: loop_block,
737732
unwind: unwind.into_option(),
738-
is_replace: self.is_replace,
739733
},
740734
);
741735

@@ -997,12 +991,8 @@ where
997991
}
998992

999993
fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
1000-
let block = TerminatorKind::Drop {
1001-
place: self.place,
1002-
target,
1003-
unwind: unwind.into_option(),
1004-
is_replace: self.is_replace,
1005-
};
994+
let block =
995+
TerminatorKind::Drop { place: self.place, target, unwind: unwind.into_option() };
1006996
self.new_block(unwind, block)
1007997
}
1008998

compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn add_move_for_packed_drop<'tcx>(
8080
is_cleanup: bool,
8181
) {
8282
debug!("add_move_for_packed_drop({:?} @ {:?})", terminator, loc);
83-
let TerminatorKind::Drop { ref place, target, unwind, is_replace: _ } = terminator.kind else {
83+
let TerminatorKind::Drop { ref place, target, unwind } = terminator.kind else {
8484
unreachable!();
8585
};
8686

@@ -98,11 +98,6 @@ fn add_move_for_packed_drop<'tcx>(
9898
patch.add_assign(loc, Place::from(temp), Rvalue::Use(Operand::Move(*place)));
9999
patch.patch_terminator(
100100
loc.block,
101-
TerminatorKind::Drop {
102-
place: Place::from(temp),
103-
target: storage_dead_block,
104-
unwind,
105-
is_replace: false,
106-
},
101+
TerminatorKind::Drop { place: Place::from(temp), target: storage_dead_block, unwind },
107102
);
108103
}

compiler/rustc_mir_transform/src/elaborate_drops.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
358358

359359
let resume_block = self.patch.resume_block();
360360
match terminator.kind {
361-
TerminatorKind::Drop { mut place, target, unwind, is_replace } => {
361+
TerminatorKind::Drop { mut place, target, unwind } => {
362362
if let Some(new_place) = self.un_derefer.derefer(place.as_ref(), self.body) {
363363
place = new_place;
364364
}
@@ -377,17 +377,12 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
377377
Unwind::To(Option::unwrap_or(unwind, resume_block))
378378
},
379379
bb,
380-
is_replace,
381380
),
382381
LookupResult::Parent(..) => {
383-
if !is_replace {
384-
self.tcx.sess.delay_span_bug(
385-
terminator.source_info.span,
386-
&format!("drop of untracked value {:?}", bb),
387-
);
388-
}
389382
// drop and replace behind a pointer/array/whatever. The location
390383
// must be initialized.
384+
// FIXME: should we check that it's actually the case and we did
385+
// not wrongly emit a drop terminator somewhere / missed move data?
391386
Elaborator { ctxt: self }.patch().patch_terminator(
392387
bb,
393388
TerminatorKind::Drop {
@@ -398,7 +393,6 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
398393
} else {
399394
Some(Option::unwrap_or(unwind, resume_block))
400395
},
401-
is_replace,
402396
},
403397
);
404398
}

compiler/rustc_mir_transform/src/generator.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -911,14 +911,11 @@ fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
911911
let mut elaborator = DropShimElaborator { body, patch: MirPatch::new(body), tcx, param_env };
912912

913913
for (block, block_data) in body.basic_blocks.iter_enumerated() {
914-
let (target, unwind, source_info, is_replace) = match block_data.terminator() {
915-
Terminator {
916-
source_info,
917-
kind: TerminatorKind::Drop { place, target, unwind, is_replace },
918-
} => {
914+
let (target, unwind, source_info) = match block_data.terminator() {
915+
Terminator { source_info, kind: TerminatorKind::Drop { place, target, unwind } } => {
919916
if let Some(local) = place.as_local() {
920917
if local == SELF_ARG {
921-
(target, unwind, source_info, is_replace)
918+
(target, unwind, source_info)
922919
} else {
923920
continue;
924921
}
@@ -941,7 +938,6 @@ fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
941938
*target,
942939
unwind,
943940
block,
944-
*is_replace,
945941
);
946942
}
947943
elaborator.patch.apply(body);
@@ -1166,12 +1162,8 @@ fn create_generator_resume_function<'tcx>(
11661162
fn insert_clean_drop(body: &mut Body<'_>) -> BasicBlock {
11671163
let return_block = insert_term_block(body, TerminatorKind::Return);
11681164

1169-
let term = TerminatorKind::Drop {
1170-
place: Place::from(SELF_ARG),
1171-
target: return_block,
1172-
unwind: None,
1173-
is_replace: false,
1174-
};
1165+
let term =
1166+
TerminatorKind::Drop { place: Place::from(SELF_ARG), target: return_block, unwind: None };
11751167
let source_info = SourceInfo::outermost(body.span);
11761168

11771169
// Create a block to destroy an unresumed generators. This can only destroy upvars.

compiler/rustc_mir_transform/src/shim.rs

+3-19
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
218218
return_block,
219219
elaborate_drops::Unwind::To(resume_block),
220220
START_BLOCK,
221-
false,
222221
);
223222
elaborator.patch
224223
};
@@ -512,12 +511,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
512511
self.make_clone_call(dest_field, src_field, ity, next_block, unwind);
513512
self.block(
514513
vec![],
515-
TerminatorKind::Drop {
516-
place: dest_field,
517-
target: unwind,
518-
unwind: None,
519-
is_replace: false,
520-
},
514+
TerminatorKind::Drop { place: dest_field, target: unwind, unwind: None },
521515
true,
522516
);
523517
unwind = next_unwind;
@@ -769,12 +763,7 @@ fn build_call_shim<'tcx>(
769763
block(
770764
&mut blocks,
771765
vec![],
772-
TerminatorKind::Drop {
773-
place: rcvr_place(),
774-
target: BasicBlock::new(2),
775-
unwind: None,
776-
is_replace: false,
777-
},
766+
TerminatorKind::Drop { place: rcvr_place(), target: BasicBlock::new(2), unwind: None },
778767
false,
779768
);
780769
}
@@ -785,12 +774,7 @@ fn build_call_shim<'tcx>(
785774
block(
786775
&mut blocks,
787776
vec![],
788-
TerminatorKind::Drop {
789-
place: rcvr_place(),
790-
target: BasicBlock::new(4),
791-
unwind: None,
792-
is_replace: false,
793-
},
777+
TerminatorKind::Drop { place: rcvr_place(), target: BasicBlock::new(4), unwind: None },
794778
true,
795779
);
796780

0 commit comments

Comments
 (0)