Rollup merge of #149394 - Aditya-PS-05:test-issue-146445-guard-patterns-liveness, r=Kivooeo

add regression test for guard patterns liveness ICE

closes rust-lang/rust#146445
This commit is contained in:
Stuart Cook 2025-11-28 15:30:45 +11:00 committed by GitHub
commit 28fae11eba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,21 @@
//@ check-pass
//! Regression test for issue #146445.
//!
//! This test ensures that liveness linting works correctly with guard patterns
//! and doesn't cause an ICE ("no successor") when using variables without
//! underscore prefixes in guard expressions.
//!
//! Fixed by #142390 which moved liveness analysis to MIR.
#![feature(guard_patterns)]
#![expect(incomplete_features)]
fn main() {
// This used to ICE before liveness analysis was moved to MIR.
// The variable `main` (without underscore prefix) would trigger
// liveness linting which wasn't properly implemented for guard patterns.
match (0,) {
(_ if { let main = false; main },) => {}
_ => {}
}
}