Skip to content

Commit b5b6be0

Browse files
committed
Local field on PlaceRef and RootPlace is not a reference anymore
1 parent 39d93b1 commit b5b6be0

File tree

22 files changed

+90
-90
lines changed

22 files changed

+90
-90
lines changed

src/librustc/mir/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ rustc_index::newtype_index! {
17731773

17741774
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
17751775
pub struct PlaceRef<'a, 'tcx> {
1776-
pub local: &'a Local,
1776+
pub local: Local,
17771777
pub projection: &'a [PlaceElem<'tcx>],
17781778
}
17791779

@@ -1798,7 +1798,7 @@ impl<'tcx> Place<'tcx> {
17981798
pub fn local_or_deref_local(&self) -> Option<Local> {
17991799
match self.as_ref() {
18001800
PlaceRef { local, projection: &[] }
1801-
| PlaceRef { local, projection: &[ProjectionElem::Deref] } => Some(*local),
1801+
| PlaceRef { local, projection: &[ProjectionElem::Deref] } => Some(local),
18021802
_ => None,
18031803
}
18041804
}
@@ -1810,7 +1810,7 @@ impl<'tcx> Place<'tcx> {
18101810
}
18111811

18121812
pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> {
1813-
PlaceRef { local: &self.local, projection: &self.projection }
1813+
PlaceRef { local: self.local, projection: &self.projection }
18141814
}
18151815
}
18161816

@@ -1826,18 +1826,18 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
18261826
//
18271827
// FIXME: can we safely swap the semantics of `fn base_local` below in here instead?
18281828
pub fn local_or_deref_local(&self) -> Option<Local> {
1829-
match self {
1829+
match *self {
18301830
PlaceRef { local, projection: [] }
1831-
| PlaceRef { local, projection: [ProjectionElem::Deref] } => Some(**local),
1831+
| PlaceRef { local, projection: [ProjectionElem::Deref] } => Some(local),
18321832
_ => None,
18331833
}
18341834
}
18351835

18361836
/// If this place represents a local variable like `_X` with no
18371837
/// projections, return `Some(_X)`.
18381838
pub fn as_local(&self) -> Option<Local> {
1839-
match self {
1840-
PlaceRef { local, projection: [] } => Some(**local),
1839+
match *self {
1840+
PlaceRef { local, projection: [] } => Some(local),
18411841
_ => None,
18421842
}
18431843
}

src/librustc_codegen_ssa/mir/analyze.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
128128
};
129129
if is_consume {
130130
let base_ty =
131-
mir::Place::ty_from(place_ref.local, proj_base, *self.fx.mir, cx.tcx());
131+
mir::Place::ty_from(&place_ref.local, proj_base, *self.fx.mir, cx.tcx());
132132
let base_ty = self.fx.monomorphize(&base_ty);
133133

134134
// ZSTs don't require any actual memory access.
135135
let elem_ty = base_ty.projection_ty(cx.tcx(), elem).ty;
136136
let elem_ty = self.fx.monomorphize(&elem_ty);
137-
let span = self.fx.mir.local_decls[*place_ref.local].source_info.span;
137+
let span = self.fx.mir.local_decls[place_ref.local].source_info.span;
138138
if cx.spanned_layout_of(elem_ty, span).is_zst() {
139139
return;
140140
}
@@ -174,7 +174,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
174174
// We use `NonUseContext::VarDebugInfo` for the base,
175175
// which might not force the base local to memory,
176176
// so we have to do it manually.
177-
self.visit_local(place_ref.local, context, location);
177+
self.visit_local(&place_ref.local, context, location);
178178
}
179179
}
180180

@@ -212,8 +212,8 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
212212
};
213213
}
214214

215-
self.visit_place_base(place_ref.local, context, location);
216-
self.visit_projection(place_ref.local, place_ref.projection, context, location);
215+
self.visit_place_base(&place_ref.local, context, location);
216+
self.visit_projection(&place_ref.local, place_ref.projection, context, location);
217217
}
218218
}
219219
}

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11111111
} else {
11121112
self.codegen_place(
11131113
bx,
1114-
mir::PlaceRef { local: &dest.local, projection: &dest.projection },
1114+
mir::PlaceRef { local: dest.local, projection: &dest.projection },
11151115
)
11161116
};
11171117
if fn_ret.is_indirect() {

src/librustc_codegen_ssa/mir/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
373373
) -> Option<OperandRef<'tcx, Bx::Value>> {
374374
debug!("maybe_codegen_consume_direct(place_ref={:?})", place_ref);
375375

376-
match self.locals[*place_ref.local] {
376+
match self.locals[place_ref.local] {
377377
LocalRef::Operand(Some(mut o)) => {
378378
// Moves out of scalar and scalar pair fields are trivial.
379379
for elem in place_ref.projection.iter() {

src/librustc_codegen_ssa/mir/place.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
415415
let tcx = self.cx.tcx();
416416

417417
let result = match place_ref {
418-
mir::PlaceRef { local, projection: [] } => match self.locals[*local] {
418+
mir::PlaceRef { local, projection: [] } => match self.locals[local] {
419419
LocalRef::Place(place) => {
420420
return place;
421421
}
@@ -499,7 +499,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
499499

500500
pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'_, 'tcx>) -> Ty<'tcx> {
501501
let tcx = self.cx.tcx();
502-
let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx);
502+
let place_ty = mir::Place::ty_from(&place_ref.local, place_ref.projection, *self.mir, tcx);
503503
self.monomorphize(&place_ty.ty)
504504
}
505505
}

src/librustc_mir/borrow_check/constraint_generation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
199199
all_facts,
200200
self.borrow_set,
201201
self.location_table,
202-
*local,
202+
local,
203203
location,
204204
);
205205
}
@@ -212,7 +212,7 @@ impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
212212
local, location
213213
);
214214

215-
if let Some(borrow_indices) = self.borrow_set.local_map.get(local) {
215+
if let Some(borrow_indices) = self.borrow_set.local_map.get(&local) {
216216
for &borrow_index in borrow_indices {
217217
let places_conflict = places_conflict::places_conflict(
218218
self.infcx.tcx,

src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
186186
}
187187

188188
let ty =
189-
Place::ty_from(used_place.local, used_place.projection, *self.body, self.infcx.tcx)
189+
Place::ty_from(&used_place.local, used_place.projection, *self.body, self.infcx.tcx)
190190
.ty;
191191
let needs_note = match ty.kind {
192192
ty::Closure(id, _) => {
@@ -605,7 +605,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
605605

606606
match elem {
607607
ProjectionElem::Field(field, _) if union_ty(local, proj_base).is_some() => {
608-
return Some((PlaceRef { local, projection: proj_base }, field));
608+
return Some((PlaceRef { local: *local, projection: proj_base }, field));
609609
}
610610
_ => {}
611611
}
@@ -624,12 +624,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
624624
if let ProjectionElem::Field(field, _) = elem {
625625
if let Some(union_ty) = union_ty(local, proj_base) {
626626
if field != target_field
627-
&& local == target_base.local
627+
&& *local == target_base.local
628628
&& proj_base == target_base.projection
629629
{
630630
// FIXME when we avoid clone reuse describe_place closure
631631
let describe_base_place = self
632-
.describe_place(PlaceRef { local, projection: proj_base })
632+
.describe_place(PlaceRef { local: *local, projection: proj_base })
633633
.unwrap_or_else(|| "_".to_owned());
634634

635635
return Some((
@@ -686,7 +686,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
686686
let borrow_span = borrow_spans.var_or_use();
687687

688688
assert!(root_place.projection.is_empty());
689-
let proper_span = self.body.local_decls[*root_place.local].source_info.span;
689+
let proper_span = self.body.local_decls[root_place.local].source_info.span;
690690

691691
let root_place_projection = self.infcx.tcx.intern_place_elems(root_place.projection);
692692

@@ -1139,7 +1139,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11391139
let root_place =
11401140
self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All).last().unwrap();
11411141
let local = root_place.local;
1142-
match self.body.local_kind(*local) {
1142+
match self.body.local_kind(local) {
11431143
LocalKind::ReturnPointer | LocalKind::Temp => {
11441144
("temporary value".to_string(), "temporary value created here".to_string())
11451145
}

src/librustc_mir/borrow_check/diagnostics/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
169169
) -> Result<(), ()> {
170170
match place {
171171
PlaceRef { local, projection: [] } => {
172-
self.append_local_to_string(*local, buf)?;
172+
self.append_local_to_string(local, buf)?;
173173
}
174174
PlaceRef { local, projection: [ProjectionElem::Deref] }
175-
if self.body.local_decls[*local].is_ref_for_guard() =>
175+
if self.body.local_decls[local].is_ref_for_guard() =>
176176
{
177177
self.append_place_to_string(
178178
PlaceRef { local: local, projection: &[] },
@@ -182,9 +182,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
182182
)?;
183183
}
184184
PlaceRef { local, projection: [ProjectionElem::Deref] }
185-
if self.body.local_decls[*local].is_ref_to_static() =>
185+
if self.body.local_decls[local].is_ref_to_static() =>
186186
{
187-
let local_info = &self.body.local_decls[*local].local_info;
187+
let local_info = &self.body.local_decls[local].local_info;
188188
if let LocalInfo::StaticRef { def_id, .. } = *local_info {
189189
buf.push_str(&self.infcx.tcx.item_name(def_id).as_str());
190190
} else {
@@ -307,7 +307,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
307307
// FIXME Place2 Make this work iteratively
308308
match place {
309309
PlaceRef { local, projection: [] } => {
310-
let local = &self.body.local_decls[*local];
310+
let local = &self.body.local_decls[local];
311311
self.describe_field_from_ty(&local.ty, field, None)
312312
}
313313
PlaceRef { local, projection: [proj_base @ .., elem] } => match elem {
@@ -316,7 +316,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
316316
}
317317
ProjectionElem::Downcast(_, variant_index) => {
318318
let base_ty =
319-
Place::ty_from(place.local, place.projection, *self.body, self.infcx.tcx)
319+
Place::ty_from(&place.local, place.projection, *self.body, self.infcx.tcx)
320320
.ty;
321321
self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
322322
}
@@ -447,7 +447,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
447447

448448
// If we didn't find an overloaded deref or index, then assume it's a
449449
// built in deref and check the type of the base.
450-
let base_ty = Place::ty_from(deref_base.local, deref_base.projection, *self.body, tcx).ty;
450+
let base_ty = Place::ty_from(&deref_base.local, deref_base.projection, *self.body, tcx).ty;
451451
if base_ty.is_unsafe_ptr() {
452452
BorrowedContentSource::DerefRawPointer
453453
} else if base_ty.is_mutable_ptr() {

src/librustc_mir/borrow_check/diagnostics/move_errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
275275
format!("static item `{}`", self.describe_place(place.as_ref()).unwrap())
276276
} else {
277277
let base_static =
278-
PlaceRef { local: &place.local, projection: &[ProjectionElem::Deref] };
278+
PlaceRef { local: place.local, projection: &[ProjectionElem::Deref] };
279279

280280
format!(
281281
"`{:?}` as `{:?}` is a static item",
@@ -304,17 +304,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
304304

305305
let deref_base = match deref_target_place.projection.as_ref() {
306306
&[ref proj_base @ .., ProjectionElem::Deref] => {
307-
PlaceRef { local: &deref_target_place.local, projection: &proj_base }
307+
PlaceRef { local: deref_target_place.local, projection: &proj_base }
308308
}
309309
_ => bug!("deref_target_place is not a deref projection"),
310310
};
311311

312312
if let PlaceRef { local, projection: [] } = deref_base {
313-
let decl = &self.body.local_decls[*local];
313+
let decl = &self.body.local_decls[local];
314314
if decl.is_ref_for_guard() {
315315
let mut err = self.cannot_move_out_of(
316316
span,
317-
&format!("`{}` in pattern guard", self.local_names[*local].unwrap()),
317+
&format!("`{}` in pattern guard", self.local_names[local].unwrap()),
318318
);
319319
err.note(
320320
"variables bound in patterns cannot be moved from \

0 commit comments

Comments
 (0)