Skip to content

Commit

Permalink
Implement base_local iteratively
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed May 2, 2019
1 parent 9f7b953 commit 49f0141
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/librustc/mir/mod.rs
Expand Up @@ -2055,10 +2055,13 @@ impl<'tcx> Place<'tcx> {

/// Finds the innermost `Local` from this `Place`.
pub fn base_local(&self) -> Option<Local> {
match self {
Place::Base(PlaceBase::Local(local)) => Some(*local),
Place::Projection(box Projection { base, elem: _ }) => base.base_local(),
Place::Base(PlaceBase::Static(..)) => None,
let mut place = self;
loop {
match place {
Place::Projection(proj) => place = &proj.base,
Place::Base(PlaceBase::Static(_)) => return None,
Place::Base(PlaceBase::Local(local)) => return Some(*local),
}
}
}

Expand Down

0 comments on commit 49f0141

Please sign in to comment.