diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-06-16 13:01:41 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-06-16 16:01:43 +1000 |
| commit | dca6b5eeade5f369c4cb021f1f405b453db35870 (patch) | |
| tree | aca42f320ef160f4b4e6e011f05ac819af3fd5f5 | |
| parent | 917b455a872050b90474043f31ef657b338526ba (diff) | |
| download | rust-dca6b5eeade5f369c4cb021f1f405b453db35870.tar.gz rust-dca6b5eeade5f369c4cb021f1f405b453db35870.zip | |
coverage: Flatten some graph code with let-else
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/graph.rs | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 544195a80fc..607cb14f4c3 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -419,26 +419,25 @@ impl<'a> TraverseCoverageGraphWithLoops<'a> { ); while let Some(context) = self.context_stack.last_mut() { - if let Some(bcb) = context.worklist.pop_front() { - if !self.visited.insert(bcb) { - debug!("Already visited: {bcb:?}"); - continue; - } - debug!("Visiting {bcb:?}"); - - if self.backedges[bcb].len() > 0 { - debug!("{bcb:?} is a loop header! Start a new TraversalContext..."); - self.context_stack.push(TraversalContext { - loop_header: Some(bcb), - worklist: VecDeque::new(), - }); - } - self.add_successors_to_worklists(bcb); - return Some(bcb); - } else { - // Strip contexts with empty worklists from the top of the stack + let Some(bcb) = context.worklist.pop_front() else { + // This stack level is exhausted; pop it and try the next one. self.context_stack.pop(); + continue; + }; + + if !self.visited.insert(bcb) { + debug!("Already visited: {bcb:?}"); + continue; + } + debug!("Visiting {bcb:?}"); + + if self.backedges[bcb].len() > 0 { + debug!("{bcb:?} is a loop header! Start a new TraversalContext..."); + self.context_stack + .push(TraversalContext { loop_header: Some(bcb), worklist: VecDeque::new() }); } + self.add_successors_to_worklists(bcb); + return Some(bcb); } None |
