Rollup merge of - spastorino:find-local-iterate, r=oli-obk

Make find_local iterate instead of recurse

r? @oli-obk
This commit is contained in:
Mazdak Farrokhzad 2019-05-25 04:57:34 +02:00 committed by GitHub
commit af015527aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -91,16 +91,19 @@ struct BorrowedLocalsVisitor<'b, 'c: 'b> {
}
fn find_local<'tcx>(place: &Place<'tcx>) -> Option<Local> {
match *place {
Place::Base(PlaceBase::Local(l)) => Some(l),
Place::Base(PlaceBase::Static(..)) => None,
Place::Projection(ref proj) => {
match proj.elem {
ProjectionElem::Deref => None,
_ => find_local(&proj.base)
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
}
})
}
impl<'tcx, 'b, 'c> Visitor<'tcx> for BorrowedLocalsVisitor<'b, 'c> {