summaryrefslogtreecommitdiffstats
path: root/src/test/ui/let-else/let-else-binding-explicit-mut-borrow.rs
blob: 63b35df76aa044e5f632aef4cea4fdc71aad205a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#![feature(let_else)]

// Slightly different from explicit-mut-annotated -- this won't show an error until borrowck.
// Should it show a type error instead?

fn main() {
    let Some(n): &mut Option<i32> = &mut &Some(5i32) else {
        //~^ ERROR cannot borrow data in a `&` reference as mutable
        return
    };
    *n += 1;
    let _ = n;
}