We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9f7b953 commit 49f0141Copy full SHA for 49f0141
src/librustc/mir/mod.rs
@@ -2055,10 +2055,13 @@ impl<'tcx> Place<'tcx> {
2055
2056
/// Finds the innermost `Local` from this `Place`.
2057
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,
+ let mut place = self;
+ loop {
+ match place {
+ Place::Projection(proj) => place = &proj.base,
2062
+ Place::Base(PlaceBase::Static(_)) => return None,
2063
+ Place::Base(PlaceBase::Local(local)) => return Some(*local),
2064
+ }
2065
}
2066
2067
0 commit comments