File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1967,7 +1967,10 @@ impl<'tcx> Place<'tcx> {
1967
1967
Place :: Projection ( Box :: new ( PlaceProjection { base : self , elem } ) )
1968
1968
}
1969
1969
1970
- /// Find the innermost `Local` from this `Place`.
1970
+ /// Find the innermost `Local` from this `Place`, *if* it is either a local itself or
1971
+ /// a single deref of a local.
1972
+ ///
1973
+ /// FIXME: can we safely swap the semantics of `fn base_local` below in here instead?
1971
1974
pub fn local ( & self ) -> Option < Local > {
1972
1975
match self {
1973
1976
Place :: Local ( local) |
@@ -1978,6 +1981,15 @@ impl<'tcx> Place<'tcx> {
1978
1981
_ => None ,
1979
1982
}
1980
1983
}
1984
+
1985
+ /// Find the innermost `Local` from this `Place`.
1986
+ pub fn base_local ( & self ) -> Option < Local > {
1987
+ match self {
1988
+ Place :: Local ( local) => Some ( * local) ,
1989
+ Place :: Projection ( box Projection { base, elem : _ } ) => base. base_local ( ) ,
1990
+ Place :: Promoted ( ..) | Place :: Static ( ..) => None ,
1991
+ }
1992
+ }
1981
1993
}
1982
1994
1983
1995
impl < ' tcx > Debug for Place < ' tcx > {
You can’t perform that action at this time.
0 commit comments