Move as_local impl to from Place to PlaceRef

This commit is contained in:
Santiago Pastorino 2019-10-21 20:20:47 -03:00
parent 0b5ee56da8
commit 270541221f
No known key found for this signature in database
GPG key ID: 88C941CDA1D46432

View file

@ -1924,10 +1924,7 @@ impl<'tcx> Place<'tcx> {
/// If this place represents a local variable like `_X` with no
/// projections, return `Some(_X)`.
pub fn as_local(&self) -> Option<Local> {
match self {
Place { projection: box [], base: PlaceBase::Local(l) } => Some(*l),
_ => None,
}
self.as_ref().as_local()
}
pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> {
@ -1971,6 +1968,15 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
_ => None,
}
}
/// If this place represents a local variable like `_X` with no
/// projections, return `Some(_X)`.
pub fn as_local(&self) -> Option<Local> {
match self {
PlaceRef { base: PlaceBase::Local(l), projection: [] } => Some(*l),
_ => None,
}
}
}
impl Debug for Place<'_> {