Skip to content

Commit

Permalink
Use and_then instead of while let chain to clarify iter scope
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Sep 28, 2023
1 parent e0abb98 commit 0e0dc59
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<'a, 'tcx> Postorder<'a, 'tcx> {
// When we yield `C` and call `traverse_successor`, we push `B` to the stack, but
// since we've already visited `E`, that child isn't added to the stack. The last
// two iterations yield `B` and finally `A` for a final traversal of [E, D, C, B, A]
while let Some((_, iter)) = self.visit_stack.last_mut() && let Some(bb) = iter.next_back() {
while let Some(bb) = self.visit_stack.last_mut().and_then(|(_, iter)| iter.next_back()) {
if self.visited.insert(bb) {
if let Some(term) = &self.basic_blocks[bb].terminator {
self.visit_stack.push((bb, term.successors()));
Expand Down

0 comments on commit 0e0dc59

Please sign in to comment.