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.
#[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`
}

View File

@ -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`

View File

@ -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
}
}