coverage: Unbox and simplify bcb_filtered_successors

This function already has access to the MIR body, so instead of taking a
reference to a terminator, it's simpler and easier to pass in a basic block
index.

There is no need to box the returned iterator if we instead add appropriate
lifetime captures, since `short_circuit_preorder` is now generic over the type
of iterator it expects.

We can also greatly simplify the function's implementation by observing that
the only difference between its two cases is whether we take all of a BB's
successors, or just the first one.
This commit is contained in:
Zalathar 2023-10-10 15:09:04 +11:00
parent f214497d22
commit 5d629457fd
2 changed files with 24 additions and 28 deletions

View file

@ -241,7 +241,7 @@ fn print_coverage_graphviz(
" {:?} [label=\"{:?}: {}\"];\n{}",
bcb,
bcb,
bcb_data.terminator(mir_body).kind.name(),
mir_body[bcb_data.last_bb()].terminator().kind.name(),
basic_coverage_blocks
.successors(bcb)
.map(|successor| { format!(" {:?} -> {:?};", bcb, successor) })