Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 25528c1

Browse files
committed
Use Place directly, it's Copy more use cases
1 parent 760bca4 commit 25528c1

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

src/librustc_mir/shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn build_drop_shim<'tcx>(
230230
elaborate_drops::elaborate_drop(
231231
&mut elaborator,
232232
source_info,
233-
&dropee,
233+
dropee,
234234
(),
235235
return_block,
236236
elaborate_drops::Unwind::To(resume_block),

src/librustc_mir/transform/elaborate_drops.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
346346

347347
let resume_block = self.patch.resume_block();
348348
match terminator.kind {
349-
TerminatorKind::Drop { ref location, target, unwind } => {
349+
TerminatorKind::Drop { location, target, unwind } => {
350350
self.init_data.seek_before(loc);
351351
match self.move_data().rev_lookup.find(location.as_ref()) {
352352
LookupResult::Exact(path) => elaborate_drop(
@@ -371,7 +371,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
371371
}
372372
}
373373
}
374-
TerminatorKind::DropAndReplace { ref location, ref value, target, unwind } => {
374+
TerminatorKind::DropAndReplace { location, ref value, target, unwind } => {
375375
assert!(!data.is_cleanup);
376376

377377
self.elaborate_replace(loc, location, value, target, unwind);
@@ -396,7 +396,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
396396
fn elaborate_replace(
397397
&mut self,
398398
loc: Location,
399-
location: &Place<'tcx>,
399+
location: Place<'tcx>,
400400
value: &Operand<'tcx>,
401401
target: BasicBlock,
402402
unwind: Option<BasicBlock>,
@@ -407,7 +407,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
407407
assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported");
408408

409409
let assign = Statement {
410-
kind: StatementKind::Assign(box (*location, Rvalue::Use(value.clone()))),
410+
kind: StatementKind::Assign(box (location, Rvalue::Use(value.clone()))),
411411
source_info: terminator.source_info,
412412
};
413413

@@ -459,7 +459,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
459459
debug!("elaborate_drop_and_replace({:?}) - untracked {:?}", terminator, parent);
460460
self.patch.patch_terminator(
461461
bb,
462-
TerminatorKind::Drop { location: *location, target, unwind: Some(unwind) },
462+
TerminatorKind::Drop { location, target, unwind: Some(unwind) },
463463
);
464464
}
465465
}

src/librustc_mir/transform/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ fn elaborate_generator_drops<'tcx>(
853853
elaborate_drop(
854854
&mut elaborator,
855855
*source_info,
856-
&Place::from(SELF_ARG),
856+
Place::from(SELF_ARG),
857857
(),
858858
*target,
859859
unwind,

src/librustc_mir/util/elaborate_drops.rs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ where
100100

101101
source_info: SourceInfo,
102102

103-
place: &'l Place<'tcx>,
103+
place: Place<'tcx>,
104104
path: D::Path,
105105
succ: BasicBlock,
106106
unwind: Unwind,
@@ -109,7 +109,7 @@ where
109109
pub fn elaborate_drop<'b, 'tcx, D>(
110110
elaborator: &mut D,
111111
source_info: SourceInfo,
112-
place: &Place<'tcx>,
112+
place: Place<'tcx>,
113113
path: D::Path,
114114
succ: BasicBlock,
115115
unwind: Unwind,
@@ -126,7 +126,7 @@ where
126126
D: DropElaborator<'b, 'tcx>,
127127
'tcx: 'b,
128128
{
129-
fn place_ty(&self, place: &Place<'tcx>) -> Ty<'tcx> {
129+
fn place_ty(&self, place: Place<'tcx>) -> Ty<'tcx> {
130130
place.ty(self.elaborator.body(), self.tcx()).ty
131131
}
132132

@@ -168,7 +168,7 @@ where
168168
self.elaborator.patch().patch_terminator(
169169
bb,
170170
TerminatorKind::Drop {
171-
location: *self.place,
171+
location: self.place,
172172
target: self.succ,
173173
unwind: self.unwind.into_option(),
174174
},
@@ -195,7 +195,7 @@ where
195195
/// (the move path is `None` if the field is a rest field).
196196
fn move_paths_for_fields(
197197
&self,
198-
base_place: &Place<'tcx>,
198+
base_place: Place<'tcx>,
199199
variant_path: D::Path,
200200
variant: &'tcx ty::VariantDef,
201201
substs: SubstsRef<'tcx>,
@@ -219,7 +219,7 @@ where
219219

220220
fn drop_subpath(
221221
&mut self,
222-
place: &Place<'tcx>,
222+
place: Place<'tcx>,
223223
path: Option<D::Path>,
224224
succ: BasicBlock,
225225
unwind: Unwind,
@@ -267,12 +267,10 @@ where
267267
) -> Vec<BasicBlock> {
268268
Some(succ)
269269
.into_iter()
270-
.chain(fields.iter().rev().zip(unwind_ladder).map(
271-
|(&(ref place, path), &unwind_succ)| {
272-
succ = self.drop_subpath(place, path, succ, unwind_succ);
273-
succ
274-
},
275-
))
270+
.chain(fields.iter().rev().zip(unwind_ladder).map(|(&(place, path), &unwind_succ)| {
271+
succ = self.drop_subpath(place, path, succ, unwind_succ);
272+
succ
273+
}))
276274
.collect()
277275
}
278276

@@ -315,7 +313,7 @@ where
315313
debug!("drop_ladder({:?}, {:?})", self, fields);
316314

317315
let mut fields = fields;
318-
fields.retain(|&(ref place, _)| {
316+
fields.retain(|&(place, _)| {
319317
self.place_ty(place).needs_drop(self.tcx(), self.elaborator.param_env())
320318
});
321319

@@ -364,7 +362,7 @@ where
364362
let unwind_succ =
365363
self.unwind.map(|unwind| self.box_free_block(adt, substs, unwind, Unwind::InCleanup));
366364

367-
self.drop_subpath(&interior, interior_path, succ, unwind_succ)
365+
self.drop_subpath(interior, interior_path, succ, unwind_succ)
368366
}
369367

370368
fn open_drop_for_adt(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock {
@@ -439,8 +437,7 @@ where
439437
self.place.clone(),
440438
ProjectionElem::Downcast(Some(variant.ident.name), variant_index),
441439
);
442-
let fields =
443-
self.move_paths_for_fields(&base_place, variant_path, &variant, substs);
440+
let fields = self.move_paths_for_fields(base_place, variant_path, &variant, substs);
444441
values.push(discr.val);
445442
if let Unwind::To(unwind) = unwind {
446443
// We can't use the half-ladder from the original
@@ -527,7 +524,7 @@ where
527524
// way lies only trouble.
528525
let discr_ty = adt.repr.discr_type().to_ty(self.tcx());
529526
let discr = Place::from(self.new_temp(discr_ty));
530-
let discr_rv = Rvalue::Discriminant(*self.place);
527+
let discr_rv = Rvalue::Discriminant(self.place);
531528
let switch_block = BasicBlockData {
532529
statements: vec![self.assign(&discr, discr_rv)],
533530
terminator: Some(Terminator {
@@ -564,7 +561,7 @@ where
564561
Rvalue::Ref(
565562
tcx.lifetimes.re_erased,
566563
BorrowKind::Mut { allow_two_phase_borrow: false },
567-
*self.place,
564+
self.place,
568565
),
569566
)],
570567
terminator: Some(Terminator {
@@ -712,7 +709,7 @@ where
712709
let base_block = BasicBlockData {
713710
statements: vec![
714711
self.assign(elem_size, Rvalue::NullaryOp(NullOp::SizeOf, ety)),
715-
self.assign(len, Rvalue::Len(*self.place)),
712+
self.assign(len, Rvalue::Len(self.place)),
716713
],
717714
is_cleanup: self.unwind.is_cleanup(),
718715
terminator: Some(Terminator {
@@ -761,7 +758,7 @@ where
761758
// cur = tmp as *mut T;
762759
// end = Offset(cur, len);
763760
vec![
764-
self.assign(&tmp, Rvalue::AddressOf(Mutability::Mut, *self.place)),
761+
self.assign(&tmp, Rvalue::AddressOf(Mutability::Mut, self.place)),
765762
self.assign(&cur, Rvalue::Cast(CastKind::Misc, Operand::Move(tmp), iter_ty)),
766763
self.assign(
767764
&length_or_end,
@@ -935,7 +932,7 @@ where
935932

936933
fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
937934
let block =
938-
TerminatorKind::Drop { location: *self.place, target, unwind: unwind.into_option() };
935+
TerminatorKind::Drop { location: self.place, target, unwind: unwind.into_option() };
939936
self.new_block(unwind, block)
940937
}
941938

0 commit comments

Comments
 (0)