Skip to content

Commit

Permalink
Rollup merge of rust-lang#61094 - spastorino:find-local-iterate, r=ol…
Browse files Browse the repository at this point in the history
…i-obk

Make find_local iterate instead of recurse

r? @oli-obk
  • Loading branch information
Centril authored May 25, 2019
2 parents b4f6e5b + 2e39b9c commit af01552
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/librustc_mir/dataflow/impls/borrowed_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit af01552

Please sign in to comment.