forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#84562 - richkadel:issue-83601, r=tmandry
Adds feature-gated `#[no_coverage]` function attribute, to fix derived Eq `0` coverage issue rust-lang#83601 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). Adding a `no_coverage` feature gate with tracking issue rust-lang#84605. r? `@tmandry` cc: `@wesleywiser`
- Loading branch information
Showing
18 changed files
with
198 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
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|} | ||
|
18 changes: 18 additions & 0 deletions
18
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.no_cov_crate.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,18 @@ | ||
1| |// Enables `no_coverage` on the entire crate | ||
2| |#![feature(no_coverage)] | ||
3| | | ||
4| |#[no_coverage] | ||
5| |fn do_not_add_coverage_1() { | ||
6| | println!("called but not covered"); | ||
7| |} | ||
8| | | ||
9| |#[no_coverage] | ||
10| |fn do_not_add_coverage_2() { | ||
11| | println!("called but not covered"); | ||
12| |} | ||
13| | | ||
14| 1|fn main() { | ||
15| 1| do_not_add_coverage_1(); | ||
16| 1| do_not_add_coverage_2(); | ||
17| 1|} | ||
|
19 changes: 19 additions & 0 deletions
19
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.no_cov_func.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,19 @@ | ||
1| |// Enables `no_coverage` on individual functions | ||
2| | | ||
3| |#[feature(no_coverage)] | ||
4| |#[no_coverage] | ||
5| |fn do_not_add_coverage_1() { | ||
6| | println!("called but not covered"); | ||
7| |} | ||
8| | | ||
9| |#[no_coverage] | ||
10| |#[feature(no_coverage)] | ||
11| |fn do_not_add_coverage_2() { | ||
12| | println!("called but not covered"); | ||
13| |} | ||
14| | | ||
15| 1|fn main() { | ||
16| 1| do_not_add_coverage_1(); | ||
17| 1| do_not_add_coverage_2(); | ||
18| 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,17 @@ | ||
// Enables `no_coverage` on the entire crate | ||
#![feature(no_coverage)] | ||
|
||
#[no_coverage] | ||
fn do_not_add_coverage_1() { | ||
println!("called but not covered"); | ||
} | ||
|
||
#[no_coverage] | ||
fn do_not_add_coverage_2() { | ||
println!("called but not covered"); | ||
} | ||
|
||
fn main() { | ||
do_not_add_coverage_1(); | ||
do_not_add_coverage_2(); | ||
} |
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,18 @@ | ||
// Enables `no_coverage` on individual functions | ||
|
||
#[feature(no_coverage)] | ||
#[no_coverage] | ||
fn do_not_add_coverage_1() { | ||
println!("called but not covered"); | ||
} | ||
|
||
#[no_coverage] | ||
#[feature(no_coverage)] | ||
fn do_not_add_coverage_2() { | ||
println!("called but not covered"); | ||
} | ||
|
||
fn main() { | ||
do_not_add_coverage_1(); | ||
do_not_add_coverage_2(); | ||
} |
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,8 @@ | ||
#![crate_type = "lib"] | ||
|
||
#[no_coverage] | ||
#[feature(no_coverage)] // does not have to be enabled before `#[no_coverage]` | ||
fn no_coverage_is_enabled_on_this_function() {} | ||
|
||
#[no_coverage] //~ ERROR the `#[no_coverage]` attribute is an experimental feature | ||
fn requires_feature_no_coverage() {} |
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,13 @@ | ||
error[E0658]: the `#[no_coverage]` attribute is an experimental feature | ||
--> $DIR/feature-gate-no_coverage.rs:7:1 | ||
| | ||
LL | #[no_coverage] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #84605 <https://github.com/rust-lang/rust/issues/84605> for more information | ||
= help: add `#![feature(no_coverage)]` to the crate attributes to enable | ||
= help: or, alternatively, add `#[feature(no_coverage)]` to the function | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |