Skip to content

Commit 49f0141

Browse files
committed
Implement base_local iteratively
1 parent 9f7b953 commit 49f0141

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/librustc/mir/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,10 +2055,13 @@ impl<'tcx> Place<'tcx> {
20552055

20562056
/// Finds the innermost `Local` from this `Place`.
20572057
pub fn base_local(&self) -> Option<Local> {
2058-
match self {
2059-
Place::Base(PlaceBase::Local(local)) => Some(*local),
2060-
Place::Projection(box Projection { base, elem: _ }) => base.base_local(),
2061-
Place::Base(PlaceBase::Static(..)) => None,
2058+
let mut place = self;
2059+
loop {
2060+
match place {
2061+
Place::Projection(proj) => place = &proj.base,
2062+
Place::Base(PlaceBase::Static(_)) => return None,
2063+
Place::Base(PlaceBase::Local(local)) => return Some(*local),
2064+
}
20622065
}
20632066
}
20642067

0 commit comments

Comments
 (0)