diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-12-01 17:52:10 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-13 20:15:39 -0500 |
| commit | f0b65674c3ecc7b9501dfd3484c5dabb572017d4 (patch) | |
| tree | 1963dc5eed7cebb8c3d4449d7023ab0081e7a7c5 /src | |
| parent | 971add88d820ef84d02f2dab306b07ff09491c84 (diff) | |
| download | rust-f0b65674c3ecc7b9501dfd3484c5dabb572017d4.tar.gz rust-f0b65674c3ecc7b9501dfd3484c5dabb572017d4.zip | |
Fix compile-fail tests
Diffstat (limited to 'src')
3 files changed, 19 insertions, 18 deletions
diff --git a/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs index 4a6c20079c1..692303fc1e4 100644 --- a/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs +++ b/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs @@ -9,18 +9,19 @@ // except according to those terms. +#[deriving(Clone)] struct foo(Box<uint>); impl Add<foo, foo> for foo { - fn add(&self, f: &foo) -> foo { - let foo(box i) = *self; - let foo(box j) = *f; + fn add(self, f: foo) -> foo { + let foo(box i) = self; + let foo(box j) = f; foo(box() (i + j)) } } fn main() { let x = foo(box 3); - let _y = x + {x}; // the `{x}` forces a move to occur - //~^ ERROR cannot move out of `x` + let _y = {x} + x.clone(); // the `{x}` forces a move to occur + //~^ ERROR use of moved value: `x` } diff --git a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs index c5d7b6fa451..b83e1544c96 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - +#[deriving(Copy)] struct Point { x: int, y: int, } -impl Add<int,int> for Point { - fn add(&self, z: &int) -> int { - self.x + self.y + (*z) +impl Add<int, int> for Point { + fn add(self, z: int) -> int { + self.x + self.y + z } } @@ -41,7 +41,7 @@ fn b() { let q = &mut p; - p + 3; //~ ERROR cannot borrow `p` + p + 3; //~ ERROR cannot use `p` p.times(3); //~ ERROR cannot borrow `p` *q + 3; // OK to use the new alias `q` diff --git a/src/test/compile-fail/wrong-mul-method-signature.rs b/src/test/compile-fail/wrong-mul-method-signature.rs index aead739d3e0..b5e4cac7555 100644 --- a/src/test/compile-fail/wrong-mul-method-signature.rs +++ b/src/test/compile-fail/wrong-mul-method-signature.rs @@ -17,12 +17,12 @@ struct Vec1 { x: f64 } -// Expecting ref in input signature +// Expecting value in input signature impl Mul<f64, Vec1> for Vec1 { - fn mul(&self, s: f64) -> Vec1 { - //~^ ERROR: method `mul` has an incompatible type for trait: expected &-ptr, found f64 + fn mul(self, s: &f64) -> Vec1 { + //~^ ERROR: method `mul` has an incompatible type for trait: expected f64, found &-ptr Vec1 { - x: self.x * s + x: self.x * *s } } } @@ -34,8 +34,8 @@ struct Vec2 { // Wrong type parameter ordering impl Mul<Vec2, f64> for Vec2 { - fn mul(&self, s: f64) -> Vec2 { - //~^ ERROR: method `mul` has an incompatible type for trait: expected &-ptr, found f64 + fn mul(self, s: f64) -> Vec2 { + //~^ ERROR: method `mul` has an incompatible type for trait: expected struct Vec2, found f64 Vec2 { x: self.x * s, y: self.y * s @@ -51,9 +51,9 @@ struct Vec3 { // Unexpected return type impl Mul<f64, i32> for Vec3 { - fn mul(&self, s: &f64) -> f64 { + fn mul(self, s: f64) -> f64 { //~^ ERROR: method `mul` has an incompatible type for trait: expected i32, found f64 - *s + s } } |
