diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 96b96d0f27ad1fe0ebe22fa8f3be92da6231b845..87c165266f82daaac8c3a3d8b218eecaef09bee2 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -35,52 +35,52 @@ pub trait Add { #[lang="sub"] pub trait Sub { - pure fn sub(rhs: &RHS) -> Result; + pure fn sub(&self, rhs: &RHS) -> Result; } #[lang="mul"] pub trait Mul { - pure fn mul(rhs: &RHS) -> Result; + pure fn mul(&self, rhs: &RHS) -> Result; } #[lang="div"] pub trait Div { - pure fn div(rhs: &RHS) -> Result; + pure fn div(&self, rhs: &RHS) -> Result; } #[lang="modulo"] pub trait Modulo { - pure fn modulo(rhs: &RHS) -> Result; + pure fn modulo(&self, rhs: &RHS) -> Result; } #[lang="neg"] pub trait Neg { - pure fn neg() -> Result; + pure fn neg(&self) -> Result; } #[lang="bitand"] pub trait BitAnd { - pure fn bitand(rhs: &RHS) -> Result; + pure fn bitand(&self, rhs: &RHS) -> Result; } #[lang="bitor"] pub trait BitOr { - pure fn bitor(rhs: &RHS) -> Result; + pure fn bitor(&self, rhs: &RHS) -> Result; } #[lang="bitxor"] pub trait BitXor { - pure fn bitxor(rhs: &RHS) -> Result; + pure fn bitxor(&self, rhs: &RHS) -> Result; } #[lang="shl"] pub trait Shl { - pure fn shl(rhs: &RHS) -> Result; + pure fn shl(&self, rhs: &RHS) -> Result; } #[lang="shr"] pub trait Shr { - pure fn shr(rhs: &RHS) -> Result; + pure fn shr(&self, rhs: &RHS) -> Result; } #[lang="index"] diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 864619f2759171cabb43a712c1afc8af7b9df0dc..5f27e8665dd4044dd0ae79050f1e859a70fa2dfd 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2041,25 +2041,25 @@ fn remove_copyable(k: Kind) -> Kind { } impl Kind : ops::BitAnd { - pure fn bitand(other: &Kind) -> Kind { + pure fn bitand(&self, other: &Kind) -> Kind { unsafe { - lower_kind(self, (*other)) + lower_kind(*self, *other) } } } impl Kind : ops::BitOr { - pure fn bitor(other: &Kind) -> Kind { + pure fn bitor(&self, other: &Kind) -> Kind { unsafe { - raise_kind(self, (*other)) + raise_kind(*self, *other) } } } impl Kind : ops::Sub { - pure fn sub(other: &Kind) -> Kind { + pure fn sub(&self, other: &Kind) -> Kind { unsafe { - kind_(*self & !*(*other)) + kind_(**self & !**other) } } } @@ -2309,7 +2309,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind { // arbitrary threshold to prevent by-value copying of big records if kind_is_safe_for_default_mode(result) { if type_size(cx, ty) > 4 { - result -= kind_(KIND_MASK_DEFAULT_MODE); + result = result - kind_(KIND_MASK_DEFAULT_MODE); } } diff --git a/src/test/auxiliary/trait_inheritance_overloading_xc.rs b/src/test/auxiliary/trait_inheritance_overloading_xc.rs index 1608a332fe5a84b961cc1cb05b0e711d3b2fa1f3..235a174c838f0b1d3f67444b807f82b7e3e0be5d 100644 --- a/src/test/auxiliary/trait_inheritance_overloading_xc.rs +++ b/src/test/auxiliary/trait_inheritance_overloading_xc.rs @@ -3,7 +3,7 @@ pub trait MyNum : Add, Sub, Mul { pub impl int : MyNum { pure fn add(other: &int) -> int { self + *other } - pure fn sub(other: &int) -> int { self - *other } - pure fn mul(other: &int) -> int { self * *other } + pure fn sub(&self, other: &int) -> int { *self - *other } + pure fn mul(&self, other: &int) -> int { *self * *other } } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index b30e04a4ca7dbd75192a7acb141a58affc9d2707..67054d3b04383afa1dfd2e6d91ba58bdb7c31671 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -24,7 +24,7 @@ struct cmplx { } impl cmplx : ops::Mul { - pure fn mul(x: &cmplx) -> cmplx { + pure fn mul(&self, x: &cmplx) -> cmplx { cmplx { re: self.re*(*x).re - self.im*(*x).im, im: self.re*(*x).im + self.im*(*x).re diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index a89e21bc04b4816d001105423b0bbdf9db760f35..91d4a13a82981f9a44bf92dcebf719c2174ef745 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -13,13 +13,13 @@ impl Point : ops::Add { } impl Point : ops::Sub { - pure fn sub(other: &Point) -> Point { + pure fn sub(&self, other: &Point) -> Point { Point {x: self.x - (*other).x, y: self.y - (*other).y} } } impl Point : ops::Neg { - pure fn neg() -> Point { + pure fn neg(&self) -> Point { Point {x: -self.x, y: -self.y} } } @@ -40,7 +40,7 @@ impl Point : cmp::Eq { fn main() { let mut p = Point {x: 10, y: 20}; p += Point {x: 101, y: 102}; - p -= Point {x: 100, y: 100}; + p = p - Point {x: 100, y: 100}; assert p + Point {x: 5, y: 5} == Point {x: 16, y: 27}; assert -p == Point {x: -11, y: -22}; assert p[true] == 11; diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index 4014cd2c623870fdbe97b0580f27913ee163cc60..f8bf9faa186f616c4b400952a570894dd5846ee8 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -3,8 +3,8 @@ trait MyNum : Add, Sub, Mul { impl int : MyNum { pure fn add(other: &int) -> int { self + *other } - pure fn sub(other: &int) -> int { self - *other } - pure fn mul(other: &int) -> int { self * *other } + pure fn sub(&self, other: &int) -> int { *self - *other } + pure fn mul(&self, other: &int) -> int { *self * *other } } fn f(x: T, y: T) -> (T, T, T) {