rust/tests/ui/consts/const_let_assign3.rs

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

29 lines
329 B
Rust
Raw Normal View History

2024-08-17 07:19:34 -05:00
//@ check-pass
2018-11-19 04:19:14 -06:00
struct S {
state: u32,
}
impl S {
const fn foo(&mut self, x: u32) {
self.state = x;
}
}
const FOO: S = {
let mut s = S { state: 42 };
2024-08-17 07:19:34 -05:00
s.foo(3);
2018-11-19 04:19:14 -06:00
s
};
type Array = [u32; {
let mut x = 2;
2024-08-17 07:19:34 -05:00
let y = &mut x;
*y = 42;
*y
}];
2018-11-19 04:19:14 -06:00
fn main() {
assert_eq!(FOO.state, 3);
}