summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.rs
blob: 4efa02f57a6c72a1a03cbac196dc215624b6cb51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Check mutable reference bindings cannot be mutated by an if-let guard.

#![feature(if_let_guard)]

fn main() {
    let mut x: Option<Option<i32>> = Some(Some(6));
    match x {
        Some(ref mut y) if let Some(ref mut z) = *y => {
            //~^ ERROR cannot borrow `y.0` as mutable, as it is immutable for the pattern guard
            let _: &mut i32 = z;
        }
        _ => {}
    }
}