about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/binop-move-semantics.rs4
-rw-r--r--src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs2
-rw-r--r--src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs4
-rw-r--r--src/test/compile-fail/borrowck-move-in-irrefut-pat.rs6
-rw-r--r--src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs2
-rw-r--r--src/test/compile-fail/borrowck-move-out-of-overloaded-deref.rs2
-rw-r--r--src/test/compile-fail/borrowck-move-out-of-vec-tail.rs2
-rw-r--r--src/test/compile-fail/borrowck-overloaded-index-2.rs2
-rw-r--r--src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs47
-rw-r--r--src/test/compile-fail/borrowck-overloaded-index.rs2
-rw-r--r--src/test/compile-fail/dst-index.rs4
-rw-r--r--src/test/compile-fail/dst-rvalue.rs4
-rw-r--r--src/test/compile-fail/issue-12567.rs8
-rw-r--r--src/test/compile-fail/issue-17651.rs2
-rw-r--r--src/test/compile-fail/issue-2590.rs2
-rw-r--r--src/test/compile-fail/method-self-arg-2.rs2
-rw-r--r--src/test/compile-fail/slice-mut-2.rs2
-rw-r--r--src/test/compile-fail/slice-mut.rs2
-rw-r--r--src/test/compile-fail/std-uncopyable-atomics.rs8
-rw-r--r--src/test/compile-fail/unop-move-semantics.rs4
20 files changed, 79 insertions, 32 deletions
diff --git a/src/test/compile-fail/binop-move-semantics.rs b/src/test/compile-fail/binop-move-semantics.rs
index ffc38cc0a60..cff0064497a 100644
--- a/src/test/compile-fail/binop-move-semantics.rs
+++ b/src/test/compile-fail/binop-move-semantics.rs
@@ -37,9 +37,9 @@ fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) {
     let m = &mut x;
     let n = &y;
 
-    *m  //~ ERROR: cannot move out of dereference of `&mut`-pointer
+    *m  //~ ERROR: cannot move out of borrowed content
     +
-    *n;  //~ ERROR: cannot move out of dereference of `&`-pointer
+    *n;  //~ ERROR: cannot move out of borrowed content
 }
 
 struct Foo;
diff --git a/src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs b/src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs
index 84f4e4f8817..794e0fc6e3a 100644
--- a/src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs
+++ b/src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs
@@ -20,5 +20,5 @@ impl A {
 pub fn main() {
     let a = box A;
     a.foo();
-    //~^ ERROR cannot borrow immutable dereference of `Box` `*a` as mutable
+    //~^ ERROR cannot borrow immutable `Box` content `*a` as mutable
 }
diff --git a/src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs b/src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs
index 9aec8de46b6..d5df1251346 100644
--- a/src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs
+++ b/src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs
@@ -33,7 +33,7 @@ fn test1() {
 }
 
 fn test2<F>(f: &F) where F: FnMut() {
-    (*f)(); //~ ERROR: cannot borrow immutable dereference of `&`-pointer `*f` as mutable
+    (*f)(); //~ ERROR: cannot borrow immutable borrowed content `*f` as mutable
 }
 
 fn test3<F>(f: &mut F) where F: FnMut() {
@@ -41,7 +41,7 @@ fn test3<F>(f: &mut F) where F: FnMut() {
 }
 
 fn test4(f: &Test) {
-    f.f.call_mut(()) //~ ERROR: cannot borrow immutable dereference of `Box` `*f.f` as mutable
+    f.f.call_mut(()) //~ ERROR: cannot borrow immutable `Box` content `*f.f` as mutable
 }
 
 fn test5(f: &mut Test) {
diff --git a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs
index c5d23925a89..ec505faf885 100644
--- a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs
+++ b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs
@@ -11,16 +11,16 @@
 fn with<F>(f: F) where F: FnOnce(&String) {}
 
 fn arg_item(&_x: &String) {}
-    //~^ ERROR cannot move out of dereference of `&`-pointer
+    //~^ ERROR cannot move out of borrowed content
 
 fn arg_closure() {
     with(|&_x| ())
-    //~^ ERROR cannot move out of dereference of `&`-pointer
+    //~^ ERROR cannot move out of borrowed content
 }
 
 fn let_pat() {
     let &_x = &"hi".to_string();
-    //~^ ERROR cannot move out of dereference of `&`-pointer
+    //~^ ERROR cannot move out of borrowed content
 }
 
 pub fn main() {}
diff --git a/src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs b/src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs
index a6723a04611..a13efdea562 100644
--- a/src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs
+++ b/src/test/compile-fail/borrowck-move-out-of-overloaded-auto-deref.rs
@@ -12,5 +12,5 @@ use std::rc::Rc;
 
 pub fn main() {
     let _x = Rc::new(vec!(1i, 2)).into_iter();
-    //~^ ERROR cannot move out of dereference of `&`-pointer
+    //~^ ERROR cannot move out of borrowed content
 }
diff --git a/src/test/compile-fail/borrowck-move-out-of-overloaded-deref.rs b/src/test/compile-fail/borrowck-move-out-of-overloaded-deref.rs
index 8a93790d5a2..fffcf575ab0 100644
--- a/src/test/compile-fail/borrowck-move-out-of-overloaded-deref.rs
+++ b/src/test/compile-fail/borrowck-move-out-of-overloaded-deref.rs
@@ -12,5 +12,5 @@ use std::rc::Rc;
 
 pub fn main() {
     let _x = *Rc::new("hi".to_string());
-    //~^ ERROR cannot move out of dereference of `&`-pointer
+    //~^ ERROR cannot move out of borrowed content
 }
diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
index 23ef5331b49..75596af10d7 100644
--- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
+++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
@@ -25,7 +25,7 @@ pub fn main() {
     match x {
         [_, tail..] => {
             match tail {
-                [Foo { string: a }, //~ ERROR cannot move out of dereference of `&`-pointer
+                [Foo { string: a }, //~ ERROR cannot move out of borrowed content
                  Foo { string: b }] => {
                     //~^^ NOTE attempting to move value to here
                     //~^^ NOTE and here
diff --git a/src/test/compile-fail/borrowck-overloaded-index-2.rs b/src/test/compile-fail/borrowck-overloaded-index-2.rs
index 5e6d235574e..334f14349d7 100644
--- a/src/test/compile-fail/borrowck-overloaded-index-2.rs
+++ b/src/test/compile-fail/borrowck-overloaded-index-2.rs
@@ -28,5 +28,5 @@ fn main() {
     let v = MyVec { data: vec!(box 1i, box 2, box 3) };
     let good = &v[0]; // Shouldn't fail here
     let bad = v[0];
-    //~^ ERROR cannot move out of dereference (dereference is implicit, due to indexing)
+    //~^ ERROR cannot move out of indexed content
 }
diff --git a/src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs b/src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs
new file mode 100644
index 00000000000..4188cf00142
--- /dev/null
+++ b/src/test/compile-fail/borrowck-overloaded-index-and-overloaded-deref.rs
@@ -0,0 +1,47 @@
+// Copyright 2015 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.
+
+// Check that we properly record borrows when we are doing an
+// overloaded, autoderef of a value obtained via an overloaded index
+// operator. The accounting of the all the implicit things going on
+// here is rather subtle. Issue #20232.
+
+use std::ops::{Deref, Index};
+
+struct MyVec<T> { x: T }
+
+impl<T> Index<usize> for MyVec<T> {
+    type Output = T;
+    fn index(&self, _: &usize) -> &T {
+        &self.x
+    }
+}
+
+struct MyPtr<T> { x: T }
+
+impl<T> Deref for MyPtr<T> {
+    type Target = T;
+    fn deref(&self) -> &T {
+        &self.x
+    }
+}
+
+struct Foo { f: usize }
+
+fn main() {
+    let mut v = MyVec { x: MyPtr { x: Foo { f: 22 } } };
+    let i = &v[0].f;
+    v = MyVec { x: MyPtr { x: Foo { f: 23 } } };
+    //~^ ERROR cannot assign to `v`
+    read(*i);
+}
+
+fn read(_: usize) { }
+
diff --git a/src/test/compile-fail/borrowck-overloaded-index.rs b/src/test/compile-fail/borrowck-overloaded-index.rs
index 80b68dbf519..f4f4d983e00 100644
--- a/src/test/compile-fail/borrowck-overloaded-index.rs
+++ b/src/test/compile-fail/borrowck-overloaded-index.rs
@@ -66,5 +66,5 @@ fn main() {
         x: 1,
     };
     s[2] = 20;
-    //~^ ERROR cannot assign to immutable dereference (dereference is implicit, due to indexing)
+    //~^ ERROR cannot assign to immutable indexed content
 }
diff --git a/src/test/compile-fail/dst-index.rs b/src/test/compile-fail/dst-index.rs
index e297ecaac23..c64cc13bbe2 100644
--- a/src/test/compile-fail/dst-index.rs
+++ b/src/test/compile-fail/dst-index.rs
@@ -41,9 +41,9 @@ impl Index<uint> for T {
 
 fn main() {
     S[0];
-    //~^ ERROR cannot move out of dereference
+    //~^ ERROR cannot move out of indexed content
     //~^^ ERROR E0161
     T[0];
-    //~^ ERROR cannot move out of dereference
+    //~^ ERROR cannot move out of indexed content
     //~^^ ERROR E0161
 }
diff --git a/src/test/compile-fail/dst-rvalue.rs b/src/test/compile-fail/dst-rvalue.rs
index 74e952364cd..faae0009a93 100644
--- a/src/test/compile-fail/dst-rvalue.rs
+++ b/src/test/compile-fail/dst-rvalue.rs
@@ -15,10 +15,10 @@
 pub fn main() {
     let _x: Box<str> = box *"hello world";
     //~^ ERROR E0161
-    //~^^ ERROR cannot move out of dereference
+    //~^^ ERROR cannot move out of borrowed content
 
     let array: &[int] = &[1, 2, 3];
     let _x: Box<[int]> = box *array;
     //~^ ERROR E0161
-    //~^^ ERROR cannot move out of dereference
+    //~^^ ERROR cannot move out of borrowed content
 }
diff --git a/src/test/compile-fail/issue-12567.rs b/src/test/compile-fail/issue-12567.rs
index 26866cbbc60..d186a83676a 100644
--- a/src/test/compile-fail/issue-12567.rs
+++ b/src/test/compile-fail/issue-12567.rs
@@ -12,11 +12,11 @@ fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) {
     match (l1, l2) {
         ([], []) => println!("both empty"),
         ([], [hd, tl..]) | ([hd, tl..], []) => println!("one empty"),
-        //~^ ERROR: cannot move out of dereference
-        //~^^ ERROR: cannot move out of dereference
+        //~^ ERROR: cannot move out of borrowed content
+        //~^^ ERROR: cannot move out of borrowed content
         ([hd1, tl1..], [hd2, tl2..]) => println!("both nonempty"),
-        //~^ ERROR: cannot move out of dereference
-        //~^^ ERROR: cannot move out of dereference
+        //~^ ERROR: cannot move out of borrowed content
+        //~^^ ERROR: cannot move out of borrowed content
     }
 }
 
diff --git a/src/test/compile-fail/issue-17651.rs b/src/test/compile-fail/issue-17651.rs
index d3678f7d87f..fbecd0487bf 100644
--- a/src/test/compile-fail/issue-17651.rs
+++ b/src/test/compile-fail/issue-17651.rs
@@ -15,6 +15,6 @@
 
 fn main() {
     (|&:| box *[0us].as_slice())();
-    //~^ ERROR cannot move out of dereference
+    //~^ ERROR cannot move out of borrowed content
     //~^^ ERROR cannot move a value of type [usize]
 }
diff --git a/src/test/compile-fail/issue-2590.rs b/src/test/compile-fail/issue-2590.rs
index 79a66e30fdb..07aea4fd633 100644
--- a/src/test/compile-fail/issue-2590.rs
+++ b/src/test/compile-fail/issue-2590.rs
@@ -19,7 +19,7 @@ trait parse {
 
 impl parse for parser {
     fn parse(&self) -> Vec<int> {
-        self.tokens //~ ERROR cannot move out of dereference of `&`-pointer
+        self.tokens //~ ERROR cannot move out of borrowed content
     }
 }
 
diff --git a/src/test/compile-fail/method-self-arg-2.rs b/src/test/compile-fail/method-self-arg-2.rs
index 0ac0851619c..ad255ecd9c0 100644
--- a/src/test/compile-fail/method-self-arg-2.rs
+++ b/src/test/compile-fail/method-self-arg-2.rs
@@ -23,5 +23,5 @@ fn main() {
     Foo::bar(&x); //~ERROR cannot borrow `x`
 
     let x = Foo;
-    Foo::baz(&x); //~ERROR cannot borrow immutable dereference of `&`-pointer as mutable
+    Foo::baz(&x); //~ERROR cannot borrow immutable borrowed content as mutable
 }
diff --git a/src/test/compile-fail/slice-mut-2.rs b/src/test/compile-fail/slice-mut-2.rs
index 12f184d410c..09357d328cd 100644
--- a/src/test/compile-fail/slice-mut-2.rs
+++ b/src/test/compile-fail/slice-mut-2.rs
@@ -14,5 +14,5 @@ fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     // Can't mutably slice an immutable slice
     let slice: &mut [int] = &mut [0, 1];
-    let _ = &mut x[2..4]; //~ERROR cannot borrow immutable dereference of `&`-pointer `*x` as mutabl
+    let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable
 }
diff --git a/src/test/compile-fail/slice-mut.rs b/src/test/compile-fail/slice-mut.rs
index 9bd9a752e4e..f68554b9ec7 100644
--- a/src/test/compile-fail/slice-mut.rs
+++ b/src/test/compile-fail/slice-mut.rs
@@ -13,5 +13,5 @@
 fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     // Immutable slices are not mutable.
-    let y: &mut[_] = &x[2..4]; //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutab
+    let y: &mut[_] = &x[2..4]; //~ ERROR cannot borrow immutable borrowed content as mutable
 }
diff --git a/src/test/compile-fail/std-uncopyable-atomics.rs b/src/test/compile-fail/std-uncopyable-atomics.rs
index 5ebabc2e354..81cf9c1bdcf 100644
--- a/src/test/compile-fail/std-uncopyable-atomics.rs
+++ b/src/test/compile-fail/std-uncopyable-atomics.rs
@@ -16,11 +16,11 @@ use std::ptr;
 
 fn main() {
     let x = ATOMIC_BOOL_INIT;
-    let x = *&x; //~ ERROR: cannot move out of dereference
+    let x = *&x; //~ ERROR: cannot move out of borrowed content
     let x = ATOMIC_INT_INIT;
-    let x = *&x; //~ ERROR: cannot move out of dereference
+    let x = *&x; //~ ERROR: cannot move out of borrowed content
     let x = ATOMIC_UINT_INIT;
-    let x = *&x; //~ ERROR: cannot move out of dereference
+    let x = *&x; //~ ERROR: cannot move out of borrowed content
     let x: AtomicPtr<uint> = AtomicPtr::new(ptr::null_mut());
-    let x = *&x; //~ ERROR: cannot move out of dereference
+    let x = *&x; //~ ERROR: cannot move out of borrowed content
 }
diff --git a/src/test/compile-fail/unop-move-semantics.rs b/src/test/compile-fail/unop-move-semantics.rs
index f8cbdb4e160..94656667598 100644
--- a/src/test/compile-fail/unop-move-semantics.rs
+++ b/src/test/compile-fail/unop-move-semantics.rs
@@ -31,9 +31,9 @@ fn illegal_dereference<T: Not<Output=T>>(mut x: T, y: T) {
     let m = &mut x;
     let n = &y;
 
-    !*m;  //~ ERROR: cannot move out of dereference of `&mut`-pointer
+    !*m;  //~ ERROR: cannot move out of borrowed content
 
-    !*n;  //~ ERROR: cannot move out of dereference of `&`-pointer
+    !*n;  //~ ERROR: cannot move out of borrowed content
 }
 
 fn main() {}