Open
Description
The fact that coverage is based on source ranges of function bodies means that an inner functions ranges are being "shadowed" by the outer function. When rendered, the source ranges appear to be covered (by the outer function) even though they are not.
An example from #92695:
pub fn outer(is_true: bool) {
println!("called and covered");
inner_not_covered(is_true);
#[no_coverage]
fn inner_not_covered(is_true: bool) {
if is_true {
println!("called but not covered");
} else {
println!("absolutely not covered");
}
}
}
Pretty printing the coverage report looks like this:
45| 1| pub fn outer(is_true: bool) {
46| 1| println!("called and covered");
47| 1| inner_not_covered(is_true);
48| 1|
49| 1| #[no_coverage]
50| 1| fn inner_not_covered(is_true: bool) {
51| 1| if is_true {
52| 1| println!("called but not covered");
53| 1| } else {
54| 1| println!("absolutely not covered");
55| 1| }
56| 1| }
57| 1| }