diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 18619d407728..ecda524db9ae 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -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 { - 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 { + match self { + PlaceRef { base: PlaceBase::Local(l), projection: [] } => Some(*l), + _ => None, + } + } } impl Debug for Place<'_> {