2018-11-26 13:08:55 +01:00
|
|
|
#![feature(const_let)]
|
2018-11-19 11:19:14 +01:00
|
|
|
#![feature(const_fn)]
|
|
|
|
|
|
|
|
struct S {
|
|
|
|
state: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
const fn foo(&mut self, x: u32) {
|
|
|
|
self.state = x;
|
2018-11-26 13:08:55 +01:00
|
|
|
//~^ contains unimplemented expression
|
2018-11-19 11:19:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const FOO: S = {
|
|
|
|
let mut s = S { state: 42 };
|
|
|
|
s.foo(3); //~ ERROR references in constants may only refer to immutable values
|
|
|
|
s
|
|
|
|
};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(FOO.state, 3);
|
|
|
|
}
|