Place::Projection(Box::new(PlaceProjection { base: self, elem }))
}
- /// Find the innermost `Local` from this `Place`.
+ /// Find the innermost `Local` from this `Place`, *if* it is either a local itself or
+ /// a single deref of a local.
+ ///
+ /// FIXME: can we safely swap the semantics of `fn base_local` below in here instead?
pub fn local(&self) -> Option<Local> {
match self {
Place::Local(local) |
_ => None,
}
}
+
+ /// Find the innermost `Local` from this `Place`.
+ pub fn base_local(&self) -> Option<Local> {
+ match self {
+ Place::Local(local) => Some(*local),
+ Place::Projection(box Projection { base, elem: _ }) => base.base_local(),
+ Place::Promoted(..) | Place::Static(..) => None,
+ }
+ }
}
impl<'tcx> Debug for Place<'tcx> {