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.

28 lines
406 B
Rust
Raw Normal View History

2018-11-19 10:19:14 +00:00
struct S {
state: u32,
}
impl S {
const fn foo(&mut self, x: u32) {
2020-09-29 21:58:00 +00:00
//~^ ERROR mutable reference
2018-11-19 10:19:14 +00:00
self.state = x;
}
}
const FOO: S = {
let mut s = S { state: 42 };
2020-09-29 21:58:00 +00:00
s.foo(3); //~ ERROR mutable reference
2018-11-19 10:19:14 +00:00
s
};
type Array = [u32; {
let mut x = 2;
2020-09-29 21:58:00 +00:00
let y = &mut x; //~ ERROR mutable reference
*y = 42;
*y
}];
2018-11-19 10:19:14 +00:00
fn main() {
assert_eq!(FOO.state, 3);
}