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
|
|
|
|
};
|
|
|
|
|
2018-12-30 18:20:53 +00:00
|
|
|
type Array = [u32; {
|
|
|
|
let mut x = 2;
|
2020-09-29 21:58:00 +00:00
|
|
|
let y = &mut x; //~ ERROR mutable reference
|
2018-12-30 18:20:53 +00:00
|
|
|
*y = 42;
|
|
|
|
*y
|
|
|
|
}];
|
2018-12-28 19:05:22 +00:00
|
|
|
|
2018-11-19 10:19:14 +00:00
|
|
|
fn main() {
|
|
|
|
assert_eq!(FOO.state, 3);
|
|
|
|
}
|