Skip to content

Commit 2e39b9c

Browse files
committed
Make find_local iterate instead of recurse
1 parent 27cc0db commit 2e39b9c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/librustc_mir/dataflow/impls/borrowed_locals.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,19 @@ struct BorrowedLocalsVisitor<'b, 'c: 'b> {
9191
}
9292

9393
fn find_local<'tcx>(place: &Place<'tcx>) -> Option<Local> {
94-
match *place {
95-
Place::Base(PlaceBase::Local(l)) => Some(l),
96-
Place::Base(PlaceBase::Static(..)) => None,
97-
Place::Projection(ref proj) => {
98-
match proj.elem {
99-
ProjectionElem::Deref => None,
100-
_ => find_local(&proj.base)
94+
place.iterate(|place_base, place_projection| {
95+
for proj in place_projection {
96+
if proj.elem == ProjectionElem::Deref {
97+
return None;
10198
}
10299
}
103-
}
100+
101+
if let PlaceBase::Local(local) = place_base {
102+
Some(*local)
103+
} else {
104+
None
105+
}
106+
})
104107
}
105108

106109
impl<'tcx, 'b, 'c> Visitor<'tcx> for BorrowedLocalsVisitor<'b, 'c> {

0 commit comments

Comments
 (0)