summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorBjörn Steinbrink <bsteinbr@gmail.com>2013-05-06 00:18:51 +0200
committerBjörn Steinbrink <bsteinbr@gmail.com>2013-05-14 16:36:23 +0200
commitbdc182cc41c2741edc6fdc4ec09b8522479aab40 (patch)
treee4d26bbc1b47702ef46cd01bbaa5b5dad8633416 /src/libcore/num
parent84745b483f322671f894b9e8d0a462c46275a9d3 (diff)
downloadrust-bdc182cc41c2741edc6fdc4ec09b8522479aab40.tar.gz
rust-bdc182cc41c2741edc6fdc4ec09b8522479aab40.zip
Use static string with fail!() and remove fail!(fmt!())
fail!() used to require owned strings but can handle static strings
now. Also, it can pass its arguments to fmt!() on its own, no need for
the caller to call fmt!() itself.
Diffstat (limited to 'src/libcore/num')
-rw-r--r--src/libcore/num/f32.rs2
-rw-r--r--src/libcore/num/f64.rs2
-rw-r--r--src/libcore/num/float.rs2
-rw-r--r--src/libcore/num/int-template.rs10
-rw-r--r--src/libcore/num/strconv.rs28
-rw-r--r--src/libcore/num/uint-template.rs10
6 files changed, 27 insertions, 27 deletions
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index 21e55af39eb..af30e87bb0c 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -772,7 +772,7 @@ pub fn to_str_hex(num: f32) -> ~str {
 pub fn to_str_radix(num: f32, rdx: uint) -> ~str {
     let (r, special) = strconv::to_str_common(
         &num, rdx, true, strconv::SignNeg, strconv::DigAll);
-    if special { fail!(~"number has a special value, \
+    if special { fail!("number has a special value, \
                       try to_str_radix_special() if those are expected") }
     r
 }
diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs
index 3c9df4040d8..240d84b8403 100644
--- a/src/libcore/num/f64.rs
+++ b/src/libcore/num/f64.rs
@@ -814,7 +814,7 @@ pub fn to_str_hex(num: f64) -> ~str {
 pub fn to_str_radix(num: f64, rdx: uint) -> ~str {
     let (r, special) = strconv::to_str_common(
         &num, rdx, true, strconv::SignNeg, strconv::DigAll);
-    if special { fail!(~"number has a special value, \
+    if special { fail!("number has a special value, \
                       try to_str_radix_special() if those are expected") }
     r
 }
diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs
index 22abc76c3d3..8b3c7b1e79e 100644
--- a/src/libcore/num/float.rs
+++ b/src/libcore/num/float.rs
@@ -133,7 +133,7 @@ pub fn to_str_hex(num: float) -> ~str {
 pub fn to_str_radix(num: float, radix: uint) -> ~str {
     let (r, special) = strconv::to_str_common(
         &num, radix, true, strconv::SignNeg, strconv::DigAll);
-    if special { fail!(~"number has a special value, \
+    if special { fail!("number has a special value, \
                          try to_str_radix_special() if those are expected") }
     r
 }
diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs
index f2bba6a4639..348f72f9f0a 100644
--- a/src/libcore/num/int-template.rs
+++ b/src/libcore/num/int-template.rs
@@ -89,7 +89,7 @@ pub fn gt(x: T, y: T) -> bool { x > y }
 pub fn _range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) -> bool {
     let mut i = start;
     if step == 0 {
-        fail!(~"range_step called with step == 0");
+        fail!("range_step called with step == 0");
     } else if step > 0 { // ascending
         while i < stop {
             if !it(i) { return false; }
@@ -923,16 +923,16 @@ mod tests {
 
         // None of the `fail`s should execute.
         for range(10,0) |_i| {
-            fail!(~"unreachable");
+            fail!("unreachable");
         }
         for range_rev(0,10) |_i| {
-            fail!(~"unreachable");
+            fail!("unreachable");
         }
         for range_step(10,0,1) |_i| {
-            fail!(~"unreachable");
+            fail!("unreachable");
         }
         for range_step(0,10,-1) |_i| {
-            fail!(~"unreachable");
+            fail!("unreachable");
         }
     }
 
diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs
index 5ed99a83995..044b0d4a36c 100644
--- a/src/libcore/num/strconv.rs
+++ b/src/libcore/num/strconv.rs
@@ -178,11 +178,11 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
         num: &T, radix: uint, negative_zero: bool,
         sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) {
     if (radix as int) < 2 {
-        fail!(fmt!("to_str_bytes_common: radix %? to low, \
-                   must lie in the range [2, 36]", radix));
+        fail!("to_str_bytes_common: radix %? to low, \
+                   must lie in the range [2, 36]", radix);
     } else if radix as int > 36 {
-        fail!(fmt!("to_str_bytes_common: radix %? to high, \
-                   must lie in the range [2, 36]", radix));
+        fail!("to_str_bytes_common: radix %? to high, \
+                   must lie in the range [2, 36]", radix);
     }
 
     let _0: T = Zero::zero();
@@ -444,20 +444,20 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
         ) -> Option<T> {
     match exponent {
         ExpDec if radix >= DIGIT_E_RADIX       // decimal exponent 'e'
-          => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \
-                        use of 'e' as decimal exponent", radix)),
+          => fail!("from_str_bytes_common: radix %? incompatible with \
+                        use of 'e' as decimal exponent", radix),
         ExpBin if radix >= DIGIT_P_RADIX       // binary exponent 'p'
-          => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \
-                        use of 'p' as binary exponent", radix)),
+          => fail!("from_str_bytes_common: radix %? incompatible with \
+                        use of 'p' as binary exponent", radix),
         _ if special && radix >= DIGIT_I_RADIX // first digit of 'inf'
-          => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \
-                        special values 'inf' and 'NaN'", radix)),
+          => fail!("from_str_bytes_common: radix %? incompatible with \
+                        special values 'inf' and 'NaN'", radix),
         _ if (radix as int) < 2
-          => fail!(fmt!("from_str_bytes_common: radix %? to low, \
-                        must lie in the range [2, 36]", radix)),
+          => fail!("from_str_bytes_common: radix %? to low, \
+                        must lie in the range [2, 36]", radix),
         _ if (radix as int) > 36
-          => fail!(fmt!("from_str_bytes_common: radix %? to high, \
-                        must lie in the range [2, 36]", radix)),
+          => fail!("from_str_bytes_common: radix %? to high, \
+                        must lie in the range [2, 36]", radix),
         _ => ()
     }
 
diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs
index 1c115ee5072..da0815c264b 100644
--- a/src/libcore/num/uint-template.rs
+++ b/src/libcore/num/uint-template.rs
@@ -57,7 +57,7 @@ pub fn _range_step(start: T,
                    it: &fn(T) -> bool) -> bool {
     let mut i = start;
     if step == 0 {
-        fail!(~"range_step called with step == 0");
+        fail!("range_step called with step == 0");
     }
     if step >= 0 {
         while i < stop {
@@ -630,16 +630,16 @@ mod tests {
 
         // None of the `fail`s should execute.
         for range(0,0) |_i| {
-            fail!(~"unreachable");
+            fail!("unreachable");
         }
         for range_rev(0,0) |_i| {
-            fail!(~"unreachable");
+            fail!("unreachable");
         }
         for range_step(10,0,1) |_i| {
-            fail!(~"unreachable");
+            fail!("unreachable");
         }
         for range_step(0,1,-10) |_i| {
-            fail!(~"unreachable");
+            fail!("unreachable");
         }
     }