]> git.lizzy.rs Git - rust.git/blob - tests/ui/let-else/let-else-binding-explicit-mut.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / let-else / let-else-binding-explicit-mut.rs
1 // from rfc2005 test suite
2
3
4
5 // Verify the binding mode shifts - only when no `&` are auto-dereferenced is the
6 // final default binding mode mutable.
7
8 fn main() {
9     let Some(n) = &&Some(5i32) else { return };
10     *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference
11     let _ = n;
12
13     let Some(n) = &mut &Some(5i32) else { return };
14     *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference
15     let _ = n;
16
17     let Some(n) = &&mut Some(5i32) else { return };
18     *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference
19     let _ = n;
20 }