]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const_let_assign3.rs
Rollup merge of #64603 - gilescope:unused-lifetime-warning, r=matthewjasper
[rust.git] / src / test / ui / consts / const_let_assign3.rs
1 #![feature(const_fn)]
2
3 struct S {
4     state: u32,
5 }
6
7 impl S {
8     const fn foo(&mut self, x: u32) {
9         self.state = x;
10         //~^ contains unimplemented expression
11     }
12 }
13
14 const FOO: S = {
15     let mut s = S { state: 42 };
16     s.foo(3); //~ ERROR references in constants may only refer to immutable values
17     s
18 };
19
20 type Array = [u32; {
21     let mut x = 2;
22     let y = &mut x;
23 //~^ ERROR references in constants may only refer to immutable values
24     *y = 42;
25 //~^ ERROR constant contains unimplemented expression type
26     *y
27 }];
28
29 fn main() {
30     assert_eq!(FOO.state, 3);
31 }