Implement base_local iteratively
This commit is contained in:
parent
9f7b953a7e
commit
49f0141374
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user