mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-18 03:25:55 +00:00
14 lines
329 B
Rust
14 lines
329 B
Rust
// 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;
|
|
}
|