Skip to content

Commit 62c8977

Browse files
committed
coverage: Add tests/coverage/assert-ne.rs
This test extracts a fragment of `issue-84561.rs` that has historically proven troublesome when trying to modify how spans are extracted from MIR.
1 parent ebcb862 commit 62c8977

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

tests/coverage/assert-ne.cov-map

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Function name: assert_ne::main
2+
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]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 1
6+
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
7+
Number of file 0 mappings: 4
8+
- Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28)
9+
- Code(Counter(1)) at (prev + 4, 13) to (start + 0, 19)
10+
- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 19)
11+
= (c0 - c1)
12+
- Code(Counter(2)) at (prev + 3, 5) to (start + 1, 2)
13+

tests/coverage/assert-ne.coverage

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
LL| |//@ edition: 2021
2+
LL| |
3+
LL| |use core::hint::black_box;
4+
LL| |
5+
LL| |#[derive(Debug, PartialEq)]
6+
LL| |struct Foo(u32);
7+
LL| |
8+
LL| 1|fn main() {
9+
LL| 1| assert_ne!(
10+
LL| 1| Foo(5), // Make sure this expression's span isn't lost.
11+
LL| 1| if black_box(false) {
12+
LL| 0| Foo(0) //
13+
LL| | } else {
14+
LL| 1| Foo(1) //
15+
LL| | }
16+
LL| | );
17+
LL| 1| ()
18+
LL| 1|}
19+
LL| |
20+
LL| |// This test is a short fragment extracted from `issue-84561.rs`, highlighting
21+
LL| |// a particular span of code that can easily be lost if overlapping spans are
22+
LL| |// processed incorrectly.
23+

tests/coverage/assert-ne.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ edition: 2021
2+
3+
use core::hint::black_box;
4+
5+
#[derive(Debug, PartialEq)]
6+
struct Foo(u32);
7+
8+
fn main() {
9+
assert_ne!(
10+
Foo(5), // Make sure this expression's span isn't lost.
11+
if black_box(false) {
12+
Foo(0) //
13+
} else {
14+
Foo(1) //
15+
}
16+
);
17+
()
18+
}
19+
20+
// This test is a short fragment extracted from `issue-84561.rs`, highlighting
21+
// a particular span of code that can easily be lost if overlapping spans are
22+
// processed incorrectly.

0 commit comments

Comments
 (0)