Derived Eq no longer shows uncovered
The Eq trait has a special hidden function. MIR `InstrumentCoverage` would add this function to the coverage map, but it is never called, so the `Eq` trait would always appear uncovered. Fixes: #83601 The fix required creating a new function attribute `no_coverage` to mark functions that should be ignored by `InstrumentCoverage` and the coverage `mapgen` (during codegen). While testing, I also noticed two other issues: * spanview debug file output ICEd on a function with no body. The workaround for this is included in this PR. * `assert_*!()` macro coverage can appear covered if followed by another `assert_*!()` macro. Normally they appear uncovered. I submitted a new Issue #84561, and added a coverage test to demonstrate this issue.
This commit is contained in:
parent
1919b3f227
commit
888d0b4c96
13 changed files with 119 additions and 2 deletions
|
|
@ -0,0 +1,22 @@
|
|||
1| |// Shows that rust-lang/rust/83601 is resolved
|
||||
2| |
|
||||
3| 3|#[derive(Debug, PartialEq, Eq)]
|
||||
^2
|
||||
------------------
|
||||
| <issue_83601::Foo as core::cmp::PartialEq>::eq:
|
||||
| 3| 2|#[derive(Debug, PartialEq, Eq)]
|
||||
------------------
|
||||
| Unexecuted instantiation: <issue_83601::Foo as core::cmp::PartialEq>::ne
|
||||
------------------
|
||||
4| |struct Foo(u32);
|
||||
5| |
|
||||
6| 1|fn main() {
|
||||
7| 1| let bar = Foo(1);
|
||||
8| 0| assert_eq!(bar, Foo(1));
|
||||
9| 1| let baz = Foo(0);
|
||||
10| 0| assert_ne!(baz, Foo(1));
|
||||
11| 1| println!("{:?}", Foo(1));
|
||||
12| 1| println!("{:?}", bar);
|
||||
13| 1| println!("{:?}", baz);
|
||||
14| 1|}
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
1| |// FIXME(#84561): function-like macros produce unintuitive coverage results.
|
||||
2| |// This test demonstrates some of the problems.
|
||||
3| |
|
||||
4| 9|#[derive(Debug, PartialEq, Eq)]
|
||||
^5
|
||||
------------------
|
||||
| <issue_84561::Foo as core::cmp::PartialEq>::eq:
|
||||
| 4| 9|#[derive(Debug, PartialEq, Eq)]
|
||||
------------------
|
||||
| Unexecuted instantiation: <issue_84561::Foo as core::cmp::PartialEq>::ne
|
||||
------------------
|
||||
5| |struct Foo(u32);
|
||||
6| |
|
||||
7| 1|fn main() {
|
||||
8| 1| let bar = Foo(1);
|
||||
9| 0| assert_eq!(bar, Foo(1));
|
||||
10| 1| let baz = Foo(0);
|
||||
11| 0| assert_ne!(baz, Foo(1));
|
||||
12| 1| println!("{:?}", Foo(1));
|
||||
13| 1| println!("{:?}", bar);
|
||||
14| 1| println!("{:?}", baz);
|
||||
15| |
|
||||
16| 1| assert_eq!(Foo(1), Foo(1));
|
||||
17| 1| assert_ne!(Foo(0), Foo(1));
|
||||
18| 0| assert_eq!(Foo(2), Foo(2));
|
||||
19| 1| let bar = Foo(1);
|
||||
20| 1| assert_ne!(Foo(0), Foo(3));
|
||||
21| 1| assert_ne!(Foo(0), Foo(4));
|
||||
22| 1| assert_eq!(Foo(3), Foo(3));
|
||||
23| 0| assert_ne!(Foo(0), Foo(5));
|
||||
24| 1| println!("{:?}", bar);
|
||||
25| 1| println!("{:?}", Foo(1));
|
||||
26| 1|}
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
2| |// structure of this test.
|
||||
3| |
|
||||
4| 2|#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
^0 ^0 ^0 ^0 ^1 ^1 ^0^0
|
||||
^0 ^0 ^0 ^1 ^1 ^0^0
|
||||
------------------
|
||||
| Unexecuted instantiation: <partial_eq::Version as core::cmp::PartialEq>::ne
|
||||
------------------
|
||||
|
|
|
|||
14
src/test/run-make-fulldeps/coverage/issue-83601.rs
Normal file
14
src/test/run-make-fulldeps/coverage/issue-83601.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Shows that rust-lang/rust/83601 is resolved
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct Foo(u32);
|
||||
|
||||
fn main() {
|
||||
let bar = Foo(1);
|
||||
assert_eq!(bar, Foo(1));
|
||||
let baz = Foo(0);
|
||||
assert_ne!(baz, Foo(1));
|
||||
println!("{:?}", Foo(1));
|
||||
println!("{:?}", bar);
|
||||
println!("{:?}", baz);
|
||||
}
|
||||
26
src/test/run-make-fulldeps/coverage/issue-84561.rs
Normal file
26
src/test/run-make-fulldeps/coverage/issue-84561.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// FIXME(#84561): function-like macros produce unintuitive coverage results.
|
||||
// This test demonstrates some of the problems.
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct Foo(u32);
|
||||
|
||||
fn main() {
|
||||
let bar = Foo(1);
|
||||
assert_eq!(bar, Foo(1));
|
||||
let baz = Foo(0);
|
||||
assert_ne!(baz, Foo(1));
|
||||
println!("{:?}", Foo(1));
|
||||
println!("{:?}", bar);
|
||||
println!("{:?}", baz);
|
||||
|
||||
assert_eq!(Foo(1), Foo(1));
|
||||
assert_ne!(Foo(0), Foo(1));
|
||||
assert_eq!(Foo(2), Foo(2));
|
||||
let bar = Foo(1);
|
||||
assert_ne!(Foo(0), Foo(3));
|
||||
assert_ne!(Foo(0), Foo(4));
|
||||
assert_eq!(Foo(3), Foo(3));
|
||||
assert_ne!(Foo(0), Foo(5));
|
||||
println!("{:?}", bar);
|
||||
println!("{:?}", Foo(1));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue