forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: rust-lang#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 rust-lang#84561, and added a coverage test to demonstrate this issue.
- Loading branch information
Showing
13 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -781,6 +781,7 @@ symbols! { | |
no, | ||
no_builtins, | ||
no_core, | ||
no_coverage, | ||
no_crate_inject, | ||
no_debug, | ||
no_default_passes, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.issue-83601.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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|} | ||
|
34 changes: 34 additions & 0 deletions
34
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.issue-84561.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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|} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} |