Skip to content

Commit

Permalink
Make all projection base names be proj_base
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Sep 13, 2019
1 parent 6ffc20f commit 28db2c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions src/librustc_mir/borrow_check/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
} = first_borrowed_place;

for (i, elem) in projection.iter().enumerate().rev() {
let base_proj = &projection[..i];
let proj_base = &projection[..i];

match elem {
ProjectionElem::Field(field, _) if union_ty(base, base_proj).is_some() => {
ProjectionElem::Field(field, _) if union_ty(base, proj_base).is_some() => {
return Some((PlaceRef {
base: base,
projection: base_proj,
projection: proj_base,
}, field));
},
_ => {},
Expand Down Expand Up @@ -1520,26 +1520,26 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
[] => {
StorageDeadOrDrop::LocalStorageDead
}
[base @ .., elem] => {
[proj_base @ .., elem] => {
// FIXME(spastorino) make this iterate
let base_access = self.classify_drop_access_kind(PlaceRef {
base: place.base,
projection: base,
projection: proj_base,
});
match elem {
ProjectionElem::Deref => match base_access {
StorageDeadOrDrop::LocalStorageDead
| StorageDeadOrDrop::BoxedStorageDead => {
assert!(
Place::ty_from(&place.base, base, self.body, tcx).ty.is_box(),
Place::ty_from(&place.base, proj_base, self.body, tcx).ty.is_box(),
"Drop of value behind a reference or raw pointer"
);
StorageDeadOrDrop::BoxedStorageDead
}
StorageDeadOrDrop::Destructor(_) => base_access,
},
ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => {
let base_ty = Place::ty_from(&place.base, base, self.body, tcx).ty;
let base_ty = Place::ty_from(&place.base, proj_base, self.body, tcx).ty;
match base_ty.sty {
ty::Adt(def, _) if def.has_dtor(tcx) => {
// Report the outermost adt with a destructor
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_mir/borrow_check/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {

PlaceRef {
base: _,
projection: [base @ .., ProjectionElem::Deref],
projection: [proj_base @ .., ProjectionElem::Deref],
} => {
if the_place_err.base == &PlaceBase::Local(Local::new(1)) &&
base.is_empty() &&
proj_base.is_empty() &&
!self.upvars.is_empty() {
item_msg = format!("`{}`", access_place_desc.unwrap());
debug_assert!(self.body.local_decls[Local::new(1)].ty.is_region_ptr());
Expand All @@ -106,7 +106,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
", as `Fn` closures cannot mutate their captured variables".to_string()
}
} else if {
if let (PlaceBase::Local(local), []) = (&the_place_err.base, base) {
if let (PlaceBase::Local(local), []) = (&the_place_err.base, proj_base) {
self.body.local_decls[*local].is_ref_for_guard()
} else {
false
Expand All @@ -117,7 +117,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
} else {
let source = self.borrowed_content_source(PlaceRef {
base: the_place_err.base,
projection: base,
projection: proj_base,
});
let pointer_type = source.describe_for_immutable_place();
opt_source = Some(source);
Expand Down Expand Up @@ -240,7 +240,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// after the field access).
PlaceRef {
base,
projection: [base_proj @ ..,
projection: [proj_base @ ..,
ProjectionElem::Deref,
ProjectionElem::Field(field, _),
ProjectionElem::Deref,
Expand All @@ -250,7 +250,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {

if let Some((span, message)) = annotate_struct_field(
self.infcx.tcx,
Place::ty_from(base, base_proj, self.body, self.infcx.tcx).ty,
Place::ty_from(base, proj_base, self.body, self.infcx.tcx).ty,
field,
) {
err.span_suggestion(
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,19 +514,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
Place {
ref base,
projection: box [ref base_proj @ .., ProjectionElem::Field(upvar_index, _)],
projection: box [ref proj_base @ .., ProjectionElem::Field(upvar_index, _)],
}
| Place {
ref base,
projection: box [
ref base_proj @ ..,
ref proj_base @ ..,
ProjectionElem::Field(upvar_index, _),
ProjectionElem::Deref
],
} => {
let place = PlaceRef {
base,
projection: base_proj,
projection: proj_base,
};

// Not projected from the implicit `self` in a closure.
Expand Down

0 comments on commit 28db2c9

Please sign in to comment.