about summary refs log tree commit diff
path: root/src/libcore/num
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/libcore/num
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/libcore/num')
-rw-r--r--src/libcore/num/float_macros.rs14
-rw-r--r--src/libcore/num/mod.rs14
2 files changed, 16 insertions, 12 deletions
diff --git a/src/libcore/num/float_macros.rs b/src/libcore/num/float_macros.rs
index 5ee0dc19f9b..e3fa7047ec8 100644
--- a/src/libcore/num/float_macros.rs
+++ b/src/libcore/num/float_macros.rs
@@ -35,8 +35,8 @@ macro_rules! from_str_radix_float_impl {
             }
 
             let (is_positive, src) =  match src.slice_shift_char() {
-                None             => return Err(PFE { kind: Empty }),
-                Some(('-', ""))  => return Err(PFE { kind: Empty }),
+                None             => return Err(PFE { __kind: Empty }),
+                Some(('-', ""))  => return Err(PFE { __kind: Empty }),
                 Some(('-', src)) => (false, src),
                 Some((_, _))     => (true,  src),
             };
@@ -88,7 +88,7 @@ macro_rules! from_str_radix_float_impl {
                             break;  // start of fractional part
                         },
                         _ => {
-                            return Err(PFE { kind: Invalid });
+                            return Err(PFE { __kind: Invalid });
                         },
                     },
                 }
@@ -122,7 +122,7 @@ macro_rules! from_str_radix_float_impl {
                                 break; // start of exponent
                             },
                             _ => {
-                                return Err(PFE { kind: Invalid });
+                                return Err(PFE { __kind: Invalid });
                             },
                         },
                     }
@@ -135,7 +135,7 @@ macro_rules! from_str_radix_float_impl {
                     let base = match c {
                         'E' | 'e' if radix == 10 => 10.0,
                         'P' | 'p' if radix == 16 => 2.0,
-                        _ => return Err(PFE { kind: Invalid }),
+                        _ => return Err(PFE { __kind: Invalid }),
                     };
 
                     // Parse the exponent as decimal integer
@@ -144,13 +144,13 @@ macro_rules! from_str_radix_float_impl {
                         Some(('-', src)) => (false, src.parse::<usize>()),
                         Some(('+', src)) => (true,  src.parse::<usize>()),
                         Some((_, _))     => (true,  src.parse::<usize>()),
-                        None             => return Err(PFE { kind: Invalid }),
+                        None             => return Err(PFE { __kind: Invalid }),
                     };
 
                     match (is_positive, exp) {
                         (true,  Ok(exp)) => base.powi(exp as i32),
                         (false, Ok(exp)) => 1.0 / base.powi(exp as i32),
-                        (_, Err(_))      => return Err(PFE { kind: Invalid }),
+                        (_, Err(_))      => return Err(PFE { __kind: Invalid }),
                     }
                 },
                 None => 1.0, // no exponent
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 22f4e854655..71c2b38287e 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -1524,7 +1524,11 @@ impl fmt::Display for ParseIntError {
 
 /// An error which can be returned when parsing a float.
 #[derive(Debug, Clone, PartialEq)]
-pub struct ParseFloatError { pub kind: FloatErrorKind }
+#[stable(feature = "rust1", since = "1.0.0")]
+pub struct ParseFloatError {
+    #[doc(hidden)]
+    pub __kind: FloatErrorKind
+}
 
 #[derive(Debug, Clone, PartialEq)]
 pub enum FloatErrorKind {
@@ -1533,9 +1537,9 @@ pub enum FloatErrorKind {
 }
 
 impl ParseFloatError {
-    #[unstable(feature = "core", reason = "available through Error trait")]
-    pub fn description(&self) -> &str {
-        match self.kind {
+    #[doc(hidden)]
+    pub fn __description(&self) -> &str {
+        match self.__kind {
             FloatErrorKind::Empty => "cannot parse float from empty string",
             FloatErrorKind::Invalid => "invalid float literal",
         }
@@ -1545,6 +1549,6 @@ impl ParseFloatError {
 #[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)
+        self.__description().fmt(f)
     }
 }