rust/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs
Matthew Jasper d437a111f5 Give temporaries in if let guards correct scopes
- Make temporaries in if-let guards be the same variable in MIR when
  the guard is duplicated due to or-patterns.
- Change the "destruction scope" for match arms to be the arm scope rather
  than the arm body scope.
- Add tests.
2023-12-21 13:35:56 +00:00

33 lines
579 B
Rust

// Check that temporaries in if-let guards are correctly scoped.
// Regression test for #116079.
// build-pass
// edition:2018
// -Zvalidate-mir
#![feature(if_let_guard)]
static mut A: [i32; 5] = [1, 2, 3, 4, 5];
async fn fun() {
unsafe {
match A {
_ => (),
i if let Some(1) = async { Some(1) }.await => (),
_ => (),
}
}
}
async fn funner() {
unsafe {
match A {
_ => (),
_ | _ if let Some(1) = async { Some(1) }.await => (),
_ => (),
}
}
}
fn main() {}