summaryrefslogtreecommitdiffstats
path: root/tests/ui/let-else/let-else-binding-explicit-mut-annotated.rs
blob: 955f33ee134d2735b1f90ba428246c65b5d995e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// from rfc2005 test suite



// Verify the binding mode shifts - only when no `&` are auto-dereferenced is the
// final default binding mode mutable.

fn main() {
    let Some(n): &mut Option<i32> = &&Some(5i32) else { return }; //~ ERROR mismatched types
    *n += 1;
    let _ = n;

    let Some(n): &mut Option<i32> = &&mut Some(5i32) else { return }; //~ ERROR mismatched types
    *n += 1;
    let _ = n;
}