rust/tests/ui/pattern/mut-ref-mut-2021.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1007 B
Rust
Raw Normal View History

2024-03-23 20:04:45 -05:00
//@ edition: 2021
2024-03-26 00:23:26 -05:00
#![allow(incomplete_features)]
#![feature(mut_ref)]
2024-03-23 20:04:45 -05:00
struct Foo(u8);
fn main() {
let Foo(a) = Foo(0);
a = 42; //~ ERROR [E0384]
let Foo(mut a) = Foo(0);
a = 42;
let Foo(ref a) = Foo(0);
a = &42; //~ ERROR [E0384]
let Foo(mut ref a) = Foo(0);
a = &42;
let Foo(ref mut a) = Foo(0);
a = &mut 42; //~ ERROR [E0384]
let Foo(mut ref mut a) = Foo(0);
a = &mut 42;
let Foo(a) = &Foo(0);
a = &42; //~ ERROR [E0384]
let Foo(mut a) = &Foo(0);
a = 42;
let Foo(ref a) = &Foo(0);
a = &42; //~ ERROR [E0384]
let Foo(mut ref a) = &Foo(0);
a = &42;
let Foo(a) = &mut Foo(0);
a = &mut 42; //~ ERROR [E0384]
let Foo(mut a) = &mut Foo(0);
a = 42;
let Foo(ref a) = &mut Foo(0);
a = &42; //~ ERROR [E0384]
let Foo(mut ref a) = &mut Foo(0);
a = &42;
let Foo(ref mut a) = &mut Foo(0);
a = &mut 42; //~ ERROR [E0384]
let Foo(mut ref mut a) = &mut Foo(0);
a = &mut 42;
}