Fix compile-fail tests

This commit is contained in:
Jorge Aparicio 2014-12-01 17:52:10 -05:00
parent 971add88d8
commit f0b65674c3
3 changed files with 19 additions and 18 deletions

View file

@ -9,18 +9,19 @@
// except according to those terms. // except according to those terms.
#[deriving(Clone)]
struct foo(Box<uint>); struct foo(Box<uint>);
impl Add<foo, foo> for foo { impl Add<foo, foo> for foo {
fn add(&self, f: &foo) -> foo { fn add(self, f: foo) -> foo {
let foo(box i) = *self; let foo(box i) = self;
let foo(box j) = *f; let foo(box j) = f;
foo(box() (i + j)) foo(box() (i + j))
} }
} }
fn main() { fn main() {
let x = foo(box 3); let x = foo(box 3);
let _y = x + {x}; // the `{x}` forces a move to occur let _y = {x} + x.clone(); // the `{x}` forces a move to occur
//~^ ERROR cannot move out of `x` //~^ ERROR use of moved value: `x`
} }

View file

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[deriving(Copy)]
struct Point { struct Point {
x: int, x: int,
y: int, y: int,
} }
impl Add<int,int> for Point { impl Add<int, int> for Point {
fn add(&self, z: &int) -> int { fn add(self, z: int) -> int {
self.x + self.y + (*z) self.x + self.y + z
} }
} }
@ -41,7 +41,7 @@ fn b() {
let q = &mut p; let q = &mut p;
p + 3; //~ ERROR cannot borrow `p` p + 3; //~ ERROR cannot use `p`
p.times(3); //~ ERROR cannot borrow `p` p.times(3); //~ ERROR cannot borrow `p`
*q + 3; // OK to use the new alias `q` *q + 3; // OK to use the new alias `q`

View file

@ -17,12 +17,12 @@ struct Vec1 {
x: f64 x: f64
} }
// Expecting ref in input signature // Expecting value in input signature
impl Mul<f64, Vec1> for Vec1 { impl Mul<f64, Vec1> for Vec1 {
fn mul(&self, s: f64) -> Vec1 { fn mul(self, s: &f64) -> Vec1 {
//~^ ERROR: method `mul` has an incompatible type for trait: expected &-ptr, found f64 //~^ ERROR: method `mul` has an incompatible type for trait: expected f64, found &-ptr
Vec1 { Vec1 {
x: self.x * s x: self.x * *s
} }
} }
} }
@ -34,8 +34,8 @@ struct Vec2 {
// Wrong type parameter ordering // Wrong type parameter ordering
impl Mul<Vec2, f64> for Vec2 { impl Mul<Vec2, f64> for Vec2 {
fn mul(&self, s: f64) -> Vec2 { fn mul(self, s: f64) -> Vec2 {
//~^ ERROR: method `mul` has an incompatible type for trait: expected &-ptr, found f64 //~^ ERROR: method `mul` has an incompatible type for trait: expected struct Vec2, found f64
Vec2 { Vec2 {
x: self.x * s, x: self.x * s,
y: self.y * s y: self.y * s
@ -51,9 +51,9 @@ struct Vec3 {
// Unexpected return type // Unexpected return type
impl Mul<f64, i32> for Vec3 { 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 //~^ ERROR: method `mul` has an incompatible type for trait: expected i32, found f64
*s s
} }
} }