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

Commit 6a95bf8

Browse files
committed
Use Place directly on Operand::place and friends, it's Copy
1 parent 890b393 commit 6a95bf8

File tree

9 files changed

+33
-33
lines changed

9 files changed

+33
-33
lines changed

src/librustc_middle/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,9 +2030,9 @@ impl<'tcx> Operand<'tcx> {
20302030

20312031
/// Returns the `Place` that is the target of this `Operand`, or `None` if this `Operand` is a
20322032
/// constant.
2033-
pub fn place(&self) -> Option<&Place<'tcx>> {
2033+
pub fn place(&self) -> Option<Place<'tcx>> {
20342034
match self {
2035-
Operand::Copy(place) | Operand::Move(place) => Some(place),
2035+
Operand::Copy(place) | Operand::Move(place) => Some(*place),
20362036
Operand::Constant(_) => None,
20372037
}
20382038
}

src/librustc_mir/dataflow/framework/cursor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ where
135135
target.block,
136136
func,
137137
args,
138-
return_place,
138+
*return_place,
139139
);
140140
}
141141
TerminatorKind::Yield { resume, resume_arg, .. } => {
142142
self.results.borrow().analysis.apply_yield_resume_effect(
143143
&mut self.state,
144144
*resume,
145-
resume_arg,
145+
*resume_arg,
146146
);
147147
}
148148
_ => {}

src/librustc_mir/dataflow/framework/engine.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ where
228228
self.propagate_bits_into_entry_set_for(in_out, drop, dirty_list);
229229
}
230230

231-
self.analysis.apply_yield_resume_effect(in_out, target, &resume_arg);
231+
self.analysis.apply_yield_resume_effect(in_out, target, resume_arg);
232232
self.propagate_bits_into_entry_set_for(in_out, target, dirty_list);
233233
}
234234

@@ -272,7 +272,7 @@ where
272272
}
273273
}
274274

275-
if let Some((ref dest_place, dest_bb)) = *destination {
275+
if let Some((dest_place, dest_bb)) = *destination {
276276
// N.B.: This must be done *last*, otherwise the unwind path will see the call
277277
// return effect.
278278
self.analysis.apply_call_return_effect(in_out, bb, func, args, dest_place);
@@ -314,7 +314,7 @@ where
314314
in_out: &mut BitSet<A::Idx>,
315315
bb: BasicBlock,
316316
enum_def: &'tcx ty::AdtDef,
317-
enum_place: &mir::Place<'tcx>,
317+
enum_place: mir::Place<'tcx>,
318318
dirty_list: &mut WorkQueue<BasicBlock>,
319319
values: &[u128],
320320
targets: &[BasicBlock],
@@ -361,14 +361,14 @@ fn switch_on_enum_discriminant(
361361
tcx: TyCtxt<'tcx>,
362362
body: &'mir mir::Body<'tcx>,
363363
block: &'mir mir::BasicBlockData<'tcx>,
364-
switch_on: &mir::Place<'tcx>,
365-
) -> Option<(&'mir mir::Place<'tcx>, &'tcx ty::AdtDef)> {
364+
switch_on: mir::Place<'tcx>,
365+
) -> Option<(mir::Place<'tcx>, &'tcx ty::AdtDef)> {
366366
match block.statements.last().map(|stmt| &stmt.kind) {
367367
Some(mir::StatementKind::Assign(box (lhs, mir::Rvalue::Discriminant(discriminated))))
368-
if lhs == switch_on =>
368+
if *lhs == switch_on =>
369369
{
370370
match &discriminated.ty(body, tcx).ty.kind {
371-
ty::Adt(def, _) => Some((discriminated, def)),
371+
ty::Adt(def, _) => Some((*discriminated, def)),
372372

373373
// `Rvalue::Discriminant` is also used to get the active yield point for a
374374
// generator, but we do not need edge-specific effects in that case. This may

src/librustc_mir/dataflow/framework/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
225225
block: BasicBlock,
226226
func: &mir::Operand<'tcx>,
227227
args: &[mir::Operand<'tcx>],
228-
return_place: &mir::Place<'tcx>,
228+
return_place: mir::Place<'tcx>,
229229
);
230230

231231
/// Updates the current dataflow state with the effect of resuming from a `Yield` terminator.
@@ -238,7 +238,7 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
238238
&self,
239239
_state: &mut BitSet<Self::Idx>,
240240
_resume_block: BasicBlock,
241-
_resume_place: &mir::Place<'tcx>,
241+
_resume_place: mir::Place<'tcx>,
242242
) {
243243
}
244244

@@ -251,7 +251,7 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
251251
&self,
252252
_state: &mut BitSet<Self::Idx>,
253253
_block: BasicBlock,
254-
_enum_place: &mir::Place<'tcx>,
254+
_enum_place: mir::Place<'tcx>,
255255
_adt: &ty::AdtDef,
256256
_variant: VariantIdx,
257257
) {
@@ -332,15 +332,15 @@ pub trait GenKillAnalysis<'tcx>: Analysis<'tcx> {
332332
block: BasicBlock,
333333
func: &mir::Operand<'tcx>,
334334
args: &[mir::Operand<'tcx>],
335-
return_place: &mir::Place<'tcx>,
335+
return_place: mir::Place<'tcx>,
336336
);
337337

338338
/// See `Analysis::apply_yield_resume_effect`.
339339
fn yield_resume_effect(
340340
&self,
341341
_trans: &mut BitSet<Self::Idx>,
342342
_resume_block: BasicBlock,
343-
_resume_place: &mir::Place<'tcx>,
343+
_resume_place: mir::Place<'tcx>,
344344
) {
345345
}
346346

@@ -349,7 +349,7 @@ pub trait GenKillAnalysis<'tcx>: Analysis<'tcx> {
349349
&self,
350350
_state: &mut impl GenKill<Self::Idx>,
351351
_block: BasicBlock,
352-
_enum_place: &mir::Place<'tcx>,
352+
_enum_place: mir::Place<'tcx>,
353353
_adt: &ty::AdtDef,
354354
_variant: VariantIdx,
355355
) {
@@ -402,7 +402,7 @@ where
402402
block: BasicBlock,
403403
func: &mir::Operand<'tcx>,
404404
args: &[mir::Operand<'tcx>],
405-
return_place: &mir::Place<'tcx>,
405+
return_place: mir::Place<'tcx>,
406406
) {
407407
self.call_return_effect(state, block, func, args, return_place);
408408
}
@@ -411,7 +411,7 @@ where
411411
&self,
412412
state: &mut BitSet<Self::Idx>,
413413
resume_block: BasicBlock,
414-
resume_place: &mir::Place<'tcx>,
414+
resume_place: mir::Place<'tcx>,
415415
) {
416416
self.yield_resume_effect(state, resume_block, resume_place);
417417
}
@@ -420,7 +420,7 @@ where
420420
&self,
421421
state: &mut BitSet<Self::Idx>,
422422
block: BasicBlock,
423-
enum_place: &mir::Place<'tcx>,
423+
enum_place: mir::Place<'tcx>,
424424
adt: &ty::AdtDef,
425425
variant: VariantIdx,
426426
) {

src/librustc_mir/dataflow/impls/borrowed_locals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ where
123123
_block: mir::BasicBlock,
124124
_func: &mir::Operand<'tcx>,
125125
_args: &[mir::Operand<'tcx>],
126-
_dest_place: &mir::Place<'tcx>,
126+
_dest_place: mir::Place<'tcx>,
127127
) {
128128
}
129129
}

src/librustc_mir/dataflow/impls/borrows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<'tcx> dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
329329
_block: mir::BasicBlock,
330330
_func: &mir::Operand<'tcx>,
331331
_args: &[mir::Operand<'tcx>],
332-
_dest_place: &mir::Place<'tcx>,
332+
_dest_place: mir::Place<'tcx>,
333333
) {
334334
}
335335
}

src/librustc_mir/dataflow/impls/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
323323
_block: mir::BasicBlock,
324324
_func: &mir::Operand<'tcx>,
325325
_args: &[mir::Operand<'tcx>],
326-
dest_place: &mir::Place<'tcx>,
326+
dest_place: mir::Place<'tcx>,
327327
) {
328328
// when a call returns successfully, that means we need to set
329329
// the bits for that dest_place to 1 (initialized).
@@ -342,7 +342,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
342342
&self,
343343
trans: &mut impl GenKill<Self::Idx>,
344344
_block: mir::BasicBlock,
345-
enum_place: &mir::Place<'tcx>,
345+
enum_place: mir::Place<'tcx>,
346346
_adt: &ty::AdtDef,
347347
variant: VariantIdx,
348348
) {
@@ -425,7 +425,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
425425
_block: mir::BasicBlock,
426426
_func: &mir::Operand<'tcx>,
427427
_args: &[mir::Operand<'tcx>],
428-
dest_place: &mir::Place<'tcx>,
428+
dest_place: mir::Place<'tcx>,
429429
) {
430430
// when a call returns successfully, that means we need to set
431431
// the bits for that dest_place to 0 (initialized).
@@ -494,7 +494,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
494494
_block: mir::BasicBlock,
495495
_func: &mir::Operand<'tcx>,
496496
_args: &[mir::Operand<'tcx>],
497-
dest_place: &mir::Place<'tcx>,
497+
dest_place: mir::Place<'tcx>,
498498
) {
499499
// when a call returns successfully, that means we need to set
500500
// the bits for that dest_place to 1 (initialized).
@@ -585,7 +585,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
585585
block: mir::BasicBlock,
586586
_func: &mir::Operand<'tcx>,
587587
_args: &[mir::Operand<'tcx>],
588-
_dest_place: &mir::Place<'tcx>,
588+
_dest_place: mir::Place<'tcx>,
589589
) {
590590
let move_data = self.move_data();
591591
let init_loc_map = &move_data.init_loc_map;

src/librustc_mir/dataflow/impls/storage_liveness.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl dataflow::GenKillAnalysis<'tcx> for MaybeStorageLive {
5656
_block: BasicBlock,
5757
_func: &mir::Operand<'tcx>,
5858
_args: &[mir::Operand<'tcx>],
59-
_return_place: &mir::Place<'tcx>,
59+
_return_place: mir::Place<'tcx>,
6060
) {
6161
// Nothing to do when a call returns successfully
6262
}
@@ -231,7 +231,7 @@ impl<'mir, 'tcx> dataflow::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir,
231231
_block: BasicBlock,
232232
_func: &mir::Operand<'tcx>,
233233
_args: &[mir::Operand<'tcx>],
234-
return_place: &mir::Place<'tcx>,
234+
return_place: mir::Place<'tcx>,
235235
) {
236236
trans.gen(return_place.local);
237237
}
@@ -240,7 +240,7 @@ impl<'mir, 'tcx> dataflow::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir,
240240
&self,
241241
trans: &mut BitSet<Self::Idx>,
242242
_resume_block: BasicBlock,
243-
resume_place: &mir::Place<'tcx>,
243+
resume_place: mir::Place<'tcx>,
244244
) {
245245
trans.gen(resume_place.local);
246246
}

src/librustc_mir/transform/check_consts/resolver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ where
6868
_block: BasicBlock,
6969
_func: &mir::Operand<'tcx>,
7070
_args: &[mir::Operand<'tcx>],
71-
return_place: &mir::Place<'tcx>,
71+
return_place: mir::Place<'tcx>,
7272
) {
7373
// We cannot reason about another function's internals, so use conservative type-based
7474
// qualification for the result of a function call.
7575
let return_ty = return_place.ty(*self.item.body, self.item.tcx).ty;
7676
let qualif = Q::in_any_value_of_ty(self.item, return_ty);
7777

7878
if !return_place.is_indirect() {
79-
self.assign_qualif_direct(return_place, qualif);
79+
self.assign_qualif_direct(&return_place, qualif);
8080
}
8181
}
8282
}
@@ -214,7 +214,7 @@ where
214214
block: BasicBlock,
215215
func: &mir::Operand<'tcx>,
216216
args: &[mir::Operand<'tcx>],
217-
return_place: &mir::Place<'tcx>,
217+
return_place: mir::Place<'tcx>,
218218
) {
219219
self.transfer_function(state).apply_call_return_effect(block, func, args, return_place)
220220
}

0 commit comments

Comments
 (0)