From 270541221f25b761d6aeb0e1900d807755857774 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 21 Oct 2019 20:20:47 -0300 Subject: [PATCH] Move as_local impl to from Place to PlaceRef --- src/librustc/mir/mod.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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<'_> {