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.
Rollup merge of rust-lang#126294 - Zalathar:spans-refiner, r=oli-obk coverage: Replace the old span refiner with a single function As more and more of the span refiner's functionality has been pulled out into separate early passes, it has finally reached the point where we can remove the rest of the old `SpansRefiner` code, and replace it with a single modestly-sized function. ~~There should be no change to the resulting coverage mappings, as demonstrated by the lack of changes to test output.~~ There is *almost* no change to the resulting coverage mappings. There are some minor changes to `loop` that on inspection appear to be neutral in terms of accuracy, with the old behaviour being a slightly-horrifying implementation detail of the old code, so I think they're acceptable. Previous work in this direction includes: - rust-lang#125921 - rust-lang#121019 - rust-lang#119208
- Loading branch information
Showing
8 changed files
with
136 additions
and
204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Function name: assert_ne::main | ||
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 08, 01, 03, 1c, 05, 04, 0d, 00, 13, 02, 02, 0d, 00, 13, 09, 03, 05, 01, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 1 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
Number of file 0 mappings: 4 | ||
- Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28) | ||
- Code(Counter(1)) at (prev + 4, 13) to (start + 0, 19) | ||
- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 19) | ||
= (c0 - c1) | ||
- Code(Counter(2)) at (prev + 3, 5) to (start + 1, 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,23 @@ | ||
LL| |//@ edition: 2021 | ||
LL| | | ||
LL| |use core::hint::black_box; | ||
LL| | | ||
LL| |#[derive(Debug, PartialEq)] | ||
LL| |struct Foo(u32); | ||
LL| | | ||
LL| 1|fn main() { | ||
LL| 1| assert_ne!( | ||
LL| 1| Foo(5), // Make sure this expression's span isn't lost. | ||
LL| 1| if black_box(false) { | ||
LL| 0| Foo(0) // | ||
LL| | } else { | ||
LL| 1| Foo(1) // | ||
LL| | } | ||
LL| | ); | ||
LL| 1| () | ||
LL| 1|} | ||
LL| | | ||
LL| |// This test is a short fragment extracted from `issue-84561.rs`, highlighting | ||
LL| |// a particular span of code that can easily be lost if overlapping spans are | ||
LL| |// processed incorrectly. | ||
|
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 @@ | ||
//@ edition: 2021 | ||
|
||
use core::hint::black_box; | ||
|
||
#[derive(Debug, PartialEq)] | ||
struct Foo(u32); | ||
|
||
fn main() { | ||
assert_ne!( | ||
Foo(5), // Make sure this expression's span isn't lost. | ||
if black_box(false) { | ||
Foo(0) // | ||
} else { | ||
Foo(1) // | ||
} | ||
); | ||
() | ||
} | ||
|
||
// This test is a short fragment extracted from `issue-84561.rs`, highlighting | ||
// a particular span of code that can easily be lost if overlapping spans are | ||
// processed incorrectly. |
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 @@ | ||
Function name: loop_break::main | ||
Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 03, 01, 00, 0b, 03, 02, 0c, 00, 27, 01, 01, 0d, 00, 12, 05, 01, 0a, 00, 0b, 01, 02, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 1 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
Number of file 0 mappings: 5 | ||
- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 11) | ||
- Code(Expression(0, Add)) at (prev + 2, 12) to (start + 0, 39) | ||
= (c0 + c1) | ||
- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 18) | ||
- Code(Counter(1)) at (prev + 1, 10) to (start + 0, 11) | ||
- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 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,14 @@ | ||
LL| |//@ edition: 2021 | ||
LL| | | ||
LL| 1|fn main() { | ||
LL| | loop { | ||
LL| 1| if core::hint::black_box(true) { | ||
LL| 1| break; | ||
LL| 0| } | ||
LL| | } | ||
LL| 1|} | ||
LL| | | ||
LL| |// This test is a lightly-modified version of `tests/mir-opt/coverage/instrument_coverage.rs`. | ||
LL| |// If this test needs to be blessed, then the mir-opt version probably needs to | ||
LL| |// be blessed too! | ||
|
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 @@ | ||
//@ edition: 2021 | ||
|
||
fn main() { | ||
loop { | ||
if core::hint::black_box(true) { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
// This test is a lightly-modified version of `tests/mir-opt/coverage/instrument_coverage.rs`. | ||
// If this test needs to be blessed, then the mir-opt version probably needs to | ||
// be blessed too! |
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