Rollup merge of #61093 - spastorino:borrow-of-local-data-iterate, r=oli-obk
Make borrow_of_local_data iterate instead of recurse r? @oli-obk
This commit is contained in:
commit
b4f6e5baeb
|
@ -131,22 +131,20 @@ pub(super) fn is_active<'tcx>(
|
||||||
/// Determines if a given borrow is borrowing local data
|
/// Determines if a given borrow is borrowing local data
|
||||||
/// This is called for all Yield statements on movable generators
|
/// This is called for all Yield statements on movable generators
|
||||||
pub(super) fn borrow_of_local_data<'tcx>(place: &Place<'tcx>) -> bool {
|
pub(super) fn borrow_of_local_data<'tcx>(place: &Place<'tcx>) -> bool {
|
||||||
match place {
|
place.iterate(|place_base, place_projection| {
|
||||||
Place::Base(PlaceBase::Static(..)) => false,
|
match place_base {
|
||||||
Place::Base(PlaceBase::Local(..)) => true,
|
PlaceBase::Static(..) => return false,
|
||||||
Place::Projection(box proj) => {
|
PlaceBase::Local(..) => {},
|
||||||
match proj.elem {
|
}
|
||||||
// Reborrow of already borrowed data is ignored
|
|
||||||
// Any errors will be caught on the initial borrow
|
|
||||||
ProjectionElem::Deref => false,
|
|
||||||
|
|
||||||
// For interior references and downcasts, find out if the base is local
|
for proj in place_projection {
|
||||||
ProjectionElem::Field(..)
|
// Reborrow of already borrowed data is ignored
|
||||||
| ProjectionElem::Index(..)
|
// Any errors will be caught on the initial borrow
|
||||||
| ProjectionElem::ConstantIndex { .. }
|
if proj.elem == ProjectionElem::Deref {
|
||||||
| ProjectionElem::Subslice { .. }
|
return false;
|
||||||
| ProjectionElem::Downcast(..) => borrow_of_local_data(&proj.base),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue