Skip to content

Commit 2705412

Browse files
committed
Move as_local impl to from Place to PlaceRef
1 parent 0b5ee56 commit 2705412

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/librustc/mir/mod.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1924,10 +1924,7 @@ impl<'tcx> Place<'tcx> {
19241924
/// If this place represents a local variable like `_X` with no
19251925
/// projections, return `Some(_X)`.
19261926
pub fn as_local(&self) -> Option<Local> {
1927-
match self {
1928-
Place { projection: box [], base: PlaceBase::Local(l) } => Some(*l),
1929-
_ => None,
1930-
}
1927+
self.as_ref().as_local()
19311928
}
19321929

19331930
pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> {
@@ -1971,6 +1968,15 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
19711968
_ => None,
19721969
}
19731970
}
1971+
1972+
/// If this place represents a local variable like `_X` with no
1973+
/// projections, return `Some(_X)`.
1974+
pub fn as_local(&self) -> Option<Local> {
1975+
match self {
1976+
PlaceRef { base: PlaceBase::Local(l), projection: [] } => Some(*l),
1977+
_ => None,
1978+
}
1979+
}
19741980
}
19751981

19761982
impl Debug for Place<'_> {

0 commit comments

Comments
 (0)