]> git.lizzy.rs Git - rust.git/commitdiff
Revert rename of Div to Quot
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>
Wed, 1 May 2013 05:40:05 +0000 (15:40 +1000)
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>
Wed, 1 May 2013 05:40:05 +0000 (15:40 +1000)
27 files changed:
doc/rust.md
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/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/num/bigint.rs
src/libstd/num/complex.rs
src/libstd/num/rational.rs
src/libsyntax/ast.rs
src/libsyntax/ast_util.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/test/compile-fail/eval-enum.rs
src/test/run-fail/divide-by-zero.rs

index 9f81b38009fe8784cec4346411e1b865c4a9ef86..e23613e149ce717320b244946e50a15c2e61cbc7 100644 (file)
@@ -1467,8 +1467,8 @@ A complete list of the built-in language items follows:
   : Elements can be subtracted.
 `mul`
   : Elements can be multiplied.
-`quot`
-  : Elements have a quotient operation.
+`div`
+  : Elements have a division operation.
 `rem`
   : Elements have a remainder operation.
 `neg`
@@ -1857,7 +1857,7 @@ The default meaning of the operators on standard types is given here.
     Calls the `mul` method on the `core::ops::Mul` trait.
 `/`
   : Quotient.
-    Calls the `quot` method on the `core::ops::Quot` trait.
+    Calls the `div` method on the `core::ops::Div` trait.
 `%`
   : Remainder.
     Calls the `rem` method on the `core::ops::Rem` trait.
index f9a56f613d54276c7acb56b484abd6cf50e28a1d..26398f3fe52361f5149cbaa7ac4b8e25cd65739f 100644 (file)
@@ -78,7 +78,7 @@ pub use ops::{Drop};
 #[cfg(stage0)]
 pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
 #[cfg(not(stage0))]
-pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
+pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
 pub use ops::{BitAnd, BitOr, BitXor};
 pub use ops::{Shl, Shr, Index};
 
index e687f482fa98c1bfcb0f5ebfa52b5d835db445ee..04ddd63a177e74819e0871095c3fe82278320fb3 100644 (file)
@@ -123,7 +123,7 @@ fn tgamma(n: c_float) -> c_float = c_float_utils::tgamma
 pub fn mul(x: f32, y: f32) -> f32 { return x * y; }
 
 #[inline(always)]
-pub fn quot(x: f32, y: f32) -> f32 { return x / y; }
+pub fn div(x: f32, y: f32) -> f32 { return x / y; }
 
 #[inline(always)]
 pub fn rem(x: f32, y: f32) -> f32 { return x % y; }
@@ -279,16 +279,11 @@ impl Mul<f32,f32> for f32 {
     fn mul(&self, other: &f32) -> f32 { *self * *other }
 }
 
-#[cfg(stage0,notest)]
+#[cfg(notest)]
 impl Div<f32,f32> for f32 {
     #[inline(always)]
     fn div(&self, other: &f32) -> f32 { *self / *other }
 }
-#[cfg(not(stage0),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 {
index d00e6ae2c0d7936032aa8a761a83c1dbc24bd9d1..9f1944e3fad7fd3dc225ed66bb01bd9ee9f5ccc4 100644 (file)
@@ -149,7 +149,7 @@ fn yn(i: c_int, n: c_double) -> c_double = c_double_utils::yn
 pub fn mul(x: f64, y: f64) -> f64 { return x * y; }
 
 #[inline(always)]
-pub fn quot(x: f64, y: f64) -> f64 { return x / y; }
+pub fn div(x: f64, y: f64) -> f64 { return x / y; }
 
 #[inline(always)]
 pub fn rem(x: f64, y: f64) -> f64 { return x % y; }
@@ -296,15 +296,10 @@ fn sub(&self, other: &f64) -> f64 { *self - *other }
 impl Mul<f64,f64> for f64 {
     fn mul(&self, other: &f64) -> f64 { *self * *other }
 }
-#[cfg(stage0,notest)]
+#[cfg(notest)]
 impl Div<f64,f64> for f64 {
     fn div(&self, other: &f64) -> f64 { *self / *other }
 }
-#[cfg(not(stage0),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 }
index 3aa8848cdbed24be2d28062db49477b8bb5708d9..f163d67a69ccbb1636a9c8c1a33f4f7deff7d8d6 100644 (file)
@@ -25,7 +25,7 @@
 use num::{Zero, One, strconv};
 use prelude::*;
 
-pub use f64::{add, sub, mul, quot, rem, lt, le, eq, ne, ge, gt};
+pub use f64::{add, sub, mul, div, 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};
@@ -692,16 +692,12 @@ impl Mul<float,float> for float {
     fn mul(&self, other: &float) -> float { *self * *other }
 }
 
-#[cfg(stage0,notest)]
+#[cfg(notest)]
 impl Div<float,float> for float {
     #[inline(always)]
     fn div(&self, other: &float) -> float { *self / *other }
 }
-#[cfg(not(stage0),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 {
     #[inline(always)]
index ec38a32c039d6d9d142913e34869783383229e46..fadba84a0fe93fea461e7e87f7e5efc238b6767f 100644 (file)
@@ -30,7 +30,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 quot(x: T, y: T) -> T { x / y }
+pub fn div(x: T, y: T) -> T { x / y }
 
 ///
 /// Returns the remainder of y / x.
@@ -201,16 +201,11 @@ impl Mul<T,T> for T {
     fn mul(&self, other: &T) -> T { *self * *other }
 }
 
-#[cfg(stage0,notest)]
+#[cfg(notest)]
 impl Div<T,T> for T {
-    #[inline(always)]
-    fn div(&self, other: &T) -> T { *self / *other }
-}
-#[cfg(not(stage0),notest)]
-impl Quot<T,T> for T {
     ///
-    /// Returns the integer quotient, truncated towards 0. As this behaviour reflects
-    /// the underlying machine implementation it is more efficient than `Natural::div`.
+    /// Integer division, truncated towards 0. As this behaviour reflects the underlying
+    /// machine implementation it is more efficient than `Integer::div_floor`.
     ///
     /// # Examples
     ///
@@ -227,7 +222,7 @@ impl Quot<T,T> for T {
     /// ~~~
     ///
     #[inline(always)]
-    fn quot(&self, other: &T) -> T { *self / *other }
+    fn div(&self, other: &T) -> T { *self / *other }
 }
 
 #[cfg(stage0,notest)]
@@ -307,25 +302,25 @@ impl Integer for T {
     /// # Examples
     ///
     /// ~~~
-    /// assert!(( 8).div( 3) ==  2);
-    /// assert!(( 8).div(-3) == -3);
-    /// assert!((-8).div( 3) == -3);
-    /// assert!((-8).div(-3) ==  2);
+    /// assert!(( 8).div_floor( 3) ==  2);
+    /// assert!(( 8).div_floor(-3) == -3);
+    /// assert!((-8).div_floor( 3) == -3);
+    /// assert!((-8).div_floor(-3) ==  2);
     ///
-    /// assert!(( 1).div( 2) ==  0);
-    /// assert!(( 1).div(-2) == -1);
-    /// assert!((-1).div( 2) == -1);
-    /// assert!((-1).div(-2) ==  0);
+    /// assert!(( 1).div_floor( 2) ==  0);
+    /// assert!(( 1).div_floor(-2) == -1);
+    /// assert!((-1).div_floor( 2) == -1);
+    /// assert!((-1).div_floor(-2) ==  0);
     /// ~~~
     ///
     #[inline(always)]
-    fn div(&self, other: &T) -> T {
+    fn div_floor(&self, other: &T) -> T {
         // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
         // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
-        match self.quot_rem(other) {
-            (q, r) if (r > 0 && *other < 0)
-                   || (r < 0 && *other > 0) => q - 1,
-            (q, _)                          => q,
+        match self.div_rem(other) {
+            (d, r) if (r > 0 && *other < 0)
+                   || (r < 0 && *other > 0) => d - 1,
+            (d, _)                          => d,
         }
     }
 
@@ -333,25 +328,25 @@ fn div(&self, other: &T) -> T {
     /// Integer modulo, satisfying:
     ///
     /// ~~~
-    /// assert!(n.div(d) * d + n.modulo(d) == n)
+    /// assert!(n.div_floor(d) * d + n.mod_floor(d) == n)
     /// ~~~
     ///
     /// # Examples
     ///
     /// ~~~
-    /// assert!(( 8).modulo( 3) ==  2);
-    /// assert!(( 8).modulo(-3) == -1);
-    /// assert!((-8).modulo( 3) ==  1);
-    /// assert!((-8).modulo(-3) == -2);
+    /// assert!(( 8).mod_floor( 3) ==  2);
+    /// assert!(( 8).mod_floor(-3) == -1);
+    /// assert!((-8).mod_floor( 3) ==  1);
+    /// assert!((-8).mod_floor(-3) == -2);
     ///
-    /// assert!(( 1).modulo( 2) ==  1);
-    /// assert!(( 1).modulo(-2) == -1);
-    /// assert!((-1).modulo( 2) ==  1);
-    /// assert!((-1).modulo(-2) == -1);
+    /// assert!(( 1).mod_floor( 2) ==  1);
+    /// assert!(( 1).mod_floor(-2) == -1);
+    /// assert!((-1).mod_floor( 2) ==  1);
+    /// assert!((-1).mod_floor(-2) == -1);
     /// ~~~
     ///
     #[inline(always)]
-    fn modulo(&self, other: &T) -> T {
+    fn mod_floor(&self, other: &T) -> T {
         // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
         // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
         match *self % *other {
@@ -361,21 +356,21 @@ fn modulo(&self, other: &T) -> T {
         }
     }
 
-    /// Calculates `div` and `modulo` simultaneously
+    /// Calculates `div_floor` and `mod_floor` simultaneously
     #[inline(always)]
-    fn div_mod(&self, other: &T) -> (T,T) {
+    fn div_mod_floor(&self, other: &T) -> (T,T) {
         // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
         // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
-        match self.quot_rem(other) {
-            (q, r) if (r > 0 && *other < 0)
-                   || (r < 0 && *other > 0) => (q - 1, r + *other),
-            (q, r)                          => (q, r),
+        match self.div_rem(other) {
+            (d, r) if (r > 0 && *other < 0)
+                   || (r < 0 && *other > 0) => (d - 1, r + *other),
+            (d, r)                          => (d, r),
         }
     }
 
-    /// Calculates `quot` (`\`) and `rem` (`%`) simultaneously
+    /// Calculates `div` (`\`) and `rem` (`%`) simultaneously
     #[inline(always)]
-    fn quot_rem(&self, other: &T) -> (T,T) {
+    fn div_rem(&self, other: &T) -> (T,T) {
         (*self / *other, *self % *other)
     }
 
@@ -599,42 +594,42 @@ fn test_division_rule((n,d): (T,T), (q,r): (T,T)) {
     }
 
     #[test]
-    fn test_quot_rem() {
-        fn test_nd_qr(nd: (T,T), qr: (T,T)) {
+    fn test_div_rem() {
+        fn test_nd_dr(nd: (T,T), qr: (T,T)) {
             let (n,d) = nd;
-            let separate_quot_rem = (n / d, n % d);
-            let combined_quot_rem = n.quot_rem(&d);
+            let separate_div_rem = (n / d, n % d);
+            let combined_div_rem = n.div_rem(&d);
 
-            assert_eq!(separate_quot_rem, qr);
-            assert_eq!(combined_quot_rem, qr);
+            assert_eq!(separate_div_rem, qr);
+            assert_eq!(combined_div_rem, qr);
 
-            test_division_rule(nd, separate_quot_rem);
-            test_division_rule(nd, combined_quot_rem);
+            test_division_rule(nd, separate_div_rem);
+            test_division_rule(nd, combined_div_rem);
         }
 
-        test_nd_qr(( 8,  3), ( 2,  2));
-        test_nd_qr(( 8, -3), (-2,  2));
-        test_nd_qr((-8,  3), (-2, -2));
-        test_nd_qr((-8, -3), ( 2, -2));
+        test_nd_dr(( 8,  3), ( 2,  2));
+        test_nd_dr(( 8, -3), (-2,  2));
+        test_nd_dr((-8,  3), (-2, -2));
+        test_nd_dr((-8, -3), ( 2, -2));
 
-        test_nd_qr(( 1,  2), ( 0,  1));
-        test_nd_qr(( 1, -2), ( 0,  1));
-        test_nd_qr((-1,  2), ( 0, -1));
-        test_nd_qr((-1, -2), ( 0, -1));
+        test_nd_dr(( 1,  2), ( 0,  1));
+        test_nd_dr(( 1, -2), ( 0,  1));
+        test_nd_dr((-1,  2), ( 0, -1));
+        test_nd_dr((-1, -2), ( 0, -1));
     }
 
     #[test]
-    fn test_div_mod() {
+    fn test_div_mod_floor() {
         fn test_nd_dm(nd: (T,T), dm: (T,T)) {
             let (n,d) = nd;
-            let separate_div_mod = (n.div(&d), n.modulo(&d));
-            let combined_div_mod = n.div_mod(&d);
+            let separate_div_mod_floor = (n.div_floor(&d), n.mod_floor(&d));
+            let combined_div_mod_floor = n.div_mod_floor(&d);
 
-            assert_eq!(separate_div_mod, dm);
-            assert_eq!(combined_div_mod, dm);
+            assert_eq!(separate_div_mod_floor, dm);
+            assert_eq!(combined_div_mod_floor, dm);
 
-            test_division_rule(nd, separate_div_mod);
-            test_division_rule(nd, combined_div_mod);
+            test_division_rule(nd, separate_div_mod_floor);
+            test_division_rule(nd, combined_div_mod_floor);
         }
 
         test_nd_dm(( 8,  3), ( 2,  2));
index 3e43ebfef12228152ba43c8a5eb09a24cabba120..b8f47db7d128e791c20cd0d2ce55c068ab346870 100644 (file)
 //! An interface for numeric types
 use cmp::{Eq, Ord};
 #[cfg(stage0)]
-use ops::{Add, Sub, Mul, Neg};
-#[cfg(stage0)]
-use Quot = ops::Div;
+use ops::{Add, Sub, Mul, Div, Neg};
 #[cfg(stage0)]
 use Rem = ops::Modulo;
 #[cfg(not(stage0))]
-use ops::{Add, Sub, Mul, Quot, Rem, Neg};
+use ops::{Add, Sub, Mul, Div, Rem, Neg};
 use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
 use option::Option;
 use kinds::Copy;
@@ -32,7 +30,7 @@ pub trait Num: Eq + Zero + One
              + Add<Self,Self>
              + Sub<Self,Self>
              + Mul<Self,Self>
-             + Quot<Self,Self>
+             + Div<Self,Self>
              + Rem<Self,Self> {}
 
 pub trait IntConvertible {
@@ -76,12 +74,13 @@ pub fn abs<T:Ord + Zero + Neg<T>>(v: T) -> T {
 
 pub trait Integer: Num
                  + Orderable
-                 + Quot<Self,Self>
+                 + Div<Self,Self>
                  + Rem<Self,Self> {
-    fn div(&self, other: &Self) -> Self;
-    fn modulo(&self, other: &Self) -> Self;
-    fn div_mod(&self, other: &Self) -> (Self,Self);
-    fn quot_rem(&self, other: &Self) -> (Self,Self);
+    fn div_rem(&self, other: &Self) -> (Self,Self);
+
+    fn div_floor(&self, other: &Self) -> Self;
+    fn mod_floor(&self, other: &Self) -> Self;
+    fn div_mod_floor(&self, other: &Self) -> (Self,Self);
 
     fn gcd(&self, other: &Self) -> Self;
     fn lcm(&self, other: &Self) -> Self;
@@ -102,7 +101,7 @@ pub trait Round {
 pub trait Fractional: Num
                     + Orderable
                     + Round
-                    + Quot<Self,Self> {
+                    + Div<Self,Self> {
     fn recip(&self) -> Self;
 }
 
@@ -226,7 +225,7 @@ pub trait Primitive: Num
                    + Add<Self,Self>
                    + Sub<Self,Self>
                    + Mul<Self,Self>
-                   + Quot<Self,Self>
+                   + Div<Self,Self>
                    + Rem<Self,Self> {
     // FIXME (#5527): These should be associated constants
     fn bits() -> uint;
@@ -371,7 +370,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+Quot<T,T>+Mul<T,T>>(
+pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(
     radix: uint, pow: uint) -> T {
     let _0: T = Zero::zero();
     let _1: T = One::one();
@@ -413,13 +412,13 @@ pub 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.div(&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.div(&two), ten / two);
     assert_eq!(ten.rem(&two),  ten % two);
 }
 
index 2f3cd92dac09e7b201260552e0b012876e34a7e1..68e3b407a8bc2650fc2710ce18341e69f6109331 100644 (file)
 
 use core::cmp::{Ord, Eq};
 #[cfg(stage0)]
-use ops::{Add, Sub, Mul, Neg};
-#[cfg(stage0)]
-use Quot = ops::Div;
+use ops::{Add, Sub, Mul, Div, Neg};
 #[cfg(stage0)]
 use Rem = ops::Modulo;
 #[cfg(stage1)]
 #[cfg(stage2)]
 #[cfg(stage3)]
-use ops::{Add, Sub, Mul, Quot, Rem, Neg};
+use ops::{Add, Sub, Mul, Div, Rem, Neg};
 use option::{None, Option, Some};
 use char;
 use str;
@@ -67,7 +65,7 @@ fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool {
 }
 
 #[inline(always)]
-fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Quot<T,T>>(num: &T) -> bool {
+fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool {
     let _0: T = Zero::zero();
     let _1: T = One::one();
 
@@ -180,7 +178,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+
-                                  Quot<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
+                                  Div<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 {
@@ -388,7 +386,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+
-                            Quot<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
+                            Div<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,
@@ -441,7 +439,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+Quot<T,T>+
+pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
                                     Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
                                     NumStrConv>(
         buf: &[u8], radix: uint, negative: bool, fractional: bool,
@@ -638,7 +636,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Quot<T,T>+
  * `from_str_bytes_common()`, for details see there.
  */
 #[inline(always)]
-pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Quot<T,T>+Mul<T,T>+
+pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<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 3dfdd22c42dc1996a993865626a555fba5c52516..f6b98989545d05d5ca43e370bcf40afd04f0afb0 100644 (file)
@@ -31,7 +31,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 quot(x: T, y: T) -> T { x / y }
+pub fn div(x: T, y: T) -> T { x / y }
 #[inline(always)]
 pub fn rem(x: T, y: T) -> T { x % y }
 
@@ -166,16 +166,11 @@ impl Mul<T,T> for T {
     fn mul(&self, other: &T) -> T { *self * *other }
 }
 
-#[cfg(stage0,notest)]
+#[cfg(notest)]
 impl Div<T,T> for T {
     #[inline(always)]
     fn div(&self, other: &T) -> T { *self / *other }
 }
-#[cfg(not(stage0),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 {
@@ -197,23 +192,23 @@ fn neg(&self) -> T { -*self }
 impl Unsigned for T {}
 
 impl Integer for T {
-    /// Unsigned integer division. Returns the same result as `quot` (`/`).
+    /// Calculates `div` (`\`) and `rem` (`%`) simultaneously
     #[inline(always)]
-    fn div(&self, other: &T) -> T { *self / *other }
+    fn div_rem(&self, other: &T) -> (T,T) {
+        (*self / *other, *self % *other)
+    }
 
-    /// Unsigned integer modulo operation. Returns the same result as `rem` (`%`).
+    /// Unsigned integer division. Returns the same result as `div` (`/`).
     #[inline(always)]
-    fn modulo(&self, other: &T) -> T { *self / *other }
+    fn div_floor(&self, other: &T) -> T { *self / *other }
 
-    /// Calculates `div` and `modulo` simultaneously
+    /// Unsigned integer modulo operation. Returns the same result as `rem` (`%`).
     #[inline(always)]
-    fn div_mod(&self, other: &T) -> (T,T) {
-        (*self / *other, *self % *other)
-    }
+    fn mod_floor(&self, other: &T) -> T { *self / *other }
 
-    /// Calculates `quot` (`\`) and `rem` (`%`) simultaneously
+    /// Calculates `div_floor` and `modulo_floor` simultaneously
     #[inline(always)]
-    fn quot_rem(&self, other: &T) -> (T,T) {
+    fn div_mod_floor(&self, other: &T) -> (T,T) {
         (*self / *other, *self % *other)
     }
 
index 1aa7aada05c886b481e694b5044a5a06bc036966..5ba860c89c9b915e0d3f999480ea9caed60233f0 100644 (file)
@@ -31,15 +31,9 @@ pub trait Mul<RHS,Result> {
 }
 
 #[lang="div"]
-#[cfg(stage0)]
 pub trait Div<RHS,Result> {
     fn div(&self, rhs: &RHS) -> Result;
 }
-#[lang="quot"]
-#[cfg(not(stage0))]
-pub trait Quot<RHS,Result> {
-    fn quot(&self, rhs: &RHS) -> Result;
-}
 
 #[lang="modulo"]
 #[cfg(stage0)]
index 9a2e480ce6e543b5e6703e38363c838676ca1a1f..4527fcf2923da0102de0e973cbd4d702e4925fcf 100644 (file)
@@ -17,7 +17,7 @@
 #[cfg(stage0)]
 pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
 #[cfg(not(stage0))]
-pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
+pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
 pub use ops::{BitAnd, BitOr, BitXor};
 pub use ops::{Drop};
 pub use ops::{Shl, Shr, Index};
index bba4d35b5604620dec2c0300b71f5901d4dbd1a4..86b7379bb698ddb5a0e738bf70896e0b15996a45 100644 (file)
@@ -279,7 +279,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)),
-              quot => Ok(const_float(a / b)),
+              div => Ok(const_float(a / b)),
               rem => Ok(const_float(a % b)),
               eq => fromb(a == b),
               lt => fromb(a < b),
@@ -295,8 +295,8 @@ 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)),
-              quot if b == 0 => Err(~"attempted quotient with a divisor of zero"),
-              quot => Ok(const_int(a / b)),
+              div if b == 0 => Err(~"attempted to divide by zero"),
+              div => Ok(const_int(a / b)),
               rem if b == 0 => Err(~"attempted remainder with a divisor of zero"),
               rem => Ok(const_int(a % b)),
               and | bitand => Ok(const_int(a & b)),
@@ -317,8 +317,8 @@ 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)),
-              quot if b == 0 => Err(~"attempted quotient with a divisor of zero"),
-              quot => Ok(const_uint(a / b)),
+              div if b == 0 => Err(~"attempted to divide by zero"),
+              div => Ok(const_uint(a / b)),
               rem if b == 0 => Err(~"attempted remainder with a divisor of zero"),
               rem => Ok(const_uint(a % b)),
               and | bitand => Ok(const_uint(a & b)),
index 2de12b9eb9746ec7e9c0213cf12f54d304fb34dd..7298064e1c00d598335fb5dc00e6edefcc8d697d 100644 (file)
@@ -42,7 +42,7 @@ pub enum LangItem {
     AddTraitLangItem,           // 5
     SubTraitLangItem,           // 6
     MulTraitLangItem,           // 7
-    QuotTraitLangItem,          // 8
+    DivTraitLangItem,           // 8
     RemTraitLangItem,           // 9
     NegTraitLangItem,           // 10
     NotTraitLangItem,           // 11
@@ -105,7 +105,7 @@ pub fn item_name(index: uint) -> &'static str {
             5  => "add",
             6  => "sub",
             7  => "mul",
-            8  => "quot",
+            8  => "div",
             9  => "rem",
             10 => "neg",
             11 => "not",
@@ -167,8 +167,8 @@ pub fn sub_trait(&const self) -> def_id {
     pub fn mul_trait(&const self) -> def_id {
         self.items[MulTraitLangItem as uint].get()
     }
-    pub fn quot_trait(&const self) -> def_id {
-        self.items[QuotTraitLangItem as uint].get()
+    pub fn div_trait(&const self) -> def_id {
+        self.items[DivTraitLangItem as uint].get()
     }
     pub fn rem_trait(&const self) -> def_id {
         self.items[RemTraitLangItem as uint].get()
@@ -268,7 +268,7 @@ 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(@~"quot", QuotTraitLangItem as uint);
+    item_refs.insert(@~"div", DivTraitLangItem as uint);
     item_refs.insert(@~"rem", RemTraitLangItem as uint);
     item_refs.insert(@~"neg", NegTraitLangItem as uint);
     item_refs.insert(@~"not", NotTraitLangItem as uint);
index 294a21fac2c237271e11f15f6cfee848a7056812..d8ad53212e2b7797aa1bd0270ae594f26b654e29 100644 (file)
@@ -33,7 +33,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, quot, eq};
+use syntax::ast::{def_upvar, def_use, def_variant, div, 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};
@@ -4901,9 +4901,9 @@ 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(quot, _, _) | expr_assign_op(quot, _, _) => {
+            expr_binary(div, _, _) | expr_assign_op(div, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
-                                              self.lang_items.quot_trait());
+                                              self.lang_items.div_trait());
             }
             expr_binary(rem, _, _) | expr_assign_op(rem, _, _) => {
                 self.add_fixed_trait_for_expr(expr.id,
index efa10dfc2aa34db55b5e887c09e5eed3d03767db..262196ffffd5c07a564ac4b355df24746509a2ca 100644 (file)
@@ -777,10 +777,10 @@ pub fn cast_shift_rhs(op: ast::binop,
     }
 }
 
-pub fn fail_if_zero(cx: block, span: span, quotrem: ast::binop,
+pub fn fail_if_zero(cx: block, span: span, divrem: ast::binop,
                     rhs: ValueRef, rhs_t: ty::t) -> block {
-    let text = if quotrem == ast::quot {
-        @~"attempted quotient with a divisor of zero"
+    let text = if divrem == ast::div {
+        @~"attempted to divide by zero"
     } else {
         @~"attempted remainder with a divisor of zero"
     };
index 25f34b8eaa9d1e97f1a3fe114e415870e34c1bb6..c6c5561854c0dccb5804a0583545a9ec726fafda 100644 (file)
@@ -270,7 +270,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
                 if is_float { llvm::LLVMConstFMul(te1, te2) }
                 else        { llvm::LLVMConstMul(te1, te2) }
               }
-              ast::quot   => {
+              ast::div    => {
                 if is_float    { llvm::LLVMConstFDiv(te1, te2) }
                 else if signed { llvm::LLVMConstSDiv(te1, te2) }
                 else           { llvm::LLVMConstUDiv(te1, te2) }
index f83562add31691bd413e6a3253ef4078af56a625..ae510ae6d114f15e0a7d716754e1ec4bb830b450 100644 (file)
@@ -1435,7 +1435,7 @@ fn trans_eager_binop(bcx: block,
         if is_float { FMul(bcx, lhs, rhs) }
         else { Mul(bcx, lhs, rhs) }
       }
-      ast::quot => {
+      ast::div => {
         if is_float {
             FDiv(bcx, lhs, rhs)
         } else {
index c7fb1e94adf4cea2f010d754d12ea81c35bc441a..4280cd4000d818715c4dc0ecfd6977d440267771 100644 (file)
@@ -4134,7 +4134,7 @@ fn opcat(op: ast::binop) -> int {
           ast::add => opcat_add,
           ast::subtract => opcat_sub,
           ast::mul => opcat_mult,
-          ast::quot => opcat_mult,
+          ast::div => opcat_mult,
           ast::rem => opcat_mult,
           ast::and => opcat_logic,
           ast::or => opcat_logic,
index e010340b94d8e200b905b1635eb0a2e1eb038947..fa9d6318cc9473c76ea62d81a269ac0ca2c20a6e 100644 (file)
@@ -293,10 +293,10 @@ fn sub_sign(a: BigUint, b: BigUint) -> (Ordering, BigUint) {
     }
 }
 
-impl Quot<BigUint, BigUint> for BigUint {
+impl Div<BigUint, BigUint> for BigUint {
     #[inline(always)]
-    fn quot(&self, other: &BigUint) -> BigUint {
-        let (q, _) = self.quot_rem(other);
+    fn div(&self, other: &BigUint) -> BigUint {
+        let (q, _) = self.div_rem(other);
         return q;
     }
 }
@@ -304,7 +304,7 @@ fn quot(&self, other: &BigUint) -> BigUint {
 impl Rem<BigUint, BigUint> for BigUint {
     #[inline(always)]
     fn rem(&self, other: &BigUint) -> BigUint {
-        let (_, r) = self.quot_rem(other);
+        let (_, r) = self.div_rem(other);
         return r;
     }
 }
@@ -316,19 +316,24 @@ fn neg(&self) -> BigUint { fail!() }
 
 impl Integer for BigUint {
     #[inline(always)]
-    fn div(&self, other: &BigUint) -> BigUint {
-        let (d, _) = self.div_mod(other);
+    fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint) {
+        self.div_mod_floor(other)
+    }
+
+    #[inline(always)]
+    fn div_floor(&self, other: &BigUint) -> BigUint {
+        let (d, _) = self.div_mod_floor(other);
         return d;
     }
 
     #[inline(always)]
-    fn modulo(&self, other: &BigUint) -> BigUint {
-        let (_, m) = self.div_mod(other);
+    fn mod_floor(&self, other: &BigUint) -> BigUint {
+        let (_, m) = self.div_mod_floor(other);
         return m;
     }
 
     #[inline(always)]
-    fn div_mod(&self, other: &BigUint) -> (BigUint, BigUint) {
+    fn div_mod_floor(&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()); }
@@ -346,11 +351,11 @@ fn div_mod(&self, other: &BigUint) -> (BigUint, BigUint) {
             shift += 1;
         }
         assert!(shift < BigDigit::bits);
-        let (d, m) = div_mod_inner(self << shift, other << shift);
+        let (d, m) = div_mod_floor_inner(self << shift, other << shift);
         return (d, m >> shift);
 
         #[inline(always)]
-        fn div_mod_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) {
+        fn div_mod_floor_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) {
             let mut m = a;
             let mut d = Zero::zero::<BigUint>();
             let mut n = 1;
@@ -409,11 +414,6 @@ fn div_estimate(a: &BigUint, b: &BigUint, n: uint)
         }
     }
 
-    #[inline(always)]
-    fn quot_rem(&self, other: &BigUint) -> (BigUint, BigUint) {
-        self.div_mod(other)
-    }
-
     /**
      * Calculates the Greatest Common Divisor (GCD) of the number and `other`
      *
@@ -485,7 +485,7 @@ fn convert_base(n: BigUint, base: uint) -> ~[BigDigit] {
             let mut result = ~[];
             let mut m      = n;
             while m > divider {
-                let (d, m0) = m.div_mod(&divider);
+                let (d, m0) = m.div_mod_floor(&divider);
                 result += [m0.to_uint() as BigDigit];
                 m = d;
             }
@@ -894,10 +894,10 @@ fn mul(&self, other: &BigInt) -> BigInt {
     }
 }
 
-impl Quot<BigInt, BigInt> for BigInt {
+impl Div<BigInt, BigInt> for BigInt {
     #[inline(always)]
-    fn quot(&self, other: &BigInt) -> BigInt {
-        let (q, _) = self.quot_rem(other);
+    fn div(&self, other: &BigInt) -> BigInt {
+        let (q, _) = self.div_rem(other);
         return q;
     }
 }
@@ -905,7 +905,7 @@ fn quot(&self, other: &BigInt) -> BigInt {
 impl Rem<BigInt, BigInt> for BigInt {
     #[inline(always)]
     fn rem(&self, other: &BigInt) -> BigInt {
-        let (_, r) = self.quot_rem(other);
+        let (_, r) = self.div_rem(other);
         return r;
     }
 }
@@ -919,21 +919,36 @@ fn neg(&self) -> BigInt {
 
 impl Integer for BigInt {
     #[inline(always)]
-    fn div(&self, other: &BigInt) -> BigInt {
-        let (d, _) = self.div_mod(other);
+    fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt) {
+        // r.sign == self.sign
+        let (d_ui, r_ui) = self.data.div_mod_floor(&other.data);
+        let d = BigInt::from_biguint(Plus, d_ui);
+        let r = BigInt::from_biguint(Plus, r_ui);
+        match (self.sign, other.sign) {
+            (_,    Zero)   => fail!(),
+            (Plus, Plus)  | (Zero, Plus)  => ( d,  r),
+            (Plus, Minus) | (Zero, Minus) => (-d,  r),
+            (Minus, Plus)                 => (-d, -r),
+            (Minus, Minus)                => ( d, -r)
+        }
+    }
+
+    #[inline(always)]
+    fn div_floor(&self, other: &BigInt) -> BigInt {
+        let (d, _) = self.div_mod_floor(other);
         return d;
     }
 
     #[inline(always)]
-    fn modulo(&self, other: &BigInt) -> BigInt {
-        let (_, m) = self.div_mod(other);
+    fn mod_floor(&self, other: &BigInt) -> BigInt {
+        let (_, m) = self.div_mod_floor(other);
         return m;
     }
 
     #[inline(always)]
-    fn div_mod(&self, other: &BigInt) -> (BigInt, BigInt) {
+    fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt) {
         // m.sign == other.sign
-        let (d_ui, m_ui) = self.data.quot_rem(&other.data);
+        let (d_ui, m_ui) = self.data.div_rem(&other.data);
         let d = BigInt::from_biguint(Plus, d_ui),
             m = BigInt::from_biguint(Plus, m_ui);
         match (self.sign, other.sign) {
@@ -953,21 +968,6 @@ fn div_mod(&self, other: &BigInt) -> (BigInt, BigInt) {
         }
     }
 
-    #[inline(always)]
-    fn quot_rem(&self, other: &BigInt) -> (BigInt, BigInt) {
-        // r.sign == self.sign
-        let (q_ui, r_ui) = self.data.div_mod(&other.data);
-        let q = BigInt::from_biguint(Plus, q_ui);
-        let r = BigInt::from_biguint(Plus, r_ui);
-        match (self.sign, other.sign) {
-            (_,    Zero)   => fail!(),
-            (Plus, Plus)  | (Zero, Plus)  => ( q,  r),
-            (Plus, Minus) | (Zero, Minus) => (-q,  r),
-            (Minus, Plus)                 => (-q, -r),
-            (Minus, Minus)                => ( q, -r)
-        }
-    }
-
     /**
      * Calculates the Greatest Common Divisor (GCD) of the number and `other`
      *
@@ -1100,8 +1100,6 @@ fn to_uint(&self) -> uint {
 
 #[cfg(test)]
 mod biguint_tests {
-
-    use core::*;
     use core::num::{IntConvertible, Zero, One, FromStrRadix};
     use core::cmp::{Less, Equal, Greater};
     use super::{BigUint, BigDigit};
@@ -1347,7 +1345,7 @@ fn test_sub() {
         (&[ 0,  0,  1],     &[ 0,  0,  0,  1], &[0, 0,  0,  0,  0,  1])
     ];
 
-    static quot_rem_quadruples: &'static [(&'static [BigDigit],
+    static div_rem_quadruples: &'static [(&'static [BigDigit],
                                            &'static [BigDigit],
                                            &'static [BigDigit],
                                            &'static [BigDigit])]
@@ -1371,7 +1369,7 @@ fn test_mul() {
             assert!(b * a == c);
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigUint::from_slice(aVec);
             let b = BigUint::from_slice(bVec);
@@ -1384,7 +1382,7 @@ fn test_mul() {
     }
 
     #[test]
-    fn test_quot_rem() {
+    fn test_div_rem() {
         for mul_triples.each |elm| {
             let (aVec, bVec, cVec) = *elm;
             let a = BigUint::from_slice(aVec);
@@ -1392,21 +1390,21 @@ fn test_quot_rem() {
             let c = BigUint::from_slice(cVec);
 
             if !a.is_zero() {
-                assert!(c.quot_rem(&a) == (copy b, Zero::zero()));
+                assert!(c.div_rem(&a) == (copy b, Zero::zero()));
             }
             if !b.is_zero() {
-                assert!(c.quot_rem(&b) == (copy a, Zero::zero()));
+                assert!(c.div_rem(&b) == (copy a, Zero::zero()));
             }
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_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_zero() { assert!(a.quot_rem(&b) == (c, d)); }
+            if !b.is_zero() { assert!(a.div_rem(&b) == (c, d)); }
         }
     }
 
@@ -1558,7 +1556,6 @@ fn check(n: uint, s: &str) {
 #[cfg(test)]
 mod bigint_tests {
     use super::{BigInt, BigUint, BigDigit, Sign, Minus, Zero, Plus};
-    use core::*;
     use core::cmp::{Less, Equal, Greater};
     use core::num::{IntConvertible, Zero, One, FromStrRadix};
 
@@ -1750,10 +1747,10 @@ fn test_sub() {
         (&[ 0,  0,  1],     &[ 0,  0,  0,  1], &[0, 0,  0,  0,  0,  1])
     ];
 
-    static quot_rem_quadruples: &'static [(&'static [BigDigit],
-                                           &'static [BigDigit],
-                                           &'static [BigDigit],
-                                           &'static [BigDigit])]
+    static div_rem_quadruples: &'static [(&'static [BigDigit],
+                                          &'static [BigDigit],
+                                          &'static [BigDigit],
+                                          &'static [BigDigit])]
         = &[
             (&[ 1],        &[ 2], &[],               &[1]),
             (&[ 1,  1],    &[ 2], &[-1/2+1],         &[1]),
@@ -1777,7 +1774,7 @@ fn test_mul() {
             assert!((-b) * a == -c);
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigInt::from_slice(Plus, aVec);
             let b = BigInt::from_slice(Plus, bVec);
@@ -1790,9 +1787,9 @@ fn test_mul() {
     }
 
     #[test]
-    fn test_div_mod() {
+    fn test_div_mod_floor() {
         fn check_sub(a: &BigInt, b: &BigInt, ans_d: &BigInt, ans_m: &BigInt) {
-            let (d, m) = a.div_mod(b);
+            let (d, m) = a.div_mod_floor(b);
             if !m.is_zero() {
                 assert!(m.sign == b.sign);
             }
@@ -1826,7 +1823,7 @@ fn check(a: &BigInt, b: &BigInt, d: &BigInt, m: &BigInt) {
             if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_rem_quadruples.each |elm| {
             let (aVec, bVec, cVec, dVec) = *elm;
             let a = BigInt::from_slice(Plus, aVec);
             let b = BigInt::from_slice(Plus, bVec);
@@ -1841,9 +1838,9 @@ fn check(a: &BigInt, b: &BigInt, d: &BigInt, m: &BigInt) {
 
 
     #[test]
-    fn test_quot_rem() {
+    fn test_div_rem() {
         fn check_sub(a: &BigInt, b: &BigInt, ans_q: &BigInt, ans_r: &BigInt) {
-            let (q, r) = a.quot_rem(b);
+            let (q, r) = a.div_rem(b);
             if !r.is_zero() {
                 assert!(r.sign == a.sign);
             }
@@ -1869,7 +1866,7 @@ fn check(a: &BigInt, b: &BigInt, q: &BigInt, r: &BigInt) {
             if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
         }
 
-        for quot_rem_quadruples.each |elm| {
+        for div_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 02393b15cca0f492968eaebec214fdcd94bd582b..41d2b4a101cd5acb4c4f3087c71494c485a7120d 100644 (file)
@@ -102,9 +102,9 @@ 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 + Num> Quot<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
+impl<T: Copy + Num> Div<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
     #[inline]
-    fn quot(&self, other: &Cmplx<T>) -> Cmplx<T> {
+    fn div(&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)
@@ -275,7 +275,7 @@ fn test_mul() {
             }
         }
         #[test]
-        fn test_quot() {
+        fn test_div() {
             assert_eq!(_neg1_1i / _0_1i, _1_1i);
             for all_consts.each |&c| {
                 if c != Zero::zero() {
index a7c170c1cd6da20ffa6d2a7884274a24b21a484d..9b92b7241b99007839e9049442eeb06a5383110c 100644 (file)
@@ -143,9 +143,9 @@ fn mul(&self, rhs: &Ratio<T>) -> Ratio<T> {
 
 // (a/b) / (c/d) = (a*d)/(b*c)
 impl<T: Copy + Num + Ord>
-    Quot<Ratio<T>,Ratio<T>> for Ratio<T> {
+    Div<Ratio<T>,Ratio<T>> for Ratio<T> {
     #[inline]
-    fn quot(&self, rhs: &Ratio<T>) -> Ratio<T> {
+    fn div(&self, rhs: &Ratio<T>) -> Ratio<T> {
         Ratio::new(self.numer * rhs.denom, self.denom * rhs.numer)
     }
 }
@@ -395,7 +395,7 @@ fn test_mul() {
         }
 
         #[test]
-        fn test_quot() {
+        fn test_div() {
             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);
@@ -424,7 +424,7 @@ fn test_zero() {
         }
         #[test]
         #[should_fail]
-        fn test_quot_0() {
+        fn test_div_0() {
             let _a =  _1 / _0;
         }
     }
index ba6fe1cda4f31b83eba478a36d0d186ab7f1d44c..5690502c811fe83b3634cb611b294e316b469f1a 100644 (file)
@@ -389,7 +389,7 @@ pub enum binop {
     add,
     subtract,
     mul,
-    quot,
+    div,
     rem,
     and,
     or,
index 148b713a4f58f388adc0dcbb8aa34d0d66828372..0ffeb684dc051b55f54a2954b6dcd458f673b538 100644 (file)
@@ -73,7 +73,7 @@ pub fn binop_to_str(op: binop) -> ~str {
       add => return ~"+",
       subtract => return ~"-",
       mul => return ~"*",
-      quot => return ~"/",
+      div => return ~"/",
       rem => return ~"%",
       and => return ~"&&",
       or => return ~"||",
@@ -96,7 +96,7 @@ pub fn binop_to_method_name(op: binop) -> Option<~str> {
       add => return Some(~"add"),
       subtract => return Some(~"sub"),
       mul => return Some(~"mul"),
-      quot => return Some(~"quot"),
+      div => return Some(~"div"),
       rem => return Some(~"rem"),
       bitxor => return Some(~"bitxor"),
       bitand => return Some(~"bitand"),
@@ -341,7 +341,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 | quot | rem   => 12u,
+      mul | div | rem   => 12u,
       // 'as' sits between here with 11
       add | subtract    => 10u,
       shl | shr         =>  9u,
index 50bdfb2f557263baba00cf0339e364be1ee5e841..42c6fad64636413741eff826a90ff15b32889cb1 100644 (file)
@@ -19,7 +19,7 @@
 use ast::{bind_by_copy, bitand, bitor, bitxor, blk};
 use ast::{blk_check_mode, box};
 use ast::{crate, crate_cfg, decl, decl_item};
-use ast::{decl_local, default_blk, deref, quot, enum_def};
+use ast::{decl_local, default_blk, deref, div, enum_def};
 use ast::{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};
@@ -1836,7 +1836,7 @@ fn parse_assign_expr(&self) -> @expr {
                   token::PLUS => aop = add,
                   token::MINUS => aop = subtract,
                   token::STAR => aop = mul,
-                  token::SLASH => aop = quot,
+                  token::SLASH => aop = div,
                   token::PERCENT => aop = rem,
                   token::CARET => aop = bitxor,
                   token::AND => aop = bitand,
index 0327a3b80da87967f34524d4870d3eceb23c761b..9426e9abab3b47fe26b9f11ae6998feca649f631 100644 (file)
@@ -371,7 +371,7 @@ fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
 pub fn token_to_binop(tok: Token) -> Option<ast::binop> {
   match tok {
       BINOP(STAR)    => Some(ast::mul),
-      BINOP(SLASH)   => Some(ast::quot),
+      BINOP(SLASH)   => Some(ast::div),
       BINOP(PERCENT) => Some(ast::rem),
       BINOP(PLUS)    => Some(ast::add),
       BINOP(MINUS)   => Some(ast::subtract),
index 0123341957903dccea3c47c4cd6e58cbd4b8d6f9..f92dad961d1344b7b713338b639637ffa6791c3e 100644 (file)
@@ -1,5 +1,5 @@
 enum test {
-    quot_zero = 1/0, //~ERROR expected constant: attempted quotient with a divisor of zero
+    div_zero = 1/0, //~ERROR expected constant: attempted to divide by zero
     rem_zero = 1%0  //~ERROR expected constant: attempted remainder with a divisor of zero
 }
 
index d4f3828ea7174e01d8c31d2432e7768c49cd35cf..9c996807ad8668e1fdf8e9cc87aac5c174b77da6 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:attempted quotient with a divisor of zero
+// error-pattern:attempted to divide by zero
 fn main() {
     let y = 0;
     let z = 1 / y;