Use new Place::is_indirect API where possible
This commit is contained in:
parent
86487329bb
commit
96ac02b8b3
2 changed files with 11 additions and 29 deletions
|
|
@ -3,7 +3,7 @@ use crate::borrow_check::places_conflict;
|
|||
use crate::borrow_check::AccessDepth;
|
||||
use crate::dataflow::indexes::BorrowIndex;
|
||||
use rustc::mir::{BasicBlock, Location, Body, Place, PlaceBase};
|
||||
use rustc::mir::{ProjectionElem, BorrowKind};
|
||||
use rustc::mir::BorrowKind;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc_data_structures::graph::dominators::Dominators;
|
||||
|
||||
|
|
@ -133,20 +133,11 @@ pub(super) fn is_active<'tcx>(
|
|||
/// Determines if a given borrow is borrowing local data
|
||||
/// This is called for all Yield statements on movable generators
|
||||
pub(super) fn borrow_of_local_data(place: &Place<'_>) -> bool {
|
||||
place.iterate(|place_base, place_projection| {
|
||||
match place_base {
|
||||
PlaceBase::Static(..) => return false,
|
||||
PlaceBase::Local(..) => {},
|
||||
}
|
||||
match place.base {
|
||||
PlaceBase::Static(_) => false,
|
||||
|
||||
for proj in place_projection {
|
||||
// Reborrow of already borrowed data is ignored
|
||||
// Any errors will be caught on the initial borrow
|
||||
if proj.elem == ProjectionElem::Deref {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
})
|
||||
// Reborrow of already borrowed data is ignored
|
||||
// Any errors will be caught on the initial borrow
|
||||
PlaceBase::Local(_) => !place.is_indirect(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,19 +93,10 @@ struct BorrowedLocalsVisitor<'gk> {
|
|||
}
|
||||
|
||||
fn find_local(place: &Place<'_>) -> Option<Local> {
|
||||
place.iterate(|place_base, place_projection| {
|
||||
for proj in place_projection {
|
||||
if proj.elem == ProjectionElem::Deref {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
if let PlaceBase::Local(local) = place_base {
|
||||
Some(*local)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
match place.base {
|
||||
PlaceBase::Local(local) if !place.is_indirect() => Some(local),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for BorrowedLocalsVisitor<'_> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue