Add Place::base_local method and improve doc for Place::local to clarify why we need the former.
This commit is contained in:
parent
5ea8eb55cd
commit
44a2f681a9
1 changed files with 13 additions and 1 deletions
|
|
@ -1967,7 +1967,10 @@ impl<'tcx> Place<'tcx> {
|
|||
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) |
|
||||
|
|
@ -1978,6 +1981,15 @@ impl<'tcx> Place<'tcx> {
|
|||
_ => 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> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue