Rollup merge of #61103 - spastorino:find-iterate, r=oli-obk
Make find iterate instead of recurse r? @oli-obk
This commit is contained in:
commit
dd33e8a84a
1 changed files with 14 additions and 13 deletions
|
@ -241,21 +241,22 @@ impl MovePathLookup {
|
||||||
// unknown place, but will rather return the nearest available
|
// unknown place, but will rather return the nearest available
|
||||||
// parent.
|
// parent.
|
||||||
pub fn find(&self, place: &Place<'tcx>) -> LookupResult {
|
pub fn find(&self, place: &Place<'tcx>) -> LookupResult {
|
||||||
match *place {
|
place.iterate(|place_base, place_projection| {
|
||||||
Place::Base(PlaceBase::Local(local)) => LookupResult::Exact(self.locals[local]),
|
let mut result = match place_base {
|
||||||
Place::Base(PlaceBase::Static(..)) => LookupResult::Parent(None),
|
PlaceBase::Local(local) => self.locals[*local],
|
||||||
Place::Projection(ref proj) => {
|
PlaceBase::Static(..) => return LookupResult::Parent(None),
|
||||||
match self.find(&proj.base) {
|
};
|
||||||
LookupResult::Exact(base_path) => {
|
|
||||||
match self.projections.get(&(base_path, proj.elem.lift())) {
|
for proj in place_projection {
|
||||||
Some(&subpath) => LookupResult::Exact(subpath),
|
if let Some(&subpath) = self.projections.get(&(result, proj.elem.lift())) {
|
||||||
None => LookupResult::Parent(Some(base_path))
|
result = subpath;
|
||||||
}
|
} else {
|
||||||
}
|
return LookupResult::Parent(Some(result));
|
||||||
inexact => inexact
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
LookupResult::Exact(result)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_local(&self, local: Local) -> MovePathIndex {
|
pub fn find_local(&self, local: Local) -> MovePathIndex {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue