]> git.lizzy.rs Git - rust.git/commitdiff
Rename Div operator trait to Quot and Modulo operator trait to Rem
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>
Sun, 21 Apr 2013 15:58:53 +0000 (01:58 +1000)
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>
Sun, 21 Apr 2013 15:58:53 +0000 (01:58 +1000)
34 files changed:
doc/rust.md
doc/tutorial.md
src/etc/kate/rust.xml
src/etc/vim/syntax/rust.vim
src/libcore/core.rc
src/libcore/num/f32.rs
src/libcore/num/f64.rs
src/libcore/num/float.rs
src/libcore/num/int-template.rs
src/libcore/num/num.rs
src/libcore/num/strconv.rs
src/libcore/num/uint-template.rs
src/libcore/ops.rs
src/libcore/prelude.rs
src/librustc/middle/const_eval.rs
src/librustc/middle/kind.rs
src/librustc/middle/lang_items.rs
src/librustc/middle/resolve.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/consts.rs
src/librustc/middle/trans/expr.rs
src/librustc/middle/ty.rs
src/libstd/base64.rs
src/libstd/num/bigint.rs
src/libstd/num/complex.rs
src/libstd/num/rational.rs
src/libstd/std.rc
src/libsyntax/ast.rs
src/libsyntax/ast_util.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/prec.rs
src/test/compile-fail/eval-enum.rs
src/test/run-fail/divide-by-zero.rs
src/test/run-fail/mod-zero.rs

index e9c88fc34121cec67cfd2f2bb241cb33e9c1fa27..b1eb5521b398f6837652120cb3efb7ab872a90b8 100644 (file)
@@ -1467,10 +1467,10 @@ A complete list of the built-in language items follows:
   : Elements can be subtracted.
 `mul`
   : Elements can be multiplied.
-`div`
-  : Elements can be divided.
-`mod`
-  : Elements have a modulo operation.
+`quot`
+  : Elements have a quotient operation.
+`rem`
+  : Elements have a remainder operation.
 `neg`
   : Elements can be negated arithmetically.
 `not`
@@ -1856,11 +1856,11 @@ The default meaning of the operators on standard types is given here.
   : Multiplication.
     Calls the `mul` method on the `core::ops::Mul` trait.
 `/`
-  : Division.
-    Calls the `div` method on the `core::ops::Div` trait.
+  : Quotient.
+    Calls the `quot` method on the `core::ops::Quot` trait.
 `%`
-  : Modulo (a.k.a. "remainder").
-    Calls the `modulo` method on the `core::ops::Modulo` trait.
+  : Remainder.
+    Calls the `rem` method on the `core::ops::Rem` trait.
 
 #### Bitwise operators
 
index 56629b93b1a490f7cc61769419b7b768e81d2ad3..c10bc8a294c5d665cae3a1ffb90a36b6d7ebf451 100644 (file)
@@ -362,7 +362,7 @@ The nil type, written `()`, has a single value, also written `()`.
 ## Operators
 
 Rust's set of operators contains very few surprises. Arithmetic is done with
-`*`, `/`, `%`, `+`, and `-` (multiply, divide, take remainder, add, and subtract). `-` is
+`*`, `/`, `%`, `+`, and `-` (multiply, quotient, remainder, add, and subtract). `-` is
 also a unary prefix operator that negates numbers. As in C, the bitwise operators
 `>>`, `<<`, `&`, `|`, and `^` are also supported.
 
index 59f8c164588b38255fe9dc25a90054b3a9781c64..6a751bd1c858833b9d273d0a4abc22cdc5f9f9ef 100644 (file)
@@ -57,8 +57,8 @@
                <item> Add </item>
                <item> Sub </item>
                <item> Mul </item>
-               <item> Div </item>
-               <item> Modulo </item>
+               <item> Quot </item>
+               <item> Rem </item>
                <item> Neg </item>
                <item> BitAnd </item>
                <item> BitOr </item>
index 3e6c11c6238b1afc0835579743322d0ac1485df4..eab3627ae16d15d1eae938be0d4c8fcbed94b5f6 100644 (file)
@@ -46,7 +46,7 @@ syn keyword   rustType        off_t dev_t ino_t pid_t mode_t ssize_t
 
 syn keyword   rustTrait       Const Copy Send Owned " inherent traits
 syn keyword   rustTrait       Eq Ord Num Ptr
-syn keyword   rustTrait       Drop Add Sub Mul Div Modulo Neg BitAnd BitOr
+syn keyword   rustTrait       Drop Add Sub Mul Quot Rem Neg BitAnd BitOr
 syn keyword   rustTrait       BitXor Shl Shr Index
 
 syn keyword   rustSelf        self
index 81190ea8fc62e4f8c9d805674b988057cb1d35dc..fd8813d0c4a4573dfcd79da0e0b3e65b569efdb1 100644 (file)
@@ -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};
 
index 6233f8c2a61b53425aaa10999ddfddf2859028fa..2e7dc98e3c56c2ecf8ea8014569aab38c4312423 100644 (file)
 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 is_NaN(f: f32) -> bool { f != f }
 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 @@ fn ne(&self, other: &f32) -> bool { (*self) != (*other) }
 }
 
 #[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 @@ fn one() -> f32 { 1.0 }
 }
 
 #[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 }
 }
 
index 7f32893f5bff76f21a30e101b6a19e78e9f38785..4762c395a2561a745ca4784077e218ba2b130cb6 100644 (file)
 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 is_NaN(f: f64) -> bool { f != f }
 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 @@ fn ne(&self, other: &f64) -> bool { (*self) != (*other) }
 }
 
 #[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 @@ fn one() -> f64 { 1.0 }
 }
 
 #[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 }
 }
 
index c9cda20640d569666587d7461f500da418fdf788..9cf14cf0f494bbc340ab514007be50dd0d935795 100644 (file)
 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 @@ fn fract(&self) -> 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 }
 }
 
index e170d85cc716e6d0ef73ac00c6940798984d028c..8f448994c98115f8e45a0ae83d3e693f9a046d54 100644 (file)
@@ -17,8 +17,6 @@
 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 @@ fn one() -> T { 1 }
 }
 
 #[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 }
 }
index 5834214475219497d9432ad38dd19b7f16cf5965..a0ff510cde7da0bd04646a134e77a1346e18d027 100644 (file)
 
 //! 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) }
index de699a3756b6ebc25df27cf4ddf8d282cc8e904b..4a45a1d97023e1817dbbfab1a67fee1c6bec20e4 100644 (file)
@@ -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 @@ impl NumStrConv for $t {
  * - 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 @@ pub fn to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
  * - 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,
index 0fb6ea614d8614f9e57d264e1d3137257f56cf19..6f3f402f92d69022f2d387ec6edeea442f729e7e 100644 (file)
@@ -19,8 +19,6 @@
 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 @@ fn one() -> T { 1 }
 }
 
 #[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 }
 }
index 4d89d8a957c7b9a705a51d28456ad6463effc2f3..465a9330f74c0a6e20eab48dc633e66270695abf 100644 (file)
@@ -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> {
index 822fb2e476beb2de74b5149a807a9fdd85c1cf07..7d8b3edcab15232615ac8c4812f33e252e7f02ca 100644 (file)
 
 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};
index 5148ea7fba4030a9e060420323fcc7b83ff6a1e7..c1cc01ed05a724a84eb71328a429473b80713979 100644 (file)
@@ -283,7 +283,7 @@ fn fromb(b: bool) -> Result<const_val, ~str> { Ok(const_int(b as i64)) }
               add => Ok(const_float(a + b)),
               subtract => Ok(const_float(a - b)),
               mul => Ok(const_float(a * b)),
-              div => Ok(const_float(a / b)),
+              quot => Ok(const_float(a / b)),
               rem => Ok(const_float(a % b)),
               eq => fromb(a == b),
               lt => fromb(a < b),
@@ -299,9 +299,9 @@ fn fromb(b: bool) -> Result<const_val, ~str> { Ok(const_int(b as i64)) }
               add => Ok(const_int(a + b)),
               subtract => Ok(const_int(a - b)),
               mul => Ok(const_int(a * b)),
-              div if b == 0 => Err(~"divide by zero"),
-              div => Ok(const_int(a / b)),
-              rem if b == 0 => Err(~"modulo zero"),
+              quot if b == 0 => Err(~"quotient zero"),
+              quot => Ok(const_int(a / b)),
+              rem if b == 0 => Err(~"remainder zero"),
               rem => Ok(const_int(a % b)),
               and | bitand => Ok(const_int(a & b)),
               or | bitor => Ok(const_int(a | b)),
@@ -321,9 +321,9 @@ fn fromb(b: bool) -> Result<const_val, ~str> { Ok(const_int(b as i64)) }
               add => Ok(const_uint(a + b)),
               subtract => Ok(const_uint(a - b)),
               mul => Ok(const_uint(a * b)),
-              div if b == 0 => Err(~"divide by zero"),
-              div => Ok(const_uint(a / b)),
-              rem if b == 0 => Err(~"modulo zero"),
+              quot if b == 0 => Err(~"quotient zero"),
+              quot => Ok(const_uint(a / b)),
+              rem if b == 0 => Err(~"remainder zero"),
               rem => Ok(const_uint(a % b)),
               and | bitand => Ok(const_uint(a & b)),
               or | bitor => Ok(const_uint(a | b)),
index 390ffded2fe36f10183add36869ed86b98f5cfde..0558df60b73037e60e82b5ba4372ee62c541fced 100644 (file)
@@ -480,7 +480,7 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
 
 /// This is rather subtle.  When we are casting a value to a instantiated
 /// trait like `a as trait<'r>`, regionck already ensures that any borrowed
-/// pointers that appear in the type of `a` are bounded by `'r` (ed.: modulo
+/// pointers that appear in the type of `a` are bounded by `'r` (ed.: rem
 /// FIXME(#5723)).  However, it is possible that there are *type parameters*
 /// in the type of `a`, and those *type parameters* may have borrowed pointers
 /// within them.  We have to guarantee that the regions which appear in those
index 435cb896ac7a18ddcdfe16006300d471159b6862..5b302108ef062f94ba763084ee2a053ff4e19fea 100644 (file)
@@ -45,8 +45,8 @@ pub enum LangItem {
     AddTraitLangItem,           // 5
     SubTraitLangItem,           // 6
     MulTraitLangItem,           // 7
-    DivTraitLangItem,           // 8
-    ModuloTraitLangItem,        // 9
+    QuotTraitLangItem,          // 8
+    RemTraitLangItem,           // 9
     NegTraitLangItem,           // 10
     NotTraitLangItem,           // 11
     BitXorTraitLangItem,        // 12
@@ -108,8 +108,8 @@ pub fn item_name(index: uint) -> &'static str {
             5  => "add",
             6  => "sub",
             7  => "mul",
-            8  => "div",
-            9  => "modulo",
+            8  => "quot",
+            9  => "rem",
             10 => "neg",
             11 => "not",
             12 => "bitxor",
@@ -170,11 +170,11 @@ pub fn sub_trait(&const self) -> def_id {
     pub fn mul_trait(&const self) -> def_id {
         self.items[MulTraitLangItem as uint].get()
     }
-    pub fn div_trait(&const self) -> def_id {
-        self.items[DivTraitLangItem as uint].get()
+    pub fn quot_trait(&const self) -> def_id {
+        self.items[QuotTraitLangItem as uint].get()
     }
-    pub fn modulo_trait(&const self) -> def_id {
-        self.items[ModuloTraitLangItem as uint].get()
+    pub fn rem_trait(&const self) -> def_id {
+        self.items[RemTraitLangItem as uint].get()
     }
     pub fn neg_trait(&const self) -> def_id {
         self.items[NegTraitLangItem as uint].get()
@@ -271,8 +271,8 @@ fn LanguageItemCollector<'r>(crate: @crate,
     item_refs.insert(@~"add", AddTraitLangItem as uint);
     item_refs.insert(@~"sub", SubTraitLangItem as uint);
     item_refs.insert(@~"mul", MulTraitLangItem as uint);
-    item_refs.insert(@~"div", DivTraitLangItem as uint);
-    item_refs.insert(@~"modulo", ModuloTraitLangItem as uint);
+    item_refs.insert(@~"quot", QuotTraitLangItem as uint);
+    item_refs.insert(@~"rem", RemTraitLangItem as uint);
     item_refs.insert(@~"neg", NegTraitLangItem as uint);
     item_refs.insert(@~"not", NotTraitLangItem as uint);
     item_refs.insert(@~"bitxor", BitXorTraitLangItem as uint);
index 3c158c0d081f8621376c6034e086c7e0902de749..41b372119cd292f103361f820067840073ddb72c 100644 (file)
@@ -37,7 +37,7 @@
 use syntax::ast::{expr_binary, expr_break, expr_field};
 use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path};
 use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param};
-use syntax::ast::{def_upvar, def_use, def_variant, div, eq};
+use syntax::ast::{def_upvar, def_use, def_variant, quot, eq};
 use syntax::ast::{expr, expr_again, expr_assign_op};
 use syntax::ast::{expr_index, expr_loop};
 use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl};
@@ -4899,13 +4899,13 @@ fn record_candidate_traits_for_expr_if_necessary(@mut self, expr: @expr) {
                 self.add_fixed_trait_for_expr(expr.id,
                                               self.lang_items.mul_trait());
             }
-            expr_binary(div, _, _) | expr_assign_op(div, _, _) => {
+            expr_binary(quot, _, _) | expr_assign_op(quot, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
-                                              self.lang_items.div_trait());
+                                              self.lang_items.quot_trait());
             }
             expr_binary(rem, _, _) | expr_assign_op(rem, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
-                                              self.lang_items.modulo_trait());
+                                              self.lang_items.rem_trait());
             }
             expr_binary(bitxor, _, _) | expr_assign_op(bitxor, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
index e1c60234f0ff04e634442be1078abdfc4eb4bfe2..3ad021b2f518fb8a8af3da7b815e6f597ad13214 100644 (file)
@@ -782,12 +782,12 @@ pub fn cast_shift_rhs(op: ast::binop,
     }
 }
 
-pub fn fail_if_zero(cx: block, span: span, divmod: ast::binop,
+pub fn fail_if_zero(cx: block, span: span, quotrem: ast::binop,
                     rhs: ValueRef, rhs_t: ty::t) -> block {
-    let text = if divmod == ast::div {
-        @~"divide by zero"
+    let text = if quotrem == ast::quot {
+        @~"quotient zero"
     } else {
-        @~"modulo zero"
+        @~"remainder zero"
     };
     let is_zero = match ty::get(rhs_t).sty {
       ty::ty_int(t) => {
index c5e708569dc25d66297d9a740942b451d35126e0..d0aeec89750aafde7ee3e09da2c662df35661a9b 100644 (file)
@@ -272,7 +272,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                 if is_float { llvm::LLVMConstFMul(te1, te2) }
                 else        { llvm::LLVMConstMul(te1, te2) }
               }
-              ast::div    => {
+              ast::quot   => {
                 if is_float    { llvm::LLVMConstFDiv(te1, te2) }
                 else if signed { llvm::LLVMConstSDiv(te1, te2) }
                 else           { llvm::LLVMConstUDiv(te1, te2) }
index ba6965f0eaea3d245c2526d367258b7d74cab968..4b4d0869a3ed3aa87e999a670a74c054eb5b5d45 100644 (file)
@@ -1437,7 +1437,7 @@ fn trans_eager_binop(bcx: block,
         if is_float { FMul(bcx, lhs, rhs) }
         else { Mul(bcx, lhs, rhs) }
       }
-      ast::div => {
+      ast::quot => {
         if is_float {
             FDiv(bcx, lhs, rhs)
         } else {
index 95d0fa984aea0472934fbf46dee862360e7ce100..033fbecc08b37ec03246a61374036d75fd16453b 100644 (file)
@@ -4255,7 +4255,7 @@ fn opcat(op: ast::binop) -> int {
           ast::add => opcat_add,
           ast::subtract => opcat_sub,
           ast::mul => opcat_mult,
-          ast::div => opcat_mult,
+          ast::quot => opcat_mult,
           ast::rem => opcat_mult,
           ast::and => opcat_logic,
           ast::or => opcat_logic,
index e90f0fb3c81d4216e9e12f4d1fa63fe8fbbdba29..cbdd2b19d276c92bfa1e21f6a96fd66934ce4a79 100644 (file)
@@ -118,7 +118,7 @@ pub trait FromBase64 {
 impl FromBase64 for ~[u8] {
     /**
      * Convert base64 `u8` vector into u8 byte values.
-     * Every 4 encoded characters is converted into 3 octets, modulo padding.
+     * Every 4 encoded characters is converted into 3 octets, rem padding.
      *
      * *Example*:
      *
index ec5d2cded8d56d468f3d2db44dba201d5dd8aa58..08c65d190bf99e29c039c2e07258830f0a0011e6 100644 (file)
@@ -262,16 +262,16 @@ fn sub_sign(a: BigUint, b: BigUint) -> (Ordering, BigUint) {
     }
 }
 
-impl Div<BigUint, BigUint> for BigUint {
-    fn div(&self, other: &BigUint) -> BigUint {
-        let (d, _) = self.divmod(other);
+impl Quot<BigUint, BigUint> for BigUint {
+    fn quot(&self, other: &BigUint) -> BigUint {
+        let (d, _) = self.quot_rem(other);
         return d;
     }
 }
 
-impl Modulo<BigUint, BigUint> for BigUint {
-    fn modulo(&self, other: &BigUint) -> BigUint {
-        let (_, m) = self.divmod(other);
+impl Rem<BigUint, BigUint> for BigUint {
+    fn rem(&self, other: &BigUint) -> BigUint {
+        let (_, m) = self.quot_rem(other);
         return m;
     }
 }
@@ -304,7 +304,7 @@ fn convert_base(n: BigUint, base: uint) -> ~[BigDigit] {
             let mut result = ~[];
             let mut r      = n;
             while r > divider {
-                let (d, r0) = r.divmod(&divider);
+                let (d, r0) = r.quot_rem(&divider);
                 result += [r0.to_uint() as BigDigit];
                 r = d;
             }
@@ -384,7 +384,7 @@ pub fn parse_bytes(buf: &[u8], radix: uint)
 
     fn abs(&self) -> BigUint { copy *self }
 
-    fn divmod(&self, other: &BigUint) -> (BigUint, BigUint) {
+    fn quot_rem(&self, other: &BigUint) -> (BigUint, BigUint) {
         if other.is_zero() { fail!() }
         if self.is_zero() { return (Zero::zero(), Zero::zero()); }
         if *other == One::one() { return (copy *self, Zero::zero()); }
@@ -402,10 +402,10 @@ fn divmod(&self, other: &BigUint) -> (BigUint, BigUint) {
             shift += 1;
         }
         assert!(shift < BigDigit::bits);
-        let (d, m) = divmod_inner(self << shift, other << shift);
+        let (d, m) = quot_rem_inner(self << shift, other << shift);
         return (d, m >> shift);
 
-        fn divmod_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) {
+        fn quot_rem_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) {
             let mut r = a;
             let mut d = Zero::zero::<BigUint>();
             let mut n = 1;
@@ -464,7 +464,7 @@ fn rem(&self, other: &BigUint) -> BigUint {
         return r;
     }
     fn quotrem(&self, other: &BigUint) -> (BigUint, BigUint) {
-        self.divmod(other)
+        self.quot_rem(other)
     }
 
     fn is_zero(&self) -> bool { self.data.is_empty() }
@@ -737,16 +737,16 @@ fn mul(&self, other: &BigInt) -> BigInt {
     }
 }
 
-impl Div<BigInt, BigInt> for BigInt {
-    fn div(&self, other: &BigInt) -> BigInt {
-        let (d, _) = self.divmod(other);
+impl Quot<BigInt, BigInt> for BigInt {
+    fn quot(&self, other: &BigInt) -> BigInt {
+        let (d, _) = self.quot_rem(other);
         return d;
     }
 }
 
-impl Modulo<BigInt, BigInt> for BigInt {
-    fn modulo(&self, other: &BigInt) -> BigInt {
-        let (_, m) = self.divmod(other);
+impl Rem<BigInt, BigInt> for BigInt {
+    fn rem(&self, other: &BigInt) -> BigInt {
+        let (_, m) = self.quot_rem(other);
         return m;
     }
 }
@@ -841,9 +841,9 @@ fn abs(&self) -> BigInt {
         BigInt::from_biguint(Plus, copy self.data)
     }
 
-    fn divmod(&self, other: &BigInt) -> (BigInt, BigInt) {
+    fn quot_rem(&self, other: &BigInt) -> (BigInt, BigInt) {
         // m.sign == other.sign
-        let (d_ui, m_ui) = self.data.divmod(&other.data);
+        let (d_ui, m_ui) = self.data.quot_rem(&other.data);
         let d = BigInt::from_biguint(Plus, d_ui),
             m = BigInt::from_biguint(Plus, m_ui);
         match (self.sign, other.sign) {
@@ -1150,7 +1150,7 @@ fn test_sub() {
         (&[ 0,  0,  1],     &[ 0,  0,  0,  1], &[0, 0,  0,  0,  0,  1])
     ];
 
-    static divmod_quadruples: &'static [(&'static [BigDigit],
+    static quot_rem_quadruples: &'static [(&'static [BigDigit],
                                          &'static [BigDigit],
                                          &'static [BigDigit],
                                          &'static [BigDigit])]
@@ -1174,7 +1174,7 @@ fn test_mul() {
             assert!(b * a == c);
         }
 
-        for divmod_quadruples.each |elm| {
+        for quot_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigUint::from_slice(aVec);
             let b = BigUint::from_slice(bVec);
@@ -1187,7 +1187,7 @@ fn test_mul() {
     }
 
     #[test]
-    fn test_divmod() {
+    fn test_quot_rem() {
         for mul_triples.each |elm| {
             let (aVec, bVec, cVec) = *elm;
             let a = BigUint::from_slice(aVec);
@@ -1195,21 +1195,21 @@ fn test_divmod() {
             let c = BigUint::from_slice(cVec);
 
             if a.is_not_zero() {
-                assert!(c.divmod(&a) == (b, Zero::zero()));
+                assert!(c.quot_rem(&a) == (b, Zero::zero()));
             }
             if b.is_not_zero() {
-                assert!(c.divmod(&b) == (a, Zero::zero()));
+                assert!(c.quot_rem(&b) == (a, Zero::zero()));
             }
         }
 
-        for divmod_quadruples.each |elm| {
+        for quot_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigUint::from_slice(aVec);
             let b = BigUint::from_slice(bVec);
             let c = BigUint::from_slice(cVec);
             let d = BigUint::from_slice(dVec);
 
-            if b.is_not_zero() { assert!(a.divmod(&b) == (c, d)); }
+            if b.is_not_zero() { assert!(a.quot_rem(&b) == (c, d)); }
         }
     }
 
@@ -1516,7 +1516,7 @@ fn test_sub() {
         (&[ 0,  0,  1],     &[ 0,  0,  0,  1], &[0, 0,  0,  0,  0,  1])
     ];
 
-    static divmod_quadruples: &'static [(&'static [BigDigit],
+    static quot_rem_quadruples: &'static [(&'static [BigDigit],
                                          &'static [BigDigit],
                                          &'static [BigDigit],
                                          &'static [BigDigit])]
@@ -1543,7 +1543,7 @@ fn test_mul() {
             assert!((-b) * a == -c);
         }
 
-        for divmod_quadruples.each |elm| {
+        for quot_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigInt::from_slice(Plus, aVec);
             let b = BigInt::from_slice(Plus, bVec);
@@ -1556,9 +1556,9 @@ fn test_mul() {
     }
 
     #[test]
-    fn test_divmod() {
+    fn test_quot_rem() {
         fn check_sub(a: &BigInt, b: &BigInt, ans_d: &BigInt, ans_m: &BigInt) {
-            let (d, m) = a.divmod(b);
+            let (d, m) = a.quot_rem(b);
             if m.is_not_zero() {
                 assert!(m.sign == b.sign);
             }
@@ -1592,7 +1592,7 @@ fn check(a: &BigInt, b: &BigInt, d: &BigInt, m: &BigInt) {
             if b.is_not_zero() { check(&c, &b, &a, &Zero::zero()); }
         }
 
-        for divmod_quadruples.each |elm| {
+        for quot_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigInt::from_slice(Plus, aVec);
             let b = BigInt::from_slice(Plus, bVec);
@@ -1635,7 +1635,7 @@ fn check(a: &BigInt, b: &BigInt, q: &BigInt, r: &BigInt) {
             if b.is_not_zero() { check(&c, &b, &a, &Zero::zero()); }
         }
 
-        for divmod_quadruples.each |elm| {
+        for quot_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigInt::from_slice(Plus, aVec);
             let b = BigInt::from_slice(Plus, bVec);
index 949850f3ca6771d8c96c8545dbe56fe139932a2d..ef7fa397d7f1bc75686e0a746b517dbd8864673b 100644 (file)
@@ -32,8 +32,7 @@ pub struct Cmplx<T> {
 pub type Complex32 = Cmplx<f32>;
 pub type Complex64 = Cmplx<f64>;
 
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>
-    Cmplx<T> {
+impl<T: Copy + Num> Cmplx<T> {
     /// Create a new Cmplx
     #[inline]
     pub fn new(re: T, im: T) -> Cmplx<T> {
@@ -80,24 +79,21 @@ pub fn inv(&self) -> Cmplx<T> {
 
 /* arithmetic */
 // (a + i b) + (c + i d) == (a + c) + i (b + d)
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>
-    Add<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
+impl<T: Copy + Num> Add<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
     #[inline]
     fn add(&self, other: &Cmplx<T>) -> Cmplx<T> {
         Cmplx::new(self.re + other.re, self.im + other.im)
     }
 }
 // (a + i b) - (c + i d) == (a - c) + i (b - d)
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>
-    Sub<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
+impl<T: Copy + Num> Sub<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
     #[inline]
     fn sub(&self, other: &Cmplx<T>) -> Cmplx<T> {
         Cmplx::new(self.re - other.re, self.im - other.im)
     }
 }
 // (a + i b) * (c + i d) == (a*c - b*d) + i (a*d + b*c)
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>
-    Mul<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
+impl<T: Copy + Num> Mul<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
     #[inline]
     fn mul(&self, other: &Cmplx<T>) -> Cmplx<T> {
         Cmplx::new(self.re*other.re - self.im*other.im,
@@ -107,18 +103,16 @@ fn mul(&self, other: &Cmplx<T>) -> Cmplx<T> {
 
 // (a + i b) / (c + i d) == [(a + i b) * (c - i d)] / (c*c + d*d)
 //   == [(a*c + b*d) / (c*c + d*d)] + i [(b*c - a*d) / (c*c + d*d)]
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>
-    Div<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
+impl<T: Copy + Num> Quot<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
     #[inline]
-    fn div(&self, other: &Cmplx<T>) -> Cmplx<T> {
+    fn quot(&self, other: &Cmplx<T>) -> Cmplx<T> {
         let norm_sqr = other.norm_sqr();
         Cmplx::new((self.re*other.re + self.im*other.im) / norm_sqr,
                      (self.im*other.re - self.re*other.im) / norm_sqr)
     }
 }
 
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>
-    Neg<Cmplx<T>> for Cmplx<T> {
+impl<T: Copy + Num> Neg<Cmplx<T>> for Cmplx<T> {
     #[inline]
     fn neg(&self) -> Cmplx<T> {
         Cmplx::new(-self.re, -self.im)
@@ -126,16 +120,14 @@ fn neg(&self) -> Cmplx<T> {
 }
 
 /* constants */
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T> + Zero>
-    Zero for Cmplx<T> {
+impl<T: Copy + Num> Zero for Cmplx<T> {
     #[inline]
     fn zero() -> Cmplx<T> {
         Cmplx::new(Zero::zero(), Zero::zero())
     }
 }
 
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T> + Zero + One>
-    One for Cmplx<T> {
+impl<T: Copy + Num> One for Cmplx<T> {
     #[inline]
     fn one() -> Cmplx<T> {
         Cmplx::new(One::one(), Zero::zero())
@@ -143,7 +135,7 @@ fn one() -> Cmplx<T> {
 }
 
 /* string conversions */
-impl<T: ToStr + Zero + Ord + Neg<T>> ToStr for Cmplx<T> {
+impl<T: ToStr + Num + Ord> ToStr for Cmplx<T> {
     fn to_str(&self) -> ~str {
         if self.im < Zero::zero() {
             fmt!("%s-%si", self.re.to_str(), (-self.im).to_str())
@@ -153,7 +145,7 @@ fn to_str(&self) -> ~str {
     }
 }
 
-impl<T: ToStrRadix + Zero + Ord + Neg<T>> ToStrRadix for Cmplx<T> {
+impl<T: ToStrRadix + Num + Ord> ToStrRadix for Cmplx<T> {
     fn to_str_radix(&self, radix: uint) -> ~str {
         if self.im < Zero::zero() {
             fmt!("%s-%si", self.re.to_str_radix(radix), (-self.im).to_str_radix(radix))
@@ -280,7 +272,7 @@ fn test_mul() {
             }
         }
         #[test]
-        fn test_div() {
+        fn test_quot() {
             assert_eq!(_neg1_1i / _0_1i, _1_1i);
             for all_consts.each |&c| {
                 if c != Zero::zero() {
index f15b382dcd35105a11b75ae9155873ab15fce48e..2098429833dfcb25d254fe0e0aafe4cacadcb9ca 100644 (file)
@@ -33,7 +33,7 @@ pub struct Ratio<T> {
 /// Alias for arbitrary precision rationals.
 pub type BigRational = Ratio<BigInt>;
 
-impl<T: Copy + Div<T,T> + Modulo<T,T> + Neg<T> + Zero + One + Ord + Eq>
+impl<T: Copy + Num + Ord>
     Ratio<T> {
     /// Create a ratio representing the integer `t`.
     #[inline(always)]
@@ -51,7 +51,7 @@ pub fn new_raw(numer: T, denom: T) -> Ratio<T> {
     #[inline(always)]
     pub fn new(numer: T, denom: T) -> Ratio<T> {
         if denom == Zero::zero() {
-            fail!(~"divide by 0");
+            fail!(~"quotient of 0");
         }
         let mut ret = Ratio::new_raw(numer, denom);
         ret.reduce();
@@ -85,7 +85,7 @@ fn reduced(&self) -> Ratio<T> {
 The result can be negative.
 */
 #[inline]
-pub fn gcd_raw<T: Modulo<T,T> + Zero + Eq>(n: T, m: T) -> T {
+pub fn gcd_raw<T: Num>(n: T, m: T) -> T {
     let mut m = m, n = n;
     while m != Zero::zero() {
         let temp = m;
@@ -101,7 +101,7 @@ pub fn gcd_raw<T: Modulo<T,T> + Zero + Eq>(n: T, m: T) -> T {
 The result is always positive.
 */
 #[inline]
-pub fn gcd<T: Modulo<T,T> + Neg<T> + Zero + Ord + Eq>(n: T, m: T) -> T {
+pub fn gcd<T: Num + Ord>(n: T, m: T) -> T {
     let g = gcd_raw(n, m);
     if g < Zero::zero() { -g }
     else { g }
@@ -136,7 +136,7 @@ fn $method(&self, other: &Ratio<T>) -> $res {
 
 /* Arithmetic */
 // a/b * c/d = (a*c)/(b*d)
-impl<T: Copy + Mul<T,T> + Div<T,T> + Modulo<T,T> + Neg<T> + Zero + One + Ord + Eq>
+impl<T: Copy + Num + Ord>
     Mul<Ratio<T>,Ratio<T>> for Ratio<T> {
     #[inline]
     fn mul(&self, rhs: &Ratio<T>) -> Ratio<T> {
@@ -145,10 +145,10 @@ fn mul(&self, rhs: &Ratio<T>) -> Ratio<T> {
 }
 
 // (a/b) / (c/d) = (a*d)/(b*c)
-impl<T: Copy + Mul<T,T> + Div<T,T> + Modulo<T,T> + Neg<T> + Zero + One + Ord + Eq>
-    Div<Ratio<T>,Ratio<T>> for Ratio<T> {
+impl<T: Copy + Num + Ord>
+    Quot<Ratio<T>,Ratio<T>> for Ratio<T> {
     #[inline]
-    fn div(&self, rhs: &Ratio<T>) -> Ratio<T> {
+    fn quot(&self, rhs: &Ratio<T>) -> Ratio<T> {
         Ratio::new(self.numer * rhs.denom, self.denom * rhs.numer)
     }
 }
@@ -156,9 +156,7 @@ fn div(&self, rhs: &Ratio<T>) -> Ratio<T> {
 // Abstracts the a/b `op` c/d = (a*d `op` b*d) / (b*d) pattern
 macro_rules! arith_impl {
     (impl $imp:ident, $method:ident) => {
-        impl<T: Copy +
-                Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Modulo<T,T> + Neg<T> +
-                Zero + One + Ord + Eq>
+        impl<T: Copy + Num + Ord>
             $imp<Ratio<T>,Ratio<T>> for Ratio<T> {
             #[inline]
             fn $method(&self, rhs: &Ratio<T>) -> Ratio<T> {
@@ -176,9 +174,9 @@ fn $method(&self, rhs: &Ratio<T>) -> Ratio<T> {
 arith_impl!(impl Sub, sub)
 
 // a/b % c/d = (a*d % b*c)/(b*d)
-arith_impl!(impl Modulo, modulo)
+arith_impl!(impl Rem, rem)
 
-impl<T: Copy + Div<T,T> + Modulo<T,T> + Neg<T> + Zero + One + Ord + Eq>
+impl<T: Copy + Num + Ord>
     Neg<Ratio<T>> for Ratio<T> {
     #[inline]
     fn neg(&self) -> Ratio<T> {
@@ -187,7 +185,7 @@ fn neg(&self) -> Ratio<T> {
 }
 
 /* Constants */
-impl<T: Copy + Div<T,T> + Modulo<T,T> + Neg<T> + Zero + One + Ord + Eq>
+impl<T: Copy + Num + Ord>
     Zero for Ratio<T> {
     #[inline]
     fn zero() -> Ratio<T> {
@@ -195,7 +193,7 @@ fn zero() -> Ratio<T> {
     }
 }
 
-impl<T: Copy + Div<T,T> + Modulo<T,T> + Neg<T> + Zero + One + Ord + Eq>
+impl<T: Copy + Num + Ord>
     One for Ratio<T> {
     #[inline]
     fn one() -> Ratio<T> {
@@ -204,8 +202,7 @@ fn one() -> Ratio<T> {
 }
 
 /* Utils */
-impl<T: Copy + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Modulo<T,T> + Neg<T> +
-    Zero + One + Ord + Eq>
+impl<T: Copy + Num + Ord>
     Round for Ratio<T> {
     fn round(&self, mode: num::RoundMode) -> Ratio<T> {
         match mode {
@@ -256,7 +253,7 @@ fn to_str_radix(&self, radix: uint) -> ~str {
     }
 }
 
-impl<T: FromStr + Copy + Div<T,T> + Modulo<T,T> + Neg<T> + Zero + One + Ord + Eq>
+impl<T: FromStr + Copy + Num + Ord>
     FromStr for Ratio<T> {
     /// Parses `numer/denom`.
     fn from_str(s: &str) -> Option<Ratio<T>> {
@@ -273,7 +270,7 @@ fn from_str(s: &str) -> Option<Ratio<T>> {
         }
     }
 }
-impl<T: FromStrRadix + Copy + Div<T,T> + Modulo<T,T> + Neg<T> + Zero + One + Ord + Eq>
+impl<T: FromStrRadix + Copy + Num + Ord>
     FromStrRadix for Ratio<T> {
     /// Parses `numer/denom` where the numbers are in base `radix`.
     fn from_str_radix(s: &str, radix: uint) -> Option<Ratio<T>> {
@@ -386,14 +383,14 @@ fn test_mul() {
         }
 
         #[test]
-        fn test_div() {
+        fn test_quot() {
             assert_eq!(_1 / _1_2, _2);
             assert_eq!(_3_2 / _1_2, _1 + _2);
             assert_eq!(_1 / _neg1_2, _neg1_2 + _neg1_2 + _neg1_2 + _neg1_2);
         }
 
         #[test]
-        fn test_modulo() {
+        fn test_rem() {
             assert_eq!(_3_2 % _1, _1_2);
             assert_eq!(_2 % _neg1_2, _0);
             assert_eq!(_1_2 % _2,  _1_2);
@@ -415,7 +412,7 @@ fn test_zero() {
         }
         #[test]
         #[should_fail]
-        fn test_div_0() {
+        fn test_quot_0() {
             let _a =  _1 / _0;
         }
     }
index 3dfc3200f0f5205d3680c54c609161c376a82f4d..7bedef0f84110220257c6a1bf02ca08b4bd399b9 100644 (file)
@@ -98,10 +98,19 @@ pub mod cmp;
 pub mod base64;
 pub mod rl;
 pub mod workcache;
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
 #[path="num/bigint.rs"]
 pub mod bigint;
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
 #[path="num/rational.rs"]
 pub mod rational;
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[cfg(stage3)]
 #[path="num/complex.rs"]
 pub mod complex;
 pub mod stats;
index b0b3e45abe501203965eb5c53e6eac5e4d2b2aad..a086a1db0aaf16f0400a128e30fd2b61e1e2d3b6 100644 (file)
@@ -389,7 +389,7 @@ pub enum binop {
     add,
     subtract,
     mul,
-    div,
+    quot,
     rem,
     and,
     or,
index 910c9857d2d635888efbff6a390b11cc5fc363db..f0a14b39049a814c10b1e0e301df3c7706f26a46 100644 (file)
@@ -80,7 +80,7 @@ pub fn binop_to_str(op: binop) -> ~str {
       add => return ~"+",
       subtract => return ~"-",
       mul => return ~"*",
-      div => return ~"/",
+      quot => return ~"/",
       rem => return ~"%",
       and => return ~"&&",
       or => return ~"||",
@@ -103,8 +103,8 @@ pub fn binop_to_method_name(op: binop) -> Option<~str> {
       add => return Some(~"add"),
       subtract => return Some(~"sub"),
       mul => return Some(~"mul"),
-      div => return Some(~"div"),
-      rem => return Some(~"modulo"),
+      quot => return Some(~"quot"),
+      rem => return Some(~"rem"),
       bitxor => return Some(~"bitxor"),
       bitand => return Some(~"bitand"),
       bitor => return Some(~"bitor"),
@@ -348,7 +348,7 @@ pub fn is_self(d: ast::def) -> bool {
 /// Maps a binary operator to its precedence
 pub fn operator_prec(op: ast::binop) -> uint {
   match op {
-      mul | div | rem   => 12u,
+      mul | quot | rem   => 12u,
       // 'as' sits between here with 11
       add | subtract    => 10u,
       shl | shr         =>  9u,
index e892f212b0577b3f9e2a9874659e1a9f7293059d..42275aca0a3e2778476e1034d6fd729163189544 100644 (file)
@@ -21,7 +21,7 @@
 use ast::{bind_by_copy, bitand, bitor, bitxor, blk};
 use ast::{blk_check_mode, box, by_copy, by_ref};
 use ast::{crate, crate_cfg, decl, decl_item};
-use ast::{decl_local, default_blk, deref, div, enum_def};
+use ast::{decl_local, default_blk, deref, quot, enum_def};
 use ast::{expl, expr, expr_, expr_addr_of, expr_match, expr_again};
 use ast::{expr_assign, expr_assign_op, expr_binary, expr_block};
 use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
@@ -1786,7 +1786,7 @@ fn parse_assign_expr(&self) -> @expr {
                   token::PLUS => aop = add,
                   token::MINUS => aop = subtract,
                   token::STAR => aop = mul,
-                  token::SLASH => aop = div,
+                  token::SLASH => aop = quot,
                   token::PERCENT => aop = rem,
                   token::CARET => aop = bitxor,
                   token::AND => aop = bitand,
index 79adabec9b773a62aa7561ed01f536355dca3224..d8c829740fa3f79ff6cb4cb40784c9cfc6776bf0 100644 (file)
@@ -31,7 +31,7 @@
 pub fn token_to_binop(tok: Token) -> Option<ast::binop> {
   match tok {
       BINOP(STAR)    => Some(mul),
-      BINOP(SLASH)   => Some(div),
+      BINOP(SLASH)   => Some(quot),
       BINOP(PERCENT) => Some(rem),
       // 'as' sits between here with 11
       BINOP(PLUS)    => Some(add),
index d8443f836f50a45f9807c1ce23ee9fde381047c5..d368f9d6769deb87d576a98104df6baac2e0aeba 100644 (file)
@@ -1,6 +1,6 @@
 enum test {
-    div_zero = 1/0, //~ERROR expected constant: divide by zero
-    rem_zero = 1%0  //~ERROR expected constant: modulo zero
+    quot_zero = 1/0, //~ERROR expected constant: quotient zero
+    rem_zero = 1%0  //~ERROR expected constant: remainder zero
 }
 
 fn main() {}
index 6bad7ab194acd901d3146e41a9d4874877a1c984..7a17dd024153c0cb963cf90ccdfd9f607424a189 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:divide by zero
+// error-pattern:quotient zero
 fn main() {
     let y = 0;
     let z = 1 / y;
index 05ff7bd96bdf84225a28b9e65532b0797127f88c..c379a8fc65fd799b4b5925756934531f98c6d140 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:modulo zero
+// error-pattern:remainder zero
 fn main() {
     let y = 0;
     let z = 1 % y;