A simple test of the -C instrument-coverage feature returns the wrong count (9 instead of 10) of the loop header on line 4 when built with Rust 1.93.0:
main.rs:
fn main(){
let mut sum: u32 = 0;
for i in 1..10 {
sum += i;
}
if false{
println!("This code can't be reached");
}
println!("Sum: {}", sum);
}
Reproducer:
rustc -C instrument-coverage main.rs -o main
LLVM_PROFILE_FILE='testprof.profraw' ./main
llvm-profdata merge -sparse testprof.profraw -o testprof.profdata
llvm-cov show main -instr-profile=testprof.profdata > coverage.out
This test works as expected with 1.92.0.
Meta
$ rustc +1.93.0 --version
rustc 1.93.0 (254b59607 2026-01-19)
A simple test of the
-C instrument-coveragefeature returns the wrong count (9 instead of 10) of the loop header on line 4 when built with Rust 1.93.0:main.rs:
Reproducer:
This test works as expected with 1.92.0.
Meta