rust/tests/ui/borrowck/borrowck-move-out-of-static-item.rs

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

18 lines
288 B
Rust
Raw Normal View History

// Ensure that moves out of static items is forbidden
struct Foo {
foo: isize,
}
static BAR: Foo = Foo { foo: 5 };
fn test(f: Foo) {
2024-03-13 00:02:45 +00:00
let f = Foo { foo: 4, ..f };
println!("{}", f.foo);
}
fn main() {
test(BAR); //~ ERROR cannot move out of static item `BAR` [E0507]
}