2014-02-18 15:19:44 +01:00
|
|
|
// Ensure that moves out of static items is forbidden
|
|
|
|
|
|
|
|
struct Foo {
|
2015-01-08 21:54:35 +11:00
|
|
|
foo: isize,
|
2014-02-18 15:19:44 +01:00
|
|
|
}
|
|
|
|
|
2015-08-11 17:27:05 -07:00
|
|
|
static BAR: Foo = Foo { foo: 5 };
|
2014-02-18 15:19:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
fn test(f: Foo) {
|
2024-03-13 00:02:45 +00:00
|
|
|
let f = Foo { foo: 4, ..f };
|
|
|
|
println!("{}", f.foo);
|
2014-02-18 15:19:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-05-05 12:02:32 +01:00
|
|
|
test(BAR); //~ ERROR cannot move out of static item `BAR` [E0507]
|
2014-02-18 15:19:44 +01:00
|
|
|
}
|