Skip to content

Commit 56071f6

Browse files
committed
Auto merge of #43055 - est31:stabilize_float_bits_conv, r=sfackler
Stabilize float_bits_conv for Rust 1.21 Stabilizes the `float_bits_conv` lib feature for the 1.20 release of Rust. I've initially implemented the feature in #39271 and later made PR #43025 to output quiet NaNs even on platforms with different encodings, which seems to have been the only unresolved issue of the API. Due to PR #43025 being only applied to master this stabilisation can't happen for Rust 1.19 through the usual "stabilisation on beta" system that is being done for library APIs. r? @BurntSushi closes #40470.
2 parents 8f1339a + 010dea1 commit 56071f6

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/libstd/f32.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1090,12 +1090,11 @@ impl f32 {
10901090
/// # Examples
10911091
///
10921092
/// ```
1093-
/// #![feature(float_bits_conv)]
10941093
/// assert_ne!((1f32).to_bits(), 1f32 as u32); // to_bits() is not casting!
10951094
/// assert_eq!((12.5f32).to_bits(), 0x41480000);
10961095
///
10971096
/// ```
1098-
#[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")]
1097+
#[stable(feature = "float_bits_conv", since = "1.21.0")]
10991098
#[inline]
11001099
pub fn to_bits(self) -> u32 {
11011100
unsafe { ::mem::transmute(self) }
@@ -1118,7 +1117,6 @@ impl f32 {
11181117
/// # Examples
11191118
///
11201119
/// ```
1121-
/// #![feature(float_bits_conv)]
11221120
/// use std::f32;
11231121
/// let v = f32::from_bits(0x41480000);
11241122
/// let difference = (v - 12.5).abs();
@@ -1127,7 +1125,7 @@ impl f32 {
11271125
/// let snan = 0x7F800001;
11281126
/// assert_ne!(f32::from_bits(snan).to_bits(), snan);
11291127
/// ```
1130-
#[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")]
1128+
#[stable(feature = "float_bits_conv", since = "1.21.0")]
11311129
#[inline]
11321130
pub fn from_bits(mut v: u32) -> Self {
11331131
const EXP_MASK: u32 = 0x7F800000;

src/libstd/f64.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1005,12 +1005,11 @@ impl f64 {
10051005
/// # Examples
10061006
///
10071007
/// ```
1008-
/// #![feature(float_bits_conv)]
10091008
/// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
10101009
/// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
10111010
///
10121011
/// ```
1013-
#[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")]
1012+
#[stable(feature = "float_bits_conv", since = "1.21.0")]
10141013
#[inline]
10151014
pub fn to_bits(self) -> u64 {
10161015
unsafe { ::mem::transmute(self) }
@@ -1033,7 +1032,6 @@ impl f64 {
10331032
/// # Examples
10341033
///
10351034
/// ```
1036-
/// #![feature(float_bits_conv)]
10371035
/// use std::f64;
10381036
/// let v = f64::from_bits(0x4029000000000000);
10391037
/// let difference = (v - 12.5).abs();
@@ -1042,7 +1040,7 @@ impl f64 {
10421040
/// let snan = 0x7FF0000000000001;
10431041
/// assert_ne!(f64::from_bits(snan).to_bits(), snan);
10441042
/// ```
1045-
#[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")]
1043+
#[stable(feature = "float_bits_conv", since = "1.21.0")]
10461044
#[inline]
10471045
pub fn from_bits(mut v: u64) -> Self {
10481046
const EXP_MASK: u64 = 0x7FF0000000000000;

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@
317317
#![feature(unwind_attributes)]
318318
#![feature(vec_push_all)]
319319
#![cfg_attr(test, feature(update_panic_count))]
320-
#![cfg_attr(test, feature(float_bits_conv))]
321320

322321
#![cfg_attr(not(stage0), default_lib_allocator)]
323322
#![cfg_attr(stage0, feature(associated_consts))]

0 commit comments

Comments
 (0)