Move as_local impl to from Place to PlaceRef
This commit is contained in:
parent
0b5ee56da8
commit
270541221f
1 changed files with 10 additions and 4 deletions
|
|
@ -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<'_> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue