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

21 lines
358 B
Rust
Raw Normal View History

// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
// Ensure that moves out of static items is forbidden
struct Foo {
foo: isize,
}
static BAR: Foo = Foo { foo: 5 };
fn test(f: Foo) {
let _f = Foo{foo: 4, ..f};
}
fn main() {
test(BAR); //[ast]~ ERROR cannot move out of static item [E0507]
//[mir]~^ ERROR [E0507]
}