-
-
Notifications
You must be signed in to change notification settings - Fork 186
Line coverage false negative issue with match in generic functions and multi-line block #1078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have encountered the same issue, as well as similar ones, for which I was able to extract minimal working examples. I have the feeling that Tarpaulin just get very confused with generics. struct S1 { v: Option<i32>, }
fn f1<T>() {
let s = S1 { v: Some(0) };
Box::new(S1 {
v: s
.v
.map(|v| 42),
});
}
#[test]
fn test1() { f1::<()>(); }
struct S2 { u: i32, }
fn f2<T>() {
Box::new(S2 {
u: 0,
});
}
#[test]
fn test2() { f2::<()>(); }
fn f3<T>() {
Some(0)
.map(
|
v
|
42
);
}
#[test]
fn test3() { f3::<()>(); } Note that |
Note we can just use struct S1 { v: Option<i32>, }
fn f1<'a>() {
let s = S1 { v: Some(0) };
Box::new(S1 {
v: s
.v
.map(|v| 42),
});
}
#[test]
fn test1() { f1(); }
struct S2 { u: i32, }
fn f2<'a>() {
Box::new(S2 {
u: 0,
});
}
#[test]
fn test2() { f2(); }
fn f3<'a>() {
Some(0)
.map(
|
v
|
42
);
}
#[test]
fn test3() { f3(); } gets me |
I'm seeing this in my project zirco-lang/zrc as well: The image doesn't show it well, but the two matchers are not covered |
Describe the bug
Tarpaulin doesn't recognise some lines as covered even though they are. In particular, in the example tarpaulin says that line
10
and16
(just those lines, not the whole blocks) are not covered.This does not happen if the match branches are oneline (that is, if instead of
I use
Ok(()) => Ok(())
the line is marked as covered)This does not happen also if the function that wraps the match does not use a generic type: the two functions in the example
do_nothing_generic
anddo_nothing_str
are practically the same, the only exception being that one takes a type that implementsto_string()
while the other takes a&str
, but the bug happens only in the function that takes a generic type.To Reproduce
[./Cargo.toml]
[./src/lib.rs]
On calling
cargo tarpaulin
the output is the followingI'm reproducing this on Linux Mint 20.3, and this is the output of
uname -a
Linux lenovo-ideapad5 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
The version of rustc used is
rustc 1.61.0 (fe5b13d68 2022-05-18)
Expected behavior
The lines
10
,16
should be counted as covered, so the Total Lines forsrc/lib.rs
should be19/19
, and the coverage should be100%
instead of89.47%
The text was updated successfully, but these errors were encountered: