rust/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
431 B
Rust
Raw Normal View History

2023-08-24 03:41:30 -05:00
// References to by-move bindings in an if-let guard *cannot* be used after the guard.
#![feature(if_let_guard)]
fn main() {
let x: Option<Option<String>> = Some(Some(String::new()));
match x {
Some(mut y) if let Some(ref z) = y => {
//~^ ERROR: cannot move out of `x.0` because it is borrowed
let _z: &String = z;
let _y: Option<String> = y;
}
_ => {}
}
}