]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/const_let_assign3.rs
Rollup merge of #106951 - tmiasko:rm-simplify-initial, r=oli-obk
[rust.git] / tests / ui / consts / const_let_assign3.rs
1 struct S {
2     state: u32,
3 }
4
5 impl S {
6     const fn foo(&mut self, x: u32) {
7         //~^ ERROR mutable reference
8         self.state = x;
9     }
10 }
11
12 const FOO: S = {
13     let mut s = S { state: 42 };
14     s.foo(3); //~ ERROR mutable reference
15     s
16 };
17
18 type Array = [u32; {
19     let mut x = 2;
20     let y = &mut x; //~ ERROR mutable reference
21     *y = 42;
22     *y
23 }];
24
25 fn main() {
26     assert_eq!(FOO.state, 3);
27 }