Function rustc_mir_transform::simplify::save_unreachable_coverage [−][src]
fn save_unreachable_coverage(
basic_blocks: &mut IndexVec<BasicBlock, BasicBlockData<'_>>,
first_dead_block: usize
)
Expand description
Some MIR transforms can determine at compile time that a sequences of
statements will never be executed, so they can be dropped from the MIR.
For example, an if
or else
block that is guaranteed to never be executed
because its condition can be evaluated at compile time, such as by const
evaluation: if false { ... }
.
Those statements are bypassed by redirecting paths in the CFG around the
dead blocks
; but with -Z instrument-coverage
, the dead blocks usually
include Coverage
statements representing the Rust source code regions to
be counted at runtime. Without these Coverage
statements, the regions are
lost, and the Rust source code will show no coverage information.
What we want to show in a coverage report is the dead code with coverage
counts of 0
. To do this, we need to save the code regions, by injecting
Unreachable
coverage statements. These are non-executable statements whose
code regions are still recorded in the coverage map, representing regions
with 0
executions.