Skip to content

Commit 22a4827

Browse files
committed
Place::ty_from takes local by value
1 parent b5b6be0 commit 22a4827

File tree

20 files changed

+47
-47
lines changed

20 files changed

+47
-47
lines changed

src/librustc/mir/tcx.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'tcx> PlaceTy<'tcx> {
114114

115115
impl<'tcx> Place<'tcx> {
116116
pub fn ty_from<D>(
117-
local: &Local,
117+
local: Local,
118118
projection: &[PlaceElem<'tcx>],
119119
local_decls: &D,
120120
tcx: TyCtxt<'tcx>,
@@ -124,7 +124,7 @@ impl<'tcx> Place<'tcx> {
124124
{
125125
projection
126126
.iter()
127-
.fold(PlaceTy::from_ty(local_decls.local_decls()[*local].ty), |place_ty, elem| {
127+
.fold(PlaceTy::from_ty(local_decls.local_decls()[local].ty), |place_ty, elem| {
128128
place_ty.projection_ty(tcx, elem)
129129
})
130130
}
@@ -133,7 +133,7 @@ impl<'tcx> Place<'tcx> {
133133
where
134134
D: HasLocalDecls<'tcx>,
135135
{
136-
Place::ty_from(&self.local, &self.projection, local_decls, tcx)
136+
Place::ty_from(self.local, &self.projection, local_decls, tcx)
137137
}
138138
}
139139

src/librustc_codegen_ssa/mir/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ 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.

src/librustc_codegen_ssa/mir/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/diagnostics/conflict_errors.rs

Lines changed: 5 additions & 5 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, _) => {
@@ -604,7 +604,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
604604
cursor = proj_base;
605605

606606
match elem {
607-
ProjectionElem::Field(field, _) if union_ty(local, proj_base).is_some() => {
607+
ProjectionElem::Field(field, _) if union_ty(*local, proj_base).is_some() => {
608608
return Some((PlaceRef { local: *local, projection: proj_base }, field));
609609
}
610610
_ => {}
@@ -622,7 +622,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
622622
cursor = proj_base;
623623

624624
if let ProjectionElem::Field(field, _) = elem {
625-
if let Some(union_ty) = union_ty(local, proj_base) {
625+
if let Some(union_ty) = union_ty(*local, proj_base) {
626626
if field != target_field
627627
&& *local == target_base.local
628628
&& proj_base == target_base.projection
@@ -1513,7 +1513,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15131513
StorageDeadOrDrop::LocalStorageDead
15141514
| StorageDeadOrDrop::BoxedStorageDead => {
15151515
assert!(
1516-
Place::ty_from(&place.local, proj_base, *self.body, tcx)
1516+
Place::ty_from(place.local, proj_base, *self.body, tcx)
15171517
.ty
15181518
.is_box(),
15191519
"Drop of value behind a reference or raw pointer"
@@ -1523,7 +1523,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15231523
StorageDeadOrDrop::Destructor(_) => base_access,
15241524
},
15251525
ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => {
1526-
let base_ty = Place::ty_from(&place.local, proj_base, *self.body, tcx).ty;
1526+
let base_ty = Place::ty_from(place.local, proj_base, *self.body, tcx).ty;
15271527
match base_ty.kind {
15281528
ty::Adt(def, _) if def.has_dtor(tcx) => {
15291529
// Report the outermost adt with a destructor

src/librustc_mir/borrow_check/diagnostics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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/mutability_errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
5757
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
5858
} => {
5959
debug_assert!(is_closure_or_generator(
60-
Place::ty_from(&local, proj_base, *self.body, self.infcx.tcx).ty
60+
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty
6161
));
6262

6363
item_msg = format!("`{}`", access_place_desc.unwrap());
@@ -101,7 +101,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
101101
debug_assert!(self.body.local_decls[Local::new(1)].ty.is_region_ptr());
102102
debug_assert!(is_closure_or_generator(
103103
Place::ty_from(
104-
&the_place_err.local,
104+
the_place_err.local,
105105
the_place_err.projection,
106106
*self.body,
107107
self.infcx.tcx
@@ -195,7 +195,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
195195

196196
if let Some((span, message)) = annotate_struct_field(
197197
self.infcx.tcx,
198-
Place::ty_from(&local, proj_base, *self.body, self.infcx.tcx).ty,
198+
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty,
199199
field,
200200
) {
201201
err.span_suggestion(
@@ -271,7 +271,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
271271
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
272272
} => {
273273
debug_assert!(is_closure_or_generator(
274-
Place::ty_from(&local, proj_base, *self.body, self.infcx.tcx).ty
274+
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty
275275
));
276276

277277
err.span_label(span, format!("cannot {ACT}", ACT = act));

src/librustc_mir/borrow_check/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16231623
place_span.0.projection
16241624
{
16251625
let place_ty =
1626-
Place::ty_from(&place_span.0.local, base_proj, self.body(), self.infcx.tcx);
1626+
Place::ty_from(place_span.0.local, base_proj, self.body(), self.infcx.tcx);
16271627
if let ty::Array(..) = place_ty.ty.kind {
16281628
let array_place = PlaceRef { local: place_span.0.local, projection: base_proj };
16291629
self.check_if_subslice_element_is_moved(
@@ -1740,7 +1740,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17401740
// assigning to `P.f` requires `P` itself
17411741
// be already initialized
17421742
let tcx = self.infcx.tcx;
1743-
let base_ty = Place::ty_from(&place.local, proj_base, self.body(), tcx).ty;
1743+
let base_ty = Place::ty_from(place.local, proj_base, self.body(), tcx).ty;
17441744
match base_ty.kind {
17451745
ty::Adt(def, _) if def.has_dtor(tcx) => {
17461746
self.check_if_path_or_subpath_is_moved(
@@ -1844,7 +1844,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
18441844
// of the union - we should error in that case.
18451845
let tcx = this.infcx.tcx;
18461846
if let ty::Adt(def, _) =
1847-
Place::ty_from(&base.local, base.projection, this.body(), tcx).ty.kind
1847+
Place::ty_from(base.local, base.projection, this.body(), tcx).ty.kind
18481848
{
18491849
if def.is_union() {
18501850
if this.move_data.path_map[mpi].iter().any(|moi| {
@@ -2058,7 +2058,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
20582058
match elem {
20592059
ProjectionElem::Deref => {
20602060
let base_ty =
2061-
Place::ty_from(&place.local, proj_base, self.body(), self.infcx.tcx).ty;
2061+
Place::ty_from(place.local, proj_base, self.body(), self.infcx.tcx).ty;
20622062

20632063
// Check the kind of deref to decide
20642064
match base_ty.kind {
@@ -2192,7 +2192,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21922192
match place_projection {
21932193
[base @ .., ProjectionElem::Field(field, _ty)] => {
21942194
let tcx = self.infcx.tcx;
2195-
let base_ty = Place::ty_from(&place_ref.local, base, self.body(), tcx).ty;
2195+
let base_ty = Place::ty_from(place_ref.local, base, self.body(), tcx).ty;
21962196

21972197
if (base_ty.is_closure() || base_ty.is_generator())
21982198
&& (!by_ref || self.upvars[field.index()].by_ref)

src/librustc_mir/borrow_check/place_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {
4848
let proj_base = &self.projection[..i];
4949

5050
if *elem == ProjectionElem::Deref {
51-
let ty = Place::ty_from(&self.local, proj_base, body, tcx).ty;
51+
let ty = Place::ty_from(self.local, proj_base, body, tcx).ty;
5252
match ty.kind {
5353
ty::Ref(_, _, hir::Mutability::Not) if i == 0 => {
5454
// For references to thread-local statics, we do need

src/librustc_mir/borrow_check/places_conflict.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ fn place_components_conflict<'tcx>(
208208
// access cares about.
209209

210210
let proj_base = &borrow_place.projection[..access_place.projection.len() + i];
211-
let base_ty = Place::ty_from(&borrow_local, proj_base, body, tcx).ty;
211+
let base_ty = Place::ty_from(borrow_local, proj_base, body, tcx).ty;
212212

213213
match (elem, &base_ty.kind, access) {
214214
(_, _, Shallow(Some(ArtificialField::ArrayLength)))
@@ -329,7 +329,7 @@ fn place_projection_conflict<'tcx>(
329329
debug!("place_element_conflict: DISJOINT-OR-EQ-FIELD");
330330
Overlap::EqualOrDisjoint
331331
} else {
332-
let ty = Place::ty_from(&pi1_local, pi1_proj_base, body, tcx).ty;
332+
let ty = Place::ty_from(pi1_local, pi1_proj_base, body, tcx).ty;
333333
match ty.kind {
334334
ty::Adt(def, _) if def.is_union() => {
335335
// Different fields of a union, we are basically stuck.

src/librustc_mir/borrow_check/prefixes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
120120
// derefs, except we stop at the deref of a shared
121121
// reference.
122122

123-
let ty = Place::ty_from(&cursor.local, proj_base, *self.body, self.tcx).ty;
123+
let ty = Place::ty_from(cursor.local, proj_base, *self.body, self.tcx).ty;
124124
match ty.kind {
125125
ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => {
126126
// don't continue traversing over derefs of raw pointers or shared

0 commit comments

Comments
 (0)