rust/tests/ui/let-else/let-else-binding-explicit-mut-annotated.rs
2023-01-11 09:32:08 +00:00

17 lines
413 B
Rust

// 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;
}