Skip to content

Commit 5766076

Browse files
csmoespastorino
authored andcommitted
introduce NeoPlace in borrow_check/borrow_set
1 parent 0d71575 commit 5766076

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/librustc/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,8 +1909,8 @@ pub enum Place<'tcx> {
19091909
/// A new Place repr
19101910
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
19111911
pub struct NeoPlace<'tcx> {
1912-
base: PlaceBase<'tcx>,
1913-
elems: &'tcx List<PlaceElem<'tcx>>,
1912+
pub base: PlaceBase<'tcx>,
1913+
pub elems: &'tcx List<PlaceElem<'tcx>>,
19141914
}
19151915

19161916
impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List<PlaceElem<'tcx>> {}

src/librustc_mir/borrow_check/borrow_set.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,16 @@ impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> {
345345
// TEMP = &foo
346346
//
347347
// so extract `temp`.
348-
let temp = if let &mir::Place::Local(temp) = assigned_place {
349-
temp
350-
} else {
351-
span_bug!(
352-
self.mir.source_info(start_location).span,
353-
"expected 2-phase borrow to assign to a local, not `{:?}`",
354-
assigned_place,
355-
);
348+
let neo_place = self.tcx.as_new_place(assigned_place);
349+
let temp = match neo_place.base {
350+
mir::PlaceBase::Local(temp) if neo_place.has_no_projection() => temp,
351+
_ => {
352+
span_bug!(
353+
self.mir.source_info(start_location).span,
354+
"expected 2-phase borrow to assign to a local, not `{:?}`",
355+
assigned_place,
356+
);
357+
}
356358
};
357359

358360
// Consider the borrow not activated to start. When we find an activation, we'll update

0 commit comments

Comments
 (0)