Skip to content

Commit 1977849

Browse files
committed
Auto merge of #50933 - SimonSapin:anchorage, r=alexcrichton
Remove the unstable Float trait Following up to #49896 and #50629. Fixes #32110.
2 parents 29ffe51 + b825477 commit 1977849

10 files changed

+232
-437
lines changed

src/libcore/num/dec2flt/rawfp.rs

+23-10
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use ops::{Add, Mul, Div, Neg};
3333
use fmt::{Debug, LowerExp};
3434
use num::diy_float::Fp;
3535
use num::FpCategory::{Infinite, Zero, Subnormal, Normal, Nan};
36-
use num::Float;
36+
use num::FpCategory;
3737
use num::dec2flt::num::{self, Big};
3838
use num::dec2flt::table;
3939

@@ -54,24 +54,29 @@ impl Unpacked {
5454
/// See the parent module's doc comment for why this is necessary.
5555
///
5656
/// Should **never ever** be implemented for other types or be used outside the dec2flt module.
57-
/// Inherits from `Float` because there is some overlap, but all the reused methods are trivial.
5857
pub trait RawFloat
59-
: Float
60-
+ Copy
58+
: Copy
6159
+ Debug
6260
+ LowerExp
6361
+ Mul<Output=Self>
6462
+ Div<Output=Self>
6563
+ Neg<Output=Self>
66-
where
67-
Self: Float<Bits = <Self as RawFloat>::RawBits>
6864
{
6965
const INFINITY: Self;
7066
const NAN: Self;
7167
const ZERO: Self;
7268

73-
/// Same as `Float::Bits` with extra traits.
74-
type RawBits: Add<Output = Self::RawBits> + From<u8> + TryFrom<u64>;
69+
/// Type used by `to_bits` and `from_bits`.
70+
type Bits: Add<Output = Self::Bits> + From<u8> + TryFrom<u64>;
71+
72+
/// Raw transmutation to integer.
73+
fn to_bits(self) -> Self::Bits;
74+
75+
/// Raw transmutation from integer.
76+
fn from_bits(v: Self::Bits) -> Self;
77+
78+
/// Returns the category that this number falls into.
79+
fn classify(self) -> FpCategory;
7580

7681
/// Returns the mantissa, exponent and sign as integers.
7782
fn integer_decode(self) -> (u64, i16, i8);
@@ -153,7 +158,7 @@ macro_rules! other_constants {
153158
}
154159

155160
impl RawFloat for f32 {
156-
type RawBits = u32;
161+
type Bits = u32;
157162

158163
const SIG_BITS: u8 = 24;
159164
const EXP_BITS: u8 = 8;
@@ -192,11 +197,15 @@ impl RawFloat for f32 {
192197
fn short_fast_pow10(e: usize) -> Self {
193198
table::F32_SHORT_POWERS[e]
194199
}
200+
201+
fn classify(self) -> FpCategory { self.classify() }
202+
fn to_bits(self) -> Self::Bits { self.to_bits() }
203+
fn from_bits(v: Self::Bits) -> Self { Self::from_bits(v) }
195204
}
196205

197206

198207
impl RawFloat for f64 {
199-
type RawBits = u64;
208+
type Bits = u64;
200209

201210
const SIG_BITS: u8 = 53;
202211
const EXP_BITS: u8 = 11;
@@ -235,6 +244,10 @@ impl RawFloat for f64 {
235244
fn short_fast_pow10(e: usize) -> Self {
236245
table::F64_SHORT_POWERS[e]
237246
}
247+
248+
fn classify(self) -> FpCategory { self.classify() }
249+
fn to_bits(self) -> Self::Bits { self.to_bits() }
250+
fn from_bits(v: Self::Bits) -> Self { Self::from_bits(v) }
238251
}
239252

240253
/// Convert an Fp to the closest machine float type.

0 commit comments

Comments
 (0)