From 971add88d820ef84d02f2dab306b07ff09491c84 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 1 Dec 2014 17:33:22 -0500 Subject: [PATCH] Fix run-pass tests --- .../trait_inheritance_overloading_xc.rs | 10 ++++---- src/test/run-pass/bool.rs | 24 +++++++++---------- src/test/run-pass/deriving-zero.rs | 10 ++++---- src/test/run-pass/issue-3743.rs | 2 +- .../run-pass/numeric-method-autoexport.rs | 20 ++++++++-------- src/test/run-pass/operator-multidispatch.rs | 6 ++--- src/test/run-pass/operator-overloading.rs | 10 ++++---- .../overloaded-calls-param-vtables.rs | 2 +- src/test/run-pass/simd-generics.rs | 4 ++-- .../trait-inheritance-overloading-xc-exe.rs | 2 +- .../run-pass/trait-inheritance-overloading.rs | 12 +++++----- 11 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/test/auxiliary/trait_inheritance_overloading_xc.rs b/src/test/auxiliary/trait_inheritance_overloading_xc.rs index 95bdecd7760..61854aba279 100644 --- a/src/test/auxiliary/trait_inheritance_overloading_xc.rs +++ b/src/test/auxiliary/trait_inheritance_overloading_xc.rs @@ -10,24 +10,24 @@ use std::cmp::PartialEq; -pub trait MyNum : Add + Sub + Mul + PartialEq { +pub trait MyNum : Add + Sub + Mul + PartialEq + Clone { } -#[deriving(Show)] +#[deriving(Clone, Show)] pub struct MyInt { pub val: int } impl Add for MyInt { - fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) } + fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) } } impl Sub for MyInt { - fn sub(&self, other: &MyInt) -> MyInt { mi(self.val - other.val) } + fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) } } impl Mul for MyInt { - fn mul(&self, other: &MyInt) -> MyInt { mi(self.val * other.val) } + fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) } } impl PartialEq for MyInt { diff --git a/src/test/run-pass/bool.rs b/src/test/run-pass/bool.rs index 91075633ab8..238d0ecdca7 100644 --- a/src/test/run-pass/bool.rs +++ b/src/test/run-pass/bool.rs @@ -16,30 +16,30 @@ fn main() { assert_eq!(false != true, true); assert_eq!(false.ne(&false), false); - assert_eq!(false.bitand(&false), false); - assert_eq!(true.bitand(&false), false); - assert_eq!(false.bitand(&true), false); - assert_eq!(true.bitand(&true), true); + assert_eq!(false.bitand(false), false); + assert_eq!(true.bitand(false), false); + assert_eq!(false.bitand(true), false); + assert_eq!(true.bitand(true), true); assert_eq!(false & false, false); assert_eq!(true & false, false); assert_eq!(false & true, false); assert_eq!(true & true, true); - assert_eq!(false.bitor(&false), false); - assert_eq!(true.bitor(&false), true); - assert_eq!(false.bitor(&true), true); - assert_eq!(true.bitor(&true), true); + assert_eq!(false.bitor(false), false); + assert_eq!(true.bitor(false), true); + assert_eq!(false.bitor(true), true); + assert_eq!(true.bitor(true), true); assert_eq!(false | false, false); assert_eq!(true | false, true); assert_eq!(false | true, true); assert_eq!(true | true, true); - assert_eq!(false.bitxor(&false), false); - assert_eq!(true.bitxor(&false), true); - assert_eq!(false.bitxor(&true), true); - assert_eq!(true.bitxor(&true), false); + assert_eq!(false.bitxor(false), false); + assert_eq!(true.bitxor(false), true); + assert_eq!(false.bitxor(true), true); + assert_eq!(true.bitxor(true), false); assert_eq!(false ^ false, false); assert_eq!(true ^ false, true); diff --git a/src/test/run-pass/deriving-zero.rs b/src/test/run-pass/deriving-zero.rs index 690d82a4ed2..88f3e5775b7 100644 --- a/src/test/run-pass/deriving-zero.rs +++ b/src/test/run-pass/deriving-zero.rs @@ -15,10 +15,10 @@ use std::num::Zero; struct Vector2(T, T); impl> Add, Vector2> for Vector2 { - fn add(&self, other: &Vector2) -> Vector2 { + fn add(self, other: Vector2) -> Vector2 { match (self, other) { - (&Vector2(ref x0, ref y0), &Vector2(ref x1, ref y1)) => { - Vector2(*x0 + *x1, *y0 + *y1) + (Vector2(x0, y0), Vector2(x1, y1)) => { + Vector2(x0 + x1, y0 + y1) } } } @@ -30,7 +30,7 @@ struct Vector3 { } impl> Add, Vector3> for Vector3 { - fn add(&self, other: &Vector3) -> Vector3 { + fn add(self, other: Vector3) -> Vector3 { Vector3 { x: self.x + other.x, y: self.y + other.y, @@ -47,7 +47,7 @@ struct Matrix3x2 { } impl> Add, Matrix3x2> for Matrix3x2 { - fn add(&self, other: &Matrix3x2) -> Matrix3x2 { + fn add(self, other: Matrix3x2) -> Matrix3x2 { Matrix3x2 { x: self.x + other.x, y: self.y + other.y, diff --git a/src/test/run-pass/issue-3743.rs b/src/test/run-pass/issue-3743.rs index ada3e37c092..80d3d29bc00 100644 --- a/src/test/run-pass/issue-3743.rs +++ b/src/test/run-pass/issue-3743.rs @@ -28,7 +28,7 @@ trait RhsOfVec2Mul { fn mul_vec2_by(&self, lhs: &Vec2) -> Result; } // Vec2's implementation of Mul "from the other side" using the above trait impl> Mul for Vec2 { - fn mul(&self, rhs: &Rhs) -> Res { rhs.mul_vec2_by(self) } + fn mul(self, rhs: Rhs) -> Res { rhs.mul_vec2_by(&self) } } // Implementation of 'f64 as right-hand-side of Vec2::Mul' diff --git a/src/test/run-pass/numeric-method-autoexport.rs b/src/test/run-pass/numeric-method-autoexport.rs index 585ade71fc6..f8184d248ff 100644 --- a/src/test/run-pass/numeric-method-autoexport.rs +++ b/src/test/run-pass/numeric-method-autoexport.rs @@ -18,19 +18,19 @@ pub fn main() { // ints // num - assert_eq!(15i.add(&6), 21); - assert_eq!(15i8.add(&6i8), 21i8); - assert_eq!(15i16.add(&6i16), 21i16); - assert_eq!(15i32.add(&6i32), 21i32); - assert_eq!(15i64.add(&6i64), 21i64); + assert_eq!(15i.add(6), 21); + assert_eq!(15i8.add(6i8), 21i8); + assert_eq!(15i16.add(6i16), 21i16); + assert_eq!(15i32.add(6i32), 21i32); + assert_eq!(15i64.add(6i64), 21i64); // uints // num - assert_eq!(15u.add(&6u), 21u); - assert_eq!(15u8.add(&6u8), 21u8); - assert_eq!(15u16.add(&6u16), 21u16); - assert_eq!(15u32.add(&6u32), 21u32); - assert_eq!(15u64.add(&6u64), 21u64); + assert_eq!(15u.add(6u), 21u); + assert_eq!(15u8.add(6u8), 21u8); + assert_eq!(15u16.add(6u16), 21u16); + assert_eq!(15u32.add(6u32), 21u32); + assert_eq!(15u64.add(6u64), 21u64); // floats // num diff --git a/src/test/run-pass/operator-multidispatch.rs b/src/test/run-pass/operator-multidispatch.rs index fc79e4f0edb..cb3397c00bc 100644 --- a/src/test/run-pass/operator-multidispatch.rs +++ b/src/test/run-pass/operator-multidispatch.rs @@ -20,13 +20,13 @@ struct Point { } impl ops::Add for Point { - fn add(&self, other: &Point) -> Point { - Point {x: self.x + (*other).x, y: self.y + (*other).y} + fn add(self, other: Point) -> Point { + Point {x: self.x + other.x, y: self.y + other.y} } } impl ops::Add for Point { - fn add(&self, &other: &int) -> Point { + fn add(self, other: int) -> Point { Point {x: self.x + other, y: self.y + other} } diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index a896d2b06f7..0f3da6836cb 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -12,21 +12,21 @@ use std::cmp; use std::ops; -#[deriving(Show)] +#[deriving(Copy, Show)] struct Point { x: int, y: int } impl ops::Add for Point { - fn add(&self, other: &Point) -> Point { - Point {x: self.x + (*other).x, y: self.y + (*other).y} + fn add(self, other: Point) -> Point { + Point {x: self.x + other.x, y: self.y + other.y} } } impl ops::Sub for Point { - fn sub(&self, other: &Point) -> Point { - Point {x: self.x - (*other).x, y: self.y - (*other).y} + fn sub(self, other: Point) -> Point { + Point {x: self.x - other.x, y: self.y - other.y} } } diff --git a/src/test/run-pass/overloaded-calls-param-vtables.rs b/src/test/run-pass/overloaded-calls-param-vtables.rs index d0dbee39ae0..2e8ec3916bd 100644 --- a/src/test/run-pass/overloaded-calls-param-vtables.rs +++ b/src/test/run-pass/overloaded-calls-param-vtables.rs @@ -18,7 +18,7 @@ struct G; impl<'a, A: Add> Fn<(A,), int> for G { extern "rust-call" fn call(&self, (arg,): (A,)) -> int { - arg.add(&1) + arg.add(1) } } diff --git a/src/test/run-pass/simd-generics.rs b/src/test/run-pass/simd-generics.rs index 31c29b615fc..42f93a97142 100644 --- a/src/test/run-pass/simd-generics.rs +++ b/src/test/run-pass/simd-generics.rs @@ -22,8 +22,8 @@ fn add>(lhs: T, rhs: T) -> T { } impl ops::Add for f32x4 { - fn add(&self, rhs: &f32x4) -> f32x4 { - *self + *rhs + fn add(self, rhs: f32x4) -> f32x4 { + self + rhs } } diff --git a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs index 7760395bf1c..2a087e5e425 100644 --- a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs +++ b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs @@ -14,7 +14,7 @@ extern crate trait_inheritance_overloading_xc; use trait_inheritance_overloading_xc::{MyNum, MyInt}; fn f(x: T, y: T) -> (T, T, T) { - return (x + y, x - y, x * y); + return (x.clone() + y.clone(), x.clone() - y.clone(), x * y); } fn mi(v: int) -> MyInt { MyInt { val: v } } diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index b13ea7ae0ba..5f8e945cce8 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -10,21 +10,21 @@ use std::cmp::PartialEq; -trait MyNum : Add + Sub + Mul + PartialEq { } +trait MyNum : Add + Sub + Mul + PartialEq + Clone { } -#[deriving(Show)] +#[deriving(Clone, Show)] struct MyInt { val: int } impl Add for MyInt { - fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) } + fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) } } impl Sub for MyInt { - fn sub(&self, other: &MyInt) -> MyInt { mi(self.val - other.val) } + fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) } } impl Mul for MyInt { - fn mul(&self, other: &MyInt) -> MyInt { mi(self.val * other.val) } + fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) } } impl PartialEq for MyInt { @@ -35,7 +35,7 @@ impl PartialEq for MyInt { impl MyNum for MyInt {} fn f(x: T, y: T) -> (T, T, T) { - return (x + y, x - y, x * y); + return (x.clone() + y.clone(), x.clone() - y.clone(), x * y); } fn mi(v: int) -> MyInt { MyInt { val: v } }