about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClar Charr <clar@charr.xyz>2017-12-23 17:51:06 -0500
committerClar Charr <clar@charr.xyz>2017-12-23 17:51:06 -0500
commit556fb02e43a16de50764af55db20f64ac17e7f23 (patch)
treedd2b99548a64898c8aa839dfc1dd6f6151ca07c0
parenta2cdeb58f680b87b5bdb6a17cba857ac51307c8f (diff)
downloadrust-556fb02e43a16de50764af55db20f64ac17e7f23.tar.gz
rust-556fb02e43a16de50764af55db20f64ac17e7f23.zip
Move Bits constraints to RawFloat::RawBits
-rw-r--r--src/libcore/num/dec2flt/rawfp.rs23
-rw-r--r--src/libcore/num/mod.rs2
2 files changed, 20 insertions, 5 deletions
diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs
index 143a05a1944..77180233a23 100644
--- a/src/libcore/num/dec2flt/rawfp.rs
+++ b/src/libcore/num/dec2flt/rawfp.rs
@@ -28,8 +28,8 @@
 //! take the universally-correct slow path (Algorithm M) for very small and very large numbers.
 //! That algorithm needs only next_float() which does handle subnormals and zeros.
 use cmp::Ordering::{Less, Equal, Greater};
-use convert::TryInto;
-use ops::{Mul, Div, Neg};
+use convert::{TryFrom, TryInto};
+use ops::{Add, Mul, Div, Neg};
 use fmt::{Debug, LowerExp};
 use num::diy_float::Fp;
 use num::FpCategory::{Infinite, Zero, Subnormal, Normal, Nan};
@@ -55,13 +55,24 @@ impl Unpacked {
 ///
 /// Should **never ever** be implemented for other types or be used outside the dec2flt module.
 /// Inherits from `Float` because there is some overlap, but all the reused methods are trivial.
-pub trait RawFloat : Float + Copy + Debug + LowerExp
-                    + Mul<Output=Self> + Div<Output=Self> + Neg<Output=Self>
+pub trait RawFloat
+    : Float
+    + Copy
+    + Debug
+    + LowerExp
+    + Mul<Output=Self>
+    + Div<Output=Self>
+    + Neg<Output=Self>
+where
+    Self: Float<Bits = <Self as RawFloat>::RawBits>
 {
     const INFINITY: Self;
     const NAN: Self;
     const ZERO: Self;
 
+    /// Same as `Float::Bits` with extra traits.
+    type RawBits: Add<Output = Self::RawBits> + From<u8> + TryFrom<u64>;
+
     /// Returns the mantissa, exponent and sign as integers.
     fn integer_decode(self) -> (u64, i16, i8);
 
@@ -142,6 +153,8 @@ macro_rules! other_constants {
 }
 
 impl RawFloat for f32 {
+    type RawBits = u32;
+
     const SIG_BITS: u8 = 24;
     const EXP_BITS: u8 = 8;
     const CEIL_LOG5_OF_MAX_SIG: i16 = 11;
@@ -183,6 +196,8 @@ impl RawFloat for f32 {
 
 
 impl RawFloat for f64 {
+    type RawBits = u64;
+
     const SIG_BITS: u8 = 53;
     const EXP_BITS: u8 = 11;
     const CEIL_LOG5_OF_MAX_SIG: i16 = 23;
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 94efde6d41d..ebf8a9597fe 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -2874,7 +2874,7 @@ pub enum FpCategory {
 pub trait Float: Sized {
     /// Type used by `to_bits` and `from_bits`.
     #[stable(feature = "core_float_bits", since = "1.24.0")]
-    type Bits: ops::Add<Output = Self::Bits> + From<u8> + TryFrom<u64>;
+    type Bits;
 
     /// Returns `true` if this value is NaN and false otherwise.
     #[stable(feature = "core", since = "1.6.0")]