diff options
| author | SparrowLii <liyuan179@huawei.com> | 2022-05-17 08:41:01 +0800 |
|---|---|---|
| committer | SparrowLii <liyuan179@huawei.com> | 2022-05-17 08:41:01 +0800 |
| commit | 38bf1158bd850c80de42599c28602ae11727a133 (patch) | |
| tree | a125d76abf6c8a63bb7060c0f1e200a8264b0c6f /compiler/rustc_mir_transform/src/coverage/graph.rs | |
| parent | 56d540e0571ac1b0633ce10644224c495aaf42a0 (diff) | |
| download | rust-38bf1158bd850c80de42599c28602ae11727a133.tar.gz rust-38bf1158bd850c80de42599c28602ae11727a133.zip | |
Change `Successors` to `impl Iterator<Item = BasicBlock>`
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/graph.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/graph.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 6bb7e676e85..47190fa0d1a 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -484,17 +484,17 @@ fn bcb_filtered_successors<'a, 'tcx>( body: &'tcx &'a mir::Body<'tcx>, term_kind: &'tcx TerminatorKind<'tcx>, ) -> Box<dyn Iterator<Item = BasicBlock> + 'a> { - let mut successors = term_kind.successors(); Box::new( match &term_kind { // SwitchInt successors are never unwind, and all of them should be traversed. - TerminatorKind::SwitchInt { .. } => successors, + TerminatorKind::SwitchInt { ref targets, .. } => { + None.into_iter().chain(targets.all_targets().into_iter().copied()) + } // For all other kinds, return only the first successor, if any, and ignore unwinds. // NOTE: `chain(&[])` is required to coerce the `option::iter` (from // `next().into_iter()`) into the `mir::Successors` aliased type. - _ => successors.next().into_iter().chain(&[]), + _ => term_kind.successors().next().into_iter().chain((&[]).into_iter().copied()), } - .copied() .filter(move |&successor| body[successor].terminator().kind != TerminatorKind::Unreachable), ) } |
