Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
14c0a70
syntax/ast_util: add `is_by_value_binop()`
Dec 1, 2014
c3a6d28
Tell typeck which binops are by value
Dec 1, 2014
f64e52a
Tell trans which binops are by value
Dec 1, 2014
5038f5a
Tell expr_use_visitor which binops are by value
Dec 1, 2014
227435a
Tell regionck which binops are by value
Dec 1, 2014
c73259a
libcore: convert binop traits to by value
Dec 1, 2014
65d3a40
libcore: fix move semantics fallout
Dec 1, 2014
dbc7e17
libcollections: Vec<T> + &[T]
Dec 1, 2014
076e932
libcollections: String + &str
Dec 1, 2014
baf79d4
libcollections: make `EnumSet` binops by value
Dec 1, 2014
32168fa
libstd: convert `BitFlags` binops to by value
Dec 1, 2014
9126a24
libstd: convert `Duration` binops to by value
Dec 1, 2014
b5537fa
libtime: convert `Timespec` binops to by value
Dec 1, 2014
265b89a
libsyntax: convert `BytePos`/`CharPos` binops to by value
Dec 1, 2014
c4fa2a3
libsyntax: convert `LockstepIterSize` binops to by value
Dec 1, 2014
eb71976
librustc: convert `TypeContents` binops to by value
Dec 1, 2014
fb1d4f1
librustdoc: convert `Counts` binops to by value
Dec 1, 2014
2b17083
Test that binops consume their arguments
Dec 1, 2014
971add8
Fix run-pass tests
Dec 1, 2014
f0b6567
Fix compile-fail tests
Dec 1, 2014
a672b27
libcollections: fix unit tests
Dec 1, 2014
1ec5650
libcoretest: fix unit tests
Dec 1, 2014
bc23b8e
libstd: fix unit tests
Dec 1, 2014
d193bf3
libcore: fix doctests
Dec 2, 2014
f4abb12
Address Niko's comments
Dec 3, 2014
949b55e
libcollections: add commutative version of `Vec`/`String` addition
Dec 3, 2014
dff2b39
Test binops move semantics
Dec 3, 2014
3084604
libcollections: convert `TrieSet` binops to by value
Dec 6, 2014
e00e461
libcollections: convert `TreeSet` binops to by value
Dec 13, 2014
89d2061
libcollections: convert `BTreeSet` binops to by value
Dec 13, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix run-pass tests
  • Loading branch information
Jorge Aparicio committed Dec 14, 2014
commit 971add88d820ef84d02f2dab306b07ff09491c84
10 changes: 5 additions & 5 deletions src/test/auxiliary/trait_inheritance_overloading_xc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@

use std::cmp::PartialEq;

pub trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq {
pub trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq + Clone {
}

#[deriving(Show)]
#[deriving(Clone, Show)]
pub struct MyInt {
pub val: int
}

impl Add<MyInt, MyInt> 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<MyInt, MyInt> 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<MyInt, MyInt> 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 {
Expand Down
24 changes: 12 additions & 12 deletions src/test/run-pass/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/test/run-pass/deriving-zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use std::num::Zero;
struct Vector2<T>(T, T);

impl<T: Add<T, T>> Add<Vector2<T>, Vector2<T>> for Vector2<T> {
fn add(&self, other: &Vector2<T>) -> Vector2<T> {
fn add(self, other: Vector2<T>) -> Vector2<T> {
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)
}
}
}
Expand All @@ -30,7 +30,7 @@ struct Vector3<T> {
}

impl<T: Add<T, T>> Add<Vector3<T>, Vector3<T>> for Vector3<T> {
fn add(&self, other: &Vector3<T>) -> Vector3<T> {
fn add(self, other: Vector3<T>) -> Vector3<T> {
Vector3 {
x: self.x + other.x,
y: self.y + other.y,
Expand All @@ -47,7 +47,7 @@ struct Matrix3x2<T> {
}

impl<T: Add<T, T>> Add<Matrix3x2<T>, Matrix3x2<T>> for Matrix3x2<T> {
fn add(&self, other: &Matrix3x2<T>) -> Matrix3x2<T> {
fn add(self, other: Matrix3x2<T>) -> Matrix3x2<T> {
Matrix3x2 {
x: self.x + other.x,
y: self.y + other.y,
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/issue-3743.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait RhsOfVec2Mul<Result> { fn mul_vec2_by(&self, lhs: &Vec2) -> Result; }

// Vec2's implementation of Mul "from the other side" using the above trait
impl<Res, Rhs: RhsOfVec2Mul<Res>> Mul<Rhs,Res> 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'
Expand Down
20 changes: 10 additions & 10 deletions src/test/run-pass/numeric-method-autoexport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/test/run-pass/operator-multidispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ struct Point {
}

impl ops::Add<Point,Point> 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<int,Point> for Point {
fn add(&self, &other: &int) -> Point {
fn add(self, other: int) -> Point {
Point {x: self.x + other,
y: self.y + other}
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/run-pass/operator-overloading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
use std::cmp;
use std::ops;

#[deriving(Show)]
#[deriving(Copy, Show)]
struct Point {
x: int,
y: int
}

impl ops::Add<Point,Point> 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<Point,Point> 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}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/overloaded-calls-param-vtables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct G;

impl<'a, A: Add<int, int>> Fn<(A,), int> for G {
extern "rust-call" fn call(&self, (arg,): (A,)) -> int {
arg.add(&1)
arg.add(1)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/simd-generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ fn add<T: ops::Add<T, T>>(lhs: T, rhs: T) -> T {
}

impl ops::Add<f32x4, f32x4> for f32x4 {
fn add(&self, rhs: &f32x4) -> f32x4 {
*self + *rhs
fn add(self, rhs: f32x4) -> f32x4 {
self + rhs
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/trait-inheritance-overloading-xc-exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern crate trait_inheritance_overloading_xc;
use trait_inheritance_overloading_xc::{MyNum, MyInt};

fn f<T:MyNum>(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 } }
Expand Down
12 changes: 6 additions & 6 deletions src/test/run-pass/trait-inheritance-overloading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@

use std::cmp::PartialEq;

trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq { }
trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq + Clone { }

#[deriving(Show)]
#[deriving(Clone, Show)]
struct MyInt { val: int }

impl Add<MyInt, MyInt> 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<MyInt, MyInt> 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<MyInt, MyInt> 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 {
Expand All @@ -35,7 +35,7 @@ impl PartialEq for MyInt {
impl MyNum for MyInt {}

fn f<T:MyNum>(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 } }
Expand Down