mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Convert manual loop into while let
This commit is contained in:
parent
4b4948c2e3
commit
e5defd0102
@ -178,17 +178,7 @@ impl<'a, 'tcx> Postorder<'a, 'tcx> {
|
|||||||
// When we yield `B` and call `traverse_successor`, we push `C` to the stack, but
|
// When we yield `B` and call `traverse_successor`, we push `C` to the stack, but
|
||||||
// since we've already visited `E`, that child isn't added to the stack. The last
|
// since we've already visited `E`, that child isn't added to the stack. The last
|
||||||
// two iterations yield `C` and finally `A` for a final traversal of [E, D, B, C, A]
|
// two iterations yield `C` and finally `A` for a final traversal of [E, D, B, C, A]
|
||||||
loop {
|
while let Some(&mut (_, ref mut iter)) = self.visit_stack.last_mut() && let Some(bb) = iter.next() {
|
||||||
let bb = if let Some(&mut (_, ref mut iter)) = self.visit_stack.last_mut() {
|
|
||||||
if let Some(bb) = iter.next() {
|
|
||||||
bb
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
if self.visited.insert(bb) {
|
if self.visited.insert(bb) {
|
||||||
if let Some(term) = &self.basic_blocks[bb].terminator {
|
if let Some(term) = &self.basic_blocks[bb].terminator {
|
||||||
self.visit_stack.push((bb, term.successors()));
|
self.visit_stack.push((bb, term.successors()));
|
||||||
|
Loading…
Reference in New Issue
Block a user