Skip to content

Commit 28fae11

Browse files
authored
Rollup merge of rust-lang#149394 - Aditya-PS-05:test-issue-146445-guard-patterns-liveness, r=Kivooeo
add regression test for guard patterns liveness ICE closes rust-lang#146445
2 parents 145c81d + 2425f80 commit 28fae11

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ check-pass
2+
//! Regression test for issue #146445.
3+
//!
4+
//! This test ensures that liveness linting works correctly with guard patterns
5+
//! and doesn't cause an ICE ("no successor") when using variables without
6+
//! underscore prefixes in guard expressions.
7+
//!
8+
//! Fixed by #142390 which moved liveness analysis to MIR.
9+
10+
#![feature(guard_patterns)]
11+
#![expect(incomplete_features)]
12+
13+
fn main() {
14+
// This used to ICE before liveness analysis was moved to MIR.
15+
// The variable `main` (without underscore prefix) would trigger
16+
// liveness linting which wasn't properly implemented for guard patterns.
17+
match (0,) {
18+
(_ if { let main = false; main },) => {}
19+
_ => {}
20+
}
21+
}

0 commit comments

Comments
 (0)