Skip to content

Commit a5c428b

Browse files
committed
Replace with new Place in mir/borrowck
1 parent 85a87a1 commit a5c428b

File tree

19 files changed

+1066
-1026
lines changed

19 files changed

+1066
-1026
lines changed

src/librustc/mir/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,13 @@ impl<'a, 'tcx> Place<'tcx> {
18261826
elems: tcx.intern_place_elems(&[elem]),
18271827
}
18281828
}
1829+
1830+
pub fn local(local: Local) -> Self {
1831+
Place {
1832+
base: PlaceBase::Local(local),
1833+
elems: Slice::empty(),
1834+
}
1835+
}
18291836
}
18301837

18311838
impl<'tcx> Debug for PlaceBase<'tcx> {

src/librustc/mir/tcx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ impl<'tcx> Place<'tcx> {
146146
let mut place = self;
147147
let mut by_ref = false;
148148

149-
base_place = place.base_place(tcx);
149+
base_place = place.base_place(*tcx);
150150

151151
if let Some(ProjectionElem::Deref) = place.projection() {
152152
place = &base_place;
153153
by_ref = true;
154154
}
155155
if let Some(ProjectionElem::Field(field, _ty)) = place.projection() {
156-
let base_ty = place.base_place(tcx).ty(mir, *tcx).to_ty(*tcx);
156+
let base_ty = place.base_place(*tcx).ty(mir, *tcx).to_ty(*tcx);
157157

158158
if base_ty.is_closure() || base_ty.is_generator()
159159
&& (!(by_ref && !mir.upvar_decls[field.index()].by_ref)) {
@@ -174,7 +174,7 @@ impl<'tcx> Place<'tcx> {
174174
// |-- base_place
175175
pub fn split_projection<'cx, 'gcx>(
176176
&self,
177-
tcx: &TyCtxt<'cx, 'gcx, 'tcx>,
177+
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
178178
) -> Option<(Place<'tcx>, &PlaceElem<'tcx>)> {
179179
// split place_elems
180180
// Base.[a, b, c]
@@ -200,7 +200,7 @@ impl<'tcx> Place<'tcx> {
200200
// ^^-- no projection
201201
pub fn base_place<'cx, 'gcx>(
202202
&self,
203-
tcx: &TyCtxt<'cx, 'gcx, 'tcx>,
203+
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
204204
) -> Place<'tcx> {
205205
match self.split_projection(tcx) {
206206
Some((place, _)) => place,

src/librustc_mir/borrow_check/borrow_set.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use borrow_check::place_ext::PlaceExt;
1212
use dataflow::indexes::BorrowIndex;
1313
use rustc::mir::traversal;
1414
use rustc::mir::visit::{PlaceContext, Visitor};
15-
use rustc::mir::{self, Location, Mir, Place};
15+
use rustc::mir::{self, Location, Mir, Place, PlaceBase};
1616
use rustc::ty::{Region, TyCtxt};
1717
use rustc::util::nodemap::{FxHashMap, FxHashSet};
1818
use rustc_data_structures::indexed_vec::IndexVec;
@@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
177177
self.insert_as_pending_if_two_phase(location, &assigned_place, region, kind, idx);
178178

179179
insert(&mut self.region_map, &region, idx);
180-
if let Some(local) = borrowed_place.root_local() {
180+
if let Some(local) = borrowed_place.root_local(self.tcx) {
181181
insert(&mut self.local_map, &local, idx);
182182
}
183183
}
@@ -202,7 +202,10 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
202202
self.super_place(place, context, location);
203203

204204
// We found a use of some temporary TEMP...
205-
if let Place::Local(temp) = place {
205+
if let Place {
206+
base: PlaceBase::Local(temp),
207+
elems: _,
208+
} = place {
206209
// ... check whether we (earlier) saw a 2-phase borrow like
207210
//
208211
// TMP = &mut place
@@ -254,7 +257,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
254257
}
255258
};
256259
}
257-
258260
None => {}
259261
}
260262
}
@@ -321,7 +323,7 @@ impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> {
321323
// TEMP = &foo
322324
//
323325
// so extract `temp`.
324-
let temp = if let &mir::Place::Local(temp) = assigned_place {
326+
let temp = if let mir::PlaceBase::Local(temp) = assigned_place.base {
325327
temp
326328
} else {
327329
span_bug!(

0 commit comments

Comments
 (0)