mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
mc::cat_deref(_, _, mc::GcPtr) |
mc::cat_deref(_, _, mc::UnsafePtr(..)) |
- mc::cat_upvar(..) |
+ mc::cat_upvar(..) | mc::cat_static_item |
mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => {
bccx.span_err(
cmt0.span,
true
}
- // It seems strange to allow a move out of a static item,
- // but what happens in practice is that you have a
- // reference to a constant with a type that should be
- // moved, like `None::<~int>`. The type of this constant
- // is technically `Option<~int>`, which moves, but we know
- // that the content of static items will never actually
- // contain allocated pointers, so we can just memcpy it.
- // Since static items can never have allocated memory,
- // this is ok. For now anyhow.
- mc::cat_static_item => {
- true
- }
-
mc::cat_rvalue(..) |
mc::cat_local(..) |
mc::cat_arg(..) => {
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Ensure that moves out of static items is forbidden
+
+use std::kinds::marker;
+
+struct Foo {
+ foo: int,
+ nopod: marker::NoPod
+}
+
+static BAR: Foo = Foo{foo: 5, nopod: marker::NoPod};
+
+
+fn test(f: Foo) {
+ let _f = Foo{foo: 4, ..f};
+}
+
+fn main() {
+ test(BAR); //~ ERROR cannot move out of static item
+}
}
fn main() {
- test(BAR);
+ test(BAR); //~ ERROR cannot move out of static item
}
use std::ptr;
fn main() {
- let x = INIT_ATOMIC_FLAG;
+ let x = INIT_ATOMIC_FLAG; //~ ERROR cannot move out of static item
let x = *&x; //~ ERROR: cannot move out of dereference
- let x = INIT_ATOMIC_BOOL;
+ let x = INIT_ATOMIC_BOOL; //~ ERROR cannot move out of static item
let x = *&x; //~ ERROR: cannot move out of dereference
- let x = INIT_ATOMIC_INT;
+ let x = INIT_ATOMIC_INT; //~ ERROR cannot move out of static item
let x = *&x; //~ ERROR: cannot move out of dereference
- let x = INIT_ATOMIC_UINT;
+ let x = INIT_ATOMIC_UINT; //~ ERROR cannot move out of static item
let x = *&x; //~ ERROR: cannot move out of dereference
let x: AtomicPtr<uint> = AtomicPtr::new(ptr::mut_null());
let x = *&x; //~ ERROR: cannot move out of dereference
extern crate issue6919_3;
pub fn main() {
- issue6919_3::D.k;
+ let _ = issue6919_3::D.k;
}