about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/core.rc5
-rw-r--r--src/libcore/num/f32.rs49
-rw-r--r--src/libcore/num/f64.rs49
-rw-r--r--src/libcore/num/float.rs45
-rw-r--r--src/libcore/num/int-template.rs50
-rw-r--r--src/libcore/num/num.rs35
-rw-r--r--src/libcore/num/strconv.rs21
-rw-r--r--src/libcore/num/uint-template.rs50
-rw-r--r--src/libcore/ops.rs16
-rw-r--r--src/libcore/prelude.rs5
10 files changed, 218 insertions, 107 deletions
diff --git a/src/libcore/core.rc b/src/libcore/core.rc
index 81190ea8fc6..fd8813d0c4a 100644
--- a/src/libcore/core.rc
+++ b/src/libcore/core.rc
@@ -75,7 +75,12 @@ they contained the following prologue:
 
 pub use kinds::{Const, Copy, Owned, Durable};
 pub use ops::{Drop};
+#[cfg(stage0)]
 pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
+pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
 pub use ops::{BitAnd, BitOr, BitXor};
 pub use ops::{Shl, Shr, Index};
 
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index 6233f8c2a61..2e7dc98e3c5 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -16,8 +16,13 @@ use option::Option;
 use from_str;
 use to_str;
 
-#[cfg(notest)] use cmp;
-#[cfg(notest)] use ops;
+#[cfg(notest)] use cmp::{Eq, Ord};
+#[cfg(stage0,notest)]
+use ops::{Add, Sub, Mul, Div, Modulo, Neg};
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+use ops::{Add, Sub, Mul, Quot, Rem, Neg};
 
 pub use cmath::c_float_targ_consts::*;
 
@@ -131,7 +136,7 @@ pub fn sub(x: f32, y: f32) -> f32 { return x - y; }
 pub fn mul(x: f32, y: f32) -> f32 { return x * y; }
 
 #[inline(always)]
-pub fn div(x: f32, y: f32) -> f32 { return x / y; }
+pub fn quot(x: f32, y: f32) -> f32 { return x / y; }
 
 #[inline(always)]
 pub fn rem(x: f32, y: f32) -> f32 { return x % y; }
@@ -265,7 +270,7 @@ pub fn logarithm(n: f32, b: f32) -> f32 {
 }
 
 #[cfg(notest)]
-impl cmp::Eq for f32 {
+impl Eq for f32 {
     #[inline(always)]
     fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
     #[inline(always)]
@@ -273,7 +278,7 @@ impl cmp::Eq for f32 {
 }
 
 #[cfg(notest)]
-impl cmp::Ord for f32 {
+impl Ord for f32 {
     #[inline(always)]
     fn lt(&self, other: &f32) -> bool { (*self) < (*other) }
     #[inline(always)]
@@ -295,33 +300,41 @@ impl num::One for f32 {
 }
 
 #[cfg(notest)]
-impl ops::Add<f32,f32> for f32 {
-    #[inline(always)]
+impl Add<f32,f32> for f32 {
     fn add(&self, other: &f32) -> f32 { *self + *other }
 }
 #[cfg(notest)]
-impl ops::Sub<f32,f32> for f32 {
-    #[inline(always)]
+impl Sub<f32,f32> for f32 {
     fn sub(&self, other: &f32) -> f32 { *self - *other }
 }
 #[cfg(notest)]
-impl ops::Mul<f32,f32> for f32 {
-    #[inline(always)]
+impl Mul<f32,f32> for f32 {
     fn mul(&self, other: &f32) -> f32 { *self * *other }
 }
-#[cfg(notest)]
-impl ops::Div<f32,f32> for f32 {
-    #[inline(always)]
+#[cfg(stage0,notest)]
+impl Div<f32,f32> for f32 {
     fn div(&self, other: &f32) -> f32 { *self / *other }
 }
-#[cfg(notest)]
-impl ops::Modulo<f32,f32> for f32 {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Quot<f32,f32> for f32 {
     #[inline(always)]
+    fn quot(&self, other: &f32) -> f32 { *self / *other }
+}
+#[cfg(stage0,notest)]
+impl Modulo<f32,f32> for f32 {
     fn modulo(&self, other: &f32) -> f32 { *self % *other }
 }
-#[cfg(notest)]
-impl ops::Neg<f32> for f32 {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Rem<f32,f32> for f32 {
     #[inline(always)]
+    fn rem(&self, other: &f32) -> f32 { *self % *other }
+}
+#[cfg(notest)]
+impl Neg<f32> for f32 {
     fn neg(&self) -> f32 { -*self }
 }
 
diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs
index 7f32893f5bf..4762c395a25 100644
--- a/src/libcore/num/f64.rs
+++ b/src/libcore/num/f64.rs
@@ -16,8 +16,13 @@ use option::Option;
 use to_str;
 use from_str;
 
-#[cfg(notest)] use cmp;
-#[cfg(notest)] use ops;
+#[cfg(notest)] use cmp::{Eq, Ord};
+#[cfg(stage0,notest)]
+use ops::{Add, Sub, Mul, Div, Modulo, Neg};
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+use ops::{Add, Sub, Mul, Quot, Rem, Neg};
 
 pub use cmath::c_double_targ_consts::*;
 pub use cmp::{min, max};
@@ -155,7 +160,7 @@ pub fn sub(x: f64, y: f64) -> f64 { return x - y; }
 pub fn mul(x: f64, y: f64) -> f64 { return x * y; }
 
 #[inline(always)]
-pub fn div(x: f64, y: f64) -> f64 { return x / y; }
+pub fn quot(x: f64, y: f64) -> f64 { return x / y; }
 
 #[inline(always)]
 pub fn rem(x: f64, y: f64) -> f64 { return x % y; }
@@ -284,7 +289,7 @@ pub fn logarithm(n: f64, b: f64) -> f64 {
 }
 
 #[cfg(notest)]
-impl cmp::Eq for f64 {
+impl Eq for f64 {
     #[inline(always)]
     fn eq(&self, other: &f64) -> bool { (*self) == (*other) }
     #[inline(always)]
@@ -292,7 +297,7 @@ impl cmp::Eq for f64 {
 }
 
 #[cfg(notest)]
-impl cmp::Ord for f64 {
+impl Ord for f64 {
     #[inline(always)]
     fn lt(&self, other: &f64) -> bool { (*self) < (*other) }
     #[inline(always)]
@@ -314,33 +319,41 @@ impl num::One for f64 {
 }
 
 #[cfg(notest)]
-impl ops::Add<f64,f64> for f64 {
-    #[inline(always)]
+impl Add<f64,f64> for f64 {
     fn add(&self, other: &f64) -> f64 { *self + *other }
 }
 #[cfg(notest)]
-impl ops::Sub<f64,f64> for f64 {
-    #[inline(always)]
+impl Sub<f64,f64> for f64 {
     fn sub(&self, other: &f64) -> f64 { *self - *other }
 }
 #[cfg(notest)]
-impl ops::Mul<f64,f64> for f64 {
-    #[inline(always)]
+impl Mul<f64,f64> for f64 {
     fn mul(&self, other: &f64) -> f64 { *self * *other }
 }
-#[cfg(notest)]
-impl ops::Div<f64,f64> for f64 {
-    #[inline(always)]
+#[cfg(stage0,notest)]
+impl Div<f64,f64> for f64 {
     fn div(&self, other: &f64) -> f64 { *self / *other }
 }
-#[cfg(notest)]
-impl ops::Modulo<f64,f64> for f64 {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Quot<f64,f64> for f64 {
     #[inline(always)]
+    fn quot(&self, other: &f64) -> f64 { *self / *other }
+}
+#[cfg(stage0,notest)]
+impl Modulo<f64,f64> for f64 {
     fn modulo(&self, other: &f64) -> f64 { *self % *other }
 }
-#[cfg(notest)]
-impl ops::Neg<f64> for f64 {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Rem<f64,f64> for f64 {
     #[inline(always)]
+    fn rem(&self, other: &f64) -> f64 { *self % *other }
+}
+#[cfg(notest)]
+impl Neg<f64> for f64 {
     fn neg(&self) -> f64 { -*self }
 }
 
diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs
index c9cda20640d..9cf14cf0f49 100644
--- a/src/libcore/num/float.rs
+++ b/src/libcore/num/float.rs
@@ -28,9 +28,14 @@ use to_str;
 use from_str;
 
 #[cfg(notest)] use cmp::{Eq, Ord};
-#[cfg(notest)] use ops;
-
-pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
+#[cfg(stage0,notest)]
+use ops::{Add, Sub, Mul, Div, Modulo, Neg};
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+use ops::{Add, Sub, Mul, Quot, Rem, Neg};
+
+pub use f64::{add, sub, mul, quot, rem, lt, le, eq, ne, ge, gt};
 pub use f64::logarithm;
 pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
 pub use f64::{erf, erfc, exp, expm1, exp2, abs_sub};
@@ -449,33 +454,41 @@ impl num::Round for float {
 }
 
 #[cfg(notest)]
-impl ops::Add<float,float> for float {
-    #[inline(always)]
+impl Add<float,float> for float {
     fn add(&self, other: &float) -> float { *self + *other }
 }
 #[cfg(notest)]
-impl ops::Sub<float,float> for float {
-    #[inline(always)]
+impl Sub<float,float> for float {
     fn sub(&self, other: &float) -> float { *self - *other }
 }
 #[cfg(notest)]
-impl ops::Mul<float,float> for float {
-    #[inline(always)]
+impl Mul<float,float> for float {
     fn mul(&self, other: &float) -> float { *self * *other }
 }
-#[cfg(notest)]
-impl ops::Div<float,float> for float {
-    #[inline(always)]
+#[cfg(stage0,notest)]
+impl Div<float,float> for float {
     fn div(&self, other: &float) -> float { *self / *other }
 }
-#[cfg(notest)]
-impl ops::Modulo<float,float> for float {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Quot<float,float> for float {
     #[inline(always)]
+    fn quot(&self, other: &float) -> float { *self / *other }
+}
+#[cfg(stage0,notest)]
+impl Modulo<float,float> for float {
     fn modulo(&self, other: &float) -> float { *self % *other }
 }
-#[cfg(notest)]
-impl ops::Neg<float> for float {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Rem<float,float> for float {
     #[inline(always)]
+    fn rem(&self, other: &float) -> float { *self % *other }
+}
+#[cfg(notest)]
+impl Neg<float> for float {
     fn neg(&self) -> float { -*self }
 }
 
diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs
index e170d85cc71..8f448994c98 100644
--- a/src/libcore/num/int-template.rs
+++ b/src/libcore/num/int-template.rs
@@ -17,8 +17,6 @@ use num::strconv;
 use num;
 use prelude::*;
 
-#[cfg(notest)] use cmp::{Eq, Ord};
-
 pub use cmp::{min, max};
 
 pub static bits : uint = inst::bits;
@@ -34,7 +32,7 @@ pub fn sub(x: T, y: T) -> T { x - y }
 #[inline(always)]
 pub fn mul(x: T, y: T) -> T { x * y }
 #[inline(always)]
-pub fn div(x: T, y: T) -> T { x / y }
+pub fn quot(x: T, y: T) -> T { x / y }
 
 /**
  * Returns the remainder of y / x.
@@ -176,63 +174,71 @@ impl num::One for T {
 }
 
 #[cfg(notest)]
-impl ops::Add<T,T> for T {
-    #[inline(always)]
+impl Add<T,T> for T {
     fn add(&self, other: &T) -> T { *self + *other }
 }
 #[cfg(notest)]
-impl ops::Sub<T,T> for T {
-    #[inline(always)]
+impl Sub<T,T> for T {
     fn sub(&self, other: &T) -> T { *self - *other }
 }
 #[cfg(notest)]
-impl ops::Mul<T,T> for T {
-    #[inline(always)]
+impl Mul<T,T> for T {
     fn mul(&self, other: &T) -> T { *self * *other }
 }
-#[cfg(notest)]
-impl ops::Div<T,T> for T {
-    #[inline(always)]
+#[cfg(stage0,notest)]
+impl Div<T,T> for T {
     fn div(&self, other: &T) -> T { *self / *other }
 }
-#[cfg(notest)]
-impl ops::Modulo<T,T> for T {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Quot<T,T> for T {
     #[inline(always)]
+    fn quot(&self, other: &T) -> T { *self / *other }
+}
+#[cfg(stage0,notest)]
+impl Modulo<T,T> for T {
     fn modulo(&self, other: &T) -> T { *self % *other }
 }
-#[cfg(notest)]
-impl ops::Neg<T> for T {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Rem<T,T> for T {
     #[inline(always)]
+    fn rem(&self, other: &T) -> T { *self % *other }
+}
+#[cfg(notest)]
+impl Neg<T> for T {
     fn neg(&self) -> T { -*self }
 }
 
 #[cfg(notest)]
-impl ops::BitOr<T,T> for T {
+impl BitOr<T,T> for T {
     #[inline(always)]
     fn bitor(&self, other: &T) -> T { *self | *other }
 }
 #[cfg(notest)]
-impl ops::BitAnd<T,T> for T {
+impl BitAnd<T,T> for T {
     #[inline(always)]
     fn bitand(&self, other: &T) -> T { *self & *other }
 }
 #[cfg(notest)]
-impl ops::BitXor<T,T> for T {
+impl BitXor<T,T> for T {
     #[inline(always)]
     fn bitxor(&self, other: &T) -> T { *self ^ *other }
 }
 #[cfg(notest)]
-impl ops::Shl<T,T> for T {
+impl Shl<T,T> for T {
     #[inline(always)]
     fn shl(&self, other: &T) -> T { *self << *other }
 }
 #[cfg(notest)]
-impl ops::Shr<T,T> for T {
+impl Shr<T,T> for T {
     #[inline(always)]
     fn shr(&self, other: &T) -> T { *self >> *other }
 }
 #[cfg(notest)]
-impl ops::Not<T> for T {
+impl Not<T> for T {
     #[inline(always)]
     fn not(&self) -> T { !*self }
 }
diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs
index 58342144752..a0ff510cde7 100644
--- a/src/libcore/num/num.rs
+++ b/src/libcore/num/num.rs
@@ -10,7 +10,16 @@
 
 //! An interface for numeric types
 use cmp::{Eq, Ord};
-use ops::{Neg, Add, Sub, Mul, Div, Modulo};
+#[cfg(stage0)]
+use ops::{Add, Sub, Mul, Neg};
+#[cfg(stage0)]
+use Quot = ops::Div;
+#[cfg(stage0)]
+use Rem = ops::Modulo;
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
+use ops::{Add, Sub, Mul, Quot, Rem, Neg};
 use option::Option;
 use kinds::Copy;
 
@@ -21,8 +30,8 @@ pub trait Num: Eq + Zero + One
              + Add<Self,Self>
              + Sub<Self,Self>
              + Mul<Self,Self>
-             + Div<Self,Self>
-             + Modulo<Self,Self> {}
+             + Quot<Self,Self>
+             + Rem<Self,Self> {}
 
 impl Num for u8 {}
 impl Num for u16 {}
@@ -174,7 +183,7 @@ pub trait FromStrRadix {
  * - If code written to use this function doesn't care about it, it's
  *   probably assuming that `x^0` always equals `1`.
  */
-pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(
+pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Quot<T,T>+Mul<T,T>>(
     radix: uint, pow: uint) -> T {
     let _0: T = Zero::zero();
     let _1: T = One::one();
@@ -194,7 +203,7 @@ pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(
     total
 }
 
-#[cfg(test)]
+#[cfg(stage0,test)]
 fn test_num<T:Num + NumCast>(ten: T, two: T) {
     assert_eq!(ten.add(&two),    cast(12));
     assert_eq!(ten.sub(&two),    cast(8));
@@ -208,6 +217,22 @@ fn test_num<T:Num + NumCast>(ten: T, two: T) {
     assert_eq!(ten.div(&two),    ten / two);
     assert_eq!(ten.modulo(&two), ten % two);
 }
+#[cfg(stage1,test)]
+#[cfg(stage2,test)]
+#[cfg(stage3,test)]
+fn test_num<T:Num + NumCast>(ten: T, two: T) {
+    assert_eq!(ten.add(&two),  cast(12));
+    assert_eq!(ten.sub(&two),  cast(8));
+    assert_eq!(ten.mul(&two),  cast(20));
+    assert_eq!(ten.quot(&two), cast(5));
+    assert_eq!(ten.rem(&two),  cast(0));
+
+    assert_eq!(ten.add(&two),  ten + two);
+    assert_eq!(ten.sub(&two),  ten - two);
+    assert_eq!(ten.mul(&two),  ten * two);
+    assert_eq!(ten.quot(&two), ten / two);
+    assert_eq!(ten.rem(&two),  ten % two);
+}
 
 #[test] fn test_u8_num()    { test_num(10u8,  2u8)  }
 #[test] fn test_u16_num()   { test_num(10u16, 2u16) }
diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs
index de699a3756b..4a45a1d9702 100644
--- a/src/libcore/num/strconv.rs
+++ b/src/libcore/num/strconv.rs
@@ -9,7 +9,16 @@
 // except according to those terms.
 
 use core::cmp::{Ord, Eq};
-use ops::{Add, Div, Modulo, Mul, Neg, Sub};
+#[cfg(stage0)]
+use ops::{Add, Sub, Mul, Neg};
+#[cfg(stage0)]
+use Quot = ops::Div;
+#[cfg(stage0)]
+use Rem = ops::Modulo;
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
+use ops::{Add, Sub, Mul, Quot, Rem, Neg};
 use option::{None, Option, Some};
 use char;
 use str;
@@ -58,7 +67,7 @@ fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool {
 }
 
 #[inline(always)]
-fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool {
+fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Quot<T,T>>(num: &T) -> bool {
     let _0: T = Zero::zero();
     let _1: T = One::one();
 
@@ -171,7 +180,7 @@ static nan_buf:          [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8];
  * - Fails if `radix` < 2 or `radix` > 36.
  */
 pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
-                                  Div<T,T>+Neg<T>+Modulo<T,T>+Mul<T,T>>(
+                                  Quot<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
         num: &T, radix: uint, negative_zero: bool,
         sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) {
     if (radix as int) < 2 {
@@ -379,7 +388,7 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
  */
 #[inline(always)]
 pub fn to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
-                            Div<T,T>+Neg<T>+Modulo<T,T>+Mul<T,T>>(
+                            Quot<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
         num: &T, radix: uint, negative_zero: bool,
         sign: SignFormat, digits: SignificantDigits) -> (~str, bool) {
     let (bytes, special) = to_str_bytes_common(num, radix,
@@ -432,7 +441,7 @@ priv static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
  * - Fails if `radix` > 18 and `special == true` due to conflict
  *   between digit and lowest first character in `inf` and `NaN`, the `'i'`.
  */
-pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
+pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Quot<T,T>+
                                     Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
                                     NumStrConv>(
         buf: &[u8], radix: uint, negative: bool, fractional: bool,
@@ -629,7 +638,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
  * `from_str_bytes_common()`, for details see there.
  */
 #[inline(always)]
-pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+Mul<T,T>+
+pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Quot<T,T>+Mul<T,T>+
                               Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv>(
         buf: &str, radix: uint, negative: bool, fractional: bool,
         special: bool, exponent: ExponentFormat, empty_zero: bool,
diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs
index 0fb6ea614d8..6f3f402f92d 100644
--- a/src/libcore/num/uint-template.rs
+++ b/src/libcore/num/uint-template.rs
@@ -19,8 +19,6 @@ use num;
 use option::Option;
 use prelude::*;
 
-#[cfg(notest)] use cmp::{Eq, Ord};
-
 pub use cmp::{min, max};
 
 pub static bits : uint = inst::bits;
@@ -36,7 +34,7 @@ pub fn sub(x: T, y: T) -> T { x - y }
 #[inline(always)]
 pub fn mul(x: T, y: T) -> T { x * y }
 #[inline(always)]
-pub fn div(x: T, y: T) -> T { x / y }
+pub fn quot(x: T, y: T) -> T { x / y }
 #[inline(always)]
 pub fn rem(x: T, y: T) -> T { x % y }
 
@@ -141,63 +139,71 @@ impl num::One for T {
 }
 
 #[cfg(notest)]
-impl ops::Add<T,T> for T {
-    #[inline(always)]
+impl Add<T,T> for T {
     fn add(&self, other: &T) -> T { *self + *other }
 }
 #[cfg(notest)]
-impl ops::Sub<T,T> for T {
-    #[inline(always)]
+impl Sub<T,T> for T {
     fn sub(&self, other: &T) -> T { *self - *other }
 }
 #[cfg(notest)]
-impl ops::Mul<T,T> for T {
-    #[inline(always)]
+impl Mul<T,T> for T {
     fn mul(&self, other: &T) -> T { *self * *other }
 }
-#[cfg(notest)]
-impl ops::Div<T,T> for T {
-    #[inline(always)]
+#[cfg(stage0,notest)]
+impl Div<T,T> for T {
     fn div(&self, other: &T) -> T { *self / *other }
 }
-#[cfg(notest)]
-impl ops::Modulo<T,T> for T {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Quot<T,T> for T {
     #[inline(always)]
+    fn quot(&self, other: &T) -> T { *self / *other }
+}
+#[cfg(stage0,notest)]
+impl Modulo<T,T> for T {
     fn modulo(&self, other: &T) -> T { *self % *other }
 }
-#[cfg(notest)]
-impl ops::Neg<T> for T {
+#[cfg(stage1,notest)]
+#[cfg(stage2,notest)]
+#[cfg(stage3,notest)]
+impl Rem<T,T> for T {
     #[inline(always)]
+    fn rem(&self, other: &T) -> T { *self % *other }
+}
+#[cfg(notest)]
+impl Neg<T> for T {
     fn neg(&self) -> T { -*self }
 }
 
 #[cfg(notest)]
-impl ops::BitOr<T,T> for T {
+impl BitOr<T,T> for T {
     #[inline(always)]
     fn bitor(&self, other: &T) -> T { *self | *other }
 }
 #[cfg(notest)]
-impl ops::BitAnd<T,T> for T {
+impl BitAnd<T,T> for T {
     #[inline(always)]
     fn bitand(&self, other: &T) -> T { *self & *other }
 }
 #[cfg(notest)]
-impl ops::BitXor<T,T> for T {
+impl BitXor<T,T> for T {
     #[inline(always)]
     fn bitxor(&self, other: &T) -> T { *self ^ *other }
 }
 #[cfg(notest)]
-impl ops::Shl<T,T> for T {
+impl Shl<T,T> for T {
     #[inline(always)]
     fn shl(&self, other: &T) -> T { *self << *other }
 }
 #[cfg(notest)]
-impl ops::Shr<T,T> for T {
+impl Shr<T,T> for T {
     #[inline(always)]
     fn shr(&self, other: &T) -> T { *self >> *other }
 }
 #[cfg(notest)]
-impl ops::Not<T> for T {
+impl Not<T> for T {
     #[inline(always)]
     fn not(&self) -> T { !*self }
 }
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs
index 4d89d8a957c..465a9330f74 100644
--- a/src/libcore/ops.rs
+++ b/src/libcore/ops.rs
@@ -31,14 +31,30 @@ pub trait Mul<RHS,Result> {
 }
 
 #[lang="div"]
+#[cfg(stage0)]
 pub trait Div<RHS,Result> {
     fn div(&self, rhs: &RHS) -> Result;
 }
+#[lang="quot"]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
+pub trait Quot<RHS,Result> {
+    fn quot(&self, rhs: &RHS) -> Result;
+}
 
 #[lang="modulo"]
+#[cfg(stage0)]
 pub trait Modulo<RHS,Result> {
     fn modulo(&self, rhs: &RHS) -> Result;
 }
+#[lang="rem"]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
+pub trait Rem<RHS,Result> {
+    fn rem(&self, rhs: &RHS) -> Result;
+}
 
 #[lang="neg"]
 pub trait Neg<Result> {
diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs
index 822fb2e476b..7d8b3edcab1 100644
--- a/src/libcore/prelude.rs
+++ b/src/libcore/prelude.rs
@@ -14,7 +14,12 @@
 
 pub use either::{Either, Left, Right};
 pub use kinds::{Const, Copy, Owned, Durable};
+#[cfg(stage0)]
 pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
+pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
 pub use ops::{BitAnd, BitOr, BitXor};
 pub use ops::{Drop};
 pub use ops::{Shl, Shr, Index};