about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-24 15:58:27 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-05-01 16:44:36 -0700
commit12910418fbfd1da76cfc43ffa7a15d0b0c4acb5b (patch)
treec4939c074d8444c344b1d42f621d424f6ef2bcbe /src/libstd
parentf3345cb0a70cdac95e126b611b355ab4d36ca3df (diff)
downloadrust-12910418fbfd1da76cfc43ffa7a15d0b0c4acb5b.tar.gz
rust-12910418fbfd1da76cfc43ffa7a15d0b0c4acb5b.zip
std: Don't use a wrapper for the float error type
Ensures that the same error type is propagated throughout. Unnecessary leakage
of the internals is prevented through the usage of stability attributes.

Closes #24748
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/error.rs2
-rw-r--r--src/libstd/num/f32.rs3
-rw-r--r--src/libstd/num/f64.rs3
-rw-r--r--src/libstd/num/mod.rs33
4 files changed, 6 insertions, 35 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 06e4d69818e..6d23df97000 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -147,7 +147,7 @@ impl Error for num::ParseIntError {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Error for num::ParseFloatError {
     fn description(&self) -> &str {
-        self.description()
+        self.__description()
     }
 }
 
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index 0efc04ef83c..1ee3aab2727 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -21,7 +21,6 @@ use core::num;
 use intrinsics;
 use libc::c_int;
 use num::{FpCategory, ParseFloatError};
-use sys_common::FromInner;
 
 pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
 pub use core::f32::{MIN_EXP, MAX_EXP, MIN_10_EXP};
@@ -77,7 +76,7 @@ impl f32 {
     /// Parses a float as with a given radix
     #[unstable(feature = "float_from_str_radix", reason = "recently moved API")]
     pub fn from_str_radix(s: &str, radix: u32) -> Result<f32, ParseFloatError> {
-        num::Float::from_str_radix(s, radix).map_err(FromInner::from_inner)
+        num::Float::from_str_radix(s, radix)
     }
 
     /// Returns `true` if this value is `NaN` and false otherwise.
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index e1497f3958d..398afcb553c 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -20,7 +20,6 @@ use core::num;
 use intrinsics;
 use libc::c_int;
 use num::{FpCategory, ParseFloatError};
-use sys_common::FromInner;
 
 pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
 pub use core::f64::{MIN_EXP, MAX_EXP, MIN_10_EXP};
@@ -85,7 +84,7 @@ impl f64 {
     /// Parses a float as with a given radix
     #[unstable(feature = "float_from_str_radix", reason = "recently moved API")]
     pub fn from_str_radix(s: &str, radix: u32) -> Result<f64, ParseFloatError> {
-        num::Float::from_str_radix(s, radix).map_err(FromInner::from_inner)
+        num::Float::from_str_radix(s, radix)
     }
 
     /// Returns `true` if this value is `NaN` and false otherwise.
diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs
index cd26be013c4..9a52a0214e9 100644
--- a/src/libstd/num/mod.rs
+++ b/src/libstd/num/mod.rs
@@ -16,16 +16,14 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 #![allow(missing_docs)]
 
-use fmt;
-use core::num;
-
 pub use core::num::{Zero, One};
-pub use core::num::{FpCategory, ParseIntError};
+pub use core::num::{FpCategory, ParseIntError, ParseFloatError};
 pub use core::num::{wrapping, Wrapping};
 
-#[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem};
 #[cfg(test)] use cmp::PartialEq;
+#[cfg(test)] use fmt;
 #[cfg(test)] use marker::Copy;
+#[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem};
 
 /// Helper function for testing numeric operations
 #[cfg(test)]
@@ -43,31 +41,6 @@ pub fn test_num<T>(ten: T, two: T) where
     assert_eq!(ten.rem(two),  ten % two);
 }
 
-/// An error which can be returned when parsing a float.
-#[derive(Debug, Clone, PartialEq)]
-#[stable(feature = "rust1", since = "1.0.0")]
-pub struct ParseFloatError { inner: num::ParseFloatError }
-
-impl ::sys_common::FromInner<num::ParseFloatError> for ParseFloatError {
-    fn from_inner(inner: num::ParseFloatError) -> ParseFloatError {
-        ParseFloatError { inner: inner }
-    }
-}
-
-impl ParseFloatError {
-    #[unstable(feature = "core", reason = "available through Error trait")]
-    pub fn description(&self) -> &str {
-        self.inner.description()
-    }
-}
-
-#[stable(feature = "rust1", since = "1.0.0")]
-impl fmt::Display for ParseFloatError {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        self.description().fmt(f)
-    }
-}
-
 #[cfg(test)]
 mod tests {
     use core::prelude::*;