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.
This commit is contained in:
Zalathar 2024-06-11 22:13:40 +10:00
parent 02c7a5921e
commit dc6def3042
3 changed files with 58 additions and 0 deletions

View File

@ -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)

View File

@ -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.

View File

@ -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.