about summary refs log tree commit diff
path: root/src/test/compile-fail
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-09-16 07:23:18 -0700
committerGitHub <noreply@github.com>2016-09-16 07:23:18 -0700
commitc6673db58d117d5c554559ae51b4ddf0aae3de00 (patch)
treeb6432a16ade737ecfacdf890c1eacaa01a1062d5 /src/test/compile-fail
parent8394685b8385156fc4bc31cfbc693867e276d9d7 (diff)
parent5c5f75223c1f707e70bf3fdd98449338433c41f8 (diff)
downloadrust-c6673db58d117d5c554559ae51b4ddf0aae3de00.tar.gz
rust-c6673db58d117d5c554559ae51b4ddf0aae3de00.zip
Auto merge of #36353 - arielb1:union-drops, r=pnkfelix
a few move-checker improvements

This fixes moves out of unions and prohibits moves out of slices (see the individual commits).

r? @pnkfelix
Diffstat (limited to 'src/test/compile-fail')
-rw-r--r--src/test/compile-fail/borrowck/borrowck-move-out-of-vec-tail.rs2
-rw-r--r--src/test/compile-fail/borrowck/borrowck-vec-pattern-nesting.rs2
-rw-r--r--src/test/compile-fail/issue-12567.rs8
-rw-r--r--src/test/compile-fail/mir-dataflow/uninits-2.rs2
-rw-r--r--src/test/compile-fail/move-out-of-slice-1.rs21
5 files changed, 28 insertions, 7 deletions
diff --git a/src/test/compile-fail/borrowck/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck/borrowck-move-out-of-vec-tail.rs
index f595d9d81cc..51e00a0ad2c 100644
--- a/src/test/compile-fail/borrowck/borrowck-move-out-of-vec-tail.rs
+++ b/src/test/compile-fail/borrowck/borrowck-move-out-of-vec-tail.rs
@@ -28,7 +28,7 @@ pub fn main() {
         [_, ref tail..] => {
             match tail {
                 &[Foo { string: a },
-                //~^ ERROR cannot move out of borrowed content
+                //~^ ERROR cannot move out of type `[Foo]`
                 //~| cannot move out
                 //~| to prevent move
                   Foo { string: b }] => {
diff --git a/src/test/compile-fail/borrowck/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck/borrowck-vec-pattern-nesting.rs
index d89b4100789..ae001e4e34d 100644
--- a/src/test/compile-fail/borrowck/borrowck-vec-pattern-nesting.rs
+++ b/src/test/compile-fail/borrowck/borrowck-vec-pattern-nesting.rs
@@ -40,7 +40,7 @@ fn c() {
     let mut vec = vec!(box 1, box 2, box 3);
     let vec: &mut [Box<isize>] = &mut vec;
     match vec {
-        &mut [_a, //~ ERROR cannot move out of borrowed content
+        &mut [_a, //~ ERROR cannot move out
             //~| cannot move out
             //~| to prevent move
             ..
diff --git a/src/test/compile-fail/issue-12567.rs b/src/test/compile-fail/issue-12567.rs
index 32a6ea4f062..15d9a318d29 100644
--- a/src/test/compile-fail/issue-12567.rs
+++ b/src/test/compile-fail/issue-12567.rs
@@ -15,12 +15,12 @@ fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) {
         (&[], &[]) => println!("both empty"),
         (&[], &[hd, ..]) | (&[hd, ..], &[])
             => println!("one empty"),
-        //~^^ ERROR: cannot move out of borrowed content
-        //~^^^ ERROR: cannot move out of borrowed content
+        //~^^ ERROR: cannot move out of type `[T]`, a non-copy array
+        //~^^^ ERROR: cannot move out of type `[T]`, a non-copy array
         (&[hd1, ..], &[hd2, ..])
             => println!("both nonempty"),
-        //~^^ ERROR: cannot move out of borrowed content
-        //~^^^ ERROR: cannot move out of borrowed content
+        //~^^ ERROR: cannot move out of type `[T]`, a non-copy array
+        //~^^^ ERROR: cannot move out of type `[T]`, a non-copy array
     }
 }
 
diff --git a/src/test/compile-fail/mir-dataflow/uninits-2.rs b/src/test/compile-fail/mir-dataflow/uninits-2.rs
index e0bf4253449..94f812a40a9 100644
--- a/src/test/compile-fail/mir-dataflow/uninits-2.rs
+++ b/src/test/compile-fail/mir-dataflow/uninits-2.rs
@@ -23,7 +23,7 @@ struct S(i32);
 fn foo(x: &mut S) {
     // `x` is initialized here, so maybe-uninit bit is 0.
 
-    unsafe { *rustc_peek(&x) }; //~ ERROR rustc_peek: bit not set
+    unsafe { rustc_peek(&x) }; //~ ERROR rustc_peek: bit not set
 
     ::std::mem::drop(x);
 
diff --git a/src/test/compile-fail/move-out-of-slice-1.rs b/src/test/compile-fail/move-out-of-slice-1.rs
new file mode 100644
index 00000000000..f3efc68701e
--- /dev/null
+++ b/src/test/compile-fail/move-out-of-slice-1.rs
@@ -0,0 +1,21 @@
+// Copyright 2016 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.
+
+#![feature(slice_patterns, box_patterns)]
+
+struct A;
+
+fn main() {
+    let a: Box<[A]> = Box::new([A]);
+    match a {
+        box [a] => {}, //~ ERROR cannot move out of type `[A]`
+        _ => {}
+    }
+}