Skip to content

Commit 70206f0

Browse files
committed
coverage: Regression test for ICE triggered by self-loops
1 parent b7dcabe commit 70206f0

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

tests/coverage/let_else_loop.cov-map

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Function name: let_else_loop::_if (unused)
2+
Raw bytes (19): 0x[01, 01, 00, 03, 00, 16, 01, 01, 0c, 00, 02, 09, 00, 10, 00, 02, 09, 00, 10]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 0
6+
Number of file 0 mappings: 3
7+
- Code(Zero) at (prev + 22, 1) to (start + 1, 12)
8+
- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
9+
- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
10+
11+
Function name: let_else_loop::_loop_either_way (unused)
12+
Raw bytes (19): 0x[01, 01, 00, 03, 00, 0f, 01, 01, 14, 00, 01, 1c, 00, 23, 00, 01, 05, 00, 0c]
13+
Number of files: 1
14+
- file 0 => global file 1
15+
Number of expressions: 0
16+
Number of file 0 mappings: 3
17+
- Code(Zero) at (prev + 15, 1) to (start + 1, 20)
18+
- Code(Zero) at (prev + 1, 28) to (start + 0, 35)
19+
- Code(Zero) at (prev + 1, 5) to (start + 0, 12)
20+
21+
Function name: let_else_loop::loopy
22+
Raw bytes (19): 0x[01, 01, 00, 03, 01, 09, 01, 01, 14, 00, 01, 1c, 00, 23, 05, 01, 01, 00, 02]
23+
Number of files: 1
24+
- file 0 => global file 1
25+
Number of expressions: 0
26+
Number of file 0 mappings: 3
27+
- Code(Counter(0)) at (prev + 9, 1) to (start + 1, 20)
28+
- Code(Zero) at (prev + 1, 28) to (start + 0, 35)
29+
- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
30+

tests/coverage/let_else_loop.coverage

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
LL| |#![feature(coverage_attribute)]
2+
LL| |//@ edition: 2021
3+
LL| |//@ ignore-test
4+
LL| |// Regression test for <https://github.com/rust-lang/rust/issues/122738>.
5+
LL| |// These code patterns should not trigger an ICE when allocating a physical
6+
LL| |// counter to a node and also one of its in-edges, because that is allowed
7+
LL| |// when the node contains a tight loop to itself.
8+
LL| |
9+
LL| 1|fn loopy(cond: bool) {
10+
LL| 1| let true = cond else { loop {} };
11+
^0
12+
LL| 1|}
13+
LL| |
14+
LL| |// Variant that also has `loop {}` on the success path.
15+
LL| |// This isn't needed to catch the original ICE, but might help detect regressions.
16+
LL| 0|fn _loop_either_way(cond: bool) {
17+
LL| 0| let true = cond else { loop {} };
18+
LL| 0| loop {}
19+
LL| |}
20+
LL| |
21+
LL| |// Variant using regular `if` instead of let-else.
22+
LL| |// This doesn't trigger the original ICE, but might help detect regressions.
23+
LL| 0|fn _if(cond: bool) {
24+
LL| 0| if cond {
25+
LL| 0| loop {}
26+
LL| | } else {
27+
LL| 0| loop {}
28+
LL| | }
29+
LL| |}
30+
LL| |
31+
LL| |#[coverage(off)]
32+
LL| |fn main() {
33+
LL| | loopy(true);
34+
LL| |}
35+

tests/coverage/let_else_loop.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![feature(coverage_attribute)]
2+
//@ edition: 2021
3+
//@ ignore-test
4+
// Regression test for <https://github.com/rust-lang/rust/issues/122738>.
5+
// These code patterns should not trigger an ICE when allocating a physical
6+
// counter to a node and also one of its in-edges, because that is allowed
7+
// when the node contains a tight loop to itself.
8+
9+
fn loopy(cond: bool) {
10+
let true = cond else { loop {} };
11+
}
12+
13+
// Variant that also has `loop {}` on the success path.
14+
// This isn't needed to catch the original ICE, but might help detect regressions.
15+
fn _loop_either_way(cond: bool) {
16+
let true = cond else { loop {} };
17+
loop {}
18+
}
19+
20+
// Variant using regular `if` instead of let-else.
21+
// This doesn't trigger the original ICE, but might help detect regressions.
22+
fn _if(cond: bool) {
23+
if cond {
24+
loop {}
25+
} else {
26+
loop {}
27+
}
28+
}
29+
30+
#[coverage(off)]
31+
fn main() {
32+
loopy(true);
33+
}

0 commit comments

Comments
 (0)