move f16/f128 const fn under f16/f128 feature gate

This commit is contained in:
Ralf Jung 2024-10-04 17:43:27 +02:00
parent d30c3924a4
commit 0cd0f7ceef
7 changed files with 22 additions and 26 deletions

View File

@ -158,8 +158,6 @@
#![feature(coverage_attribute)] #![feature(coverage_attribute)]
#![feature(do_not_recommend)] #![feature(do_not_recommend)]
#![feature(duration_consts_float)] #![feature(duration_consts_float)]
#![feature(f128_const)]
#![feature(f16_const)]
#![feature(internal_impls_macro)] #![feature(internal_impls_macro)]
#![feature(ip)] #![feature(ip)]
#![feature(is_ascii_octdigit)] #![feature(is_ascii_octdigit)]

View File

@ -910,7 +910,7 @@ pub unsafe fn to_int_unchecked<Int>(self) -> Int
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[rustc_const_unstable(feature = "f128_const", issue = "116909")] #[rustc_const_unstable(feature = "f128", issue = "116909")]
#[must_use = "this returns the result of the operation, without modifying the original"] #[must_use = "this returns the result of the operation, without modifying the original"]
pub const fn to_bits(self) -> u128 { pub const fn to_bits(self) -> u128 {
// SAFETY: `u128` is a plain old datatype so we can always transmute to it. // SAFETY: `u128` is a plain old datatype so we can always transmute to it.
@ -959,7 +959,7 @@ pub const fn to_bits(self) -> u128 {
#[inline] #[inline]
#[must_use] #[must_use]
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[rustc_const_unstable(feature = "f128_const", issue = "116909")] #[rustc_const_unstable(feature = "f128", issue = "116909")]
pub const fn from_bits(v: u128) -> Self { pub const fn from_bits(v: u128) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray! // It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u128` is a plain old datatype so we can always transmute from it. // SAFETY: `u128` is a plain old datatype so we can always transmute from it.
@ -986,7 +986,7 @@ pub const fn from_bits(v: u128) -> Self {
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[rustc_const_unstable(feature = "f128_const", issue = "116909")] #[rustc_const_unstable(feature = "f128", issue = "116909")]
#[must_use = "this returns the result of the operation, without modifying the original"] #[must_use = "this returns the result of the operation, without modifying the original"]
pub const fn to_be_bytes(self) -> [u8; 16] { pub const fn to_be_bytes(self) -> [u8; 16] {
self.to_bits().to_be_bytes() self.to_bits().to_be_bytes()
@ -1012,7 +1012,7 @@ pub const fn from_bits(v: u128) -> Self {
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[rustc_const_unstable(feature = "f128_const", issue = "116909")] #[rustc_const_unstable(feature = "f128", issue = "116909")]
#[must_use = "this returns the result of the operation, without modifying the original"] #[must_use = "this returns the result of the operation, without modifying the original"]
pub const fn to_le_bytes(self) -> [u8; 16] { pub const fn to_le_bytes(self) -> [u8; 16] {
self.to_bits().to_le_bytes() self.to_bits().to_le_bytes()
@ -1049,7 +1049,7 @@ pub const fn from_bits(v: u128) -> Self {
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[rustc_const_unstable(feature = "f128_const", issue = "116909")] #[rustc_const_unstable(feature = "f128", issue = "116909")]
#[must_use = "this returns the result of the operation, without modifying the original"] #[must_use = "this returns the result of the operation, without modifying the original"]
pub const fn to_ne_bytes(self) -> [u8; 16] { pub const fn to_ne_bytes(self) -> [u8; 16] {
self.to_bits().to_ne_bytes() self.to_bits().to_ne_bytes()
@ -1077,7 +1077,7 @@ pub const fn from_bits(v: u128) -> Self {
#[inline] #[inline]
#[must_use] #[must_use]
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[rustc_const_unstable(feature = "f128_const", issue = "116909")] #[rustc_const_unstable(feature = "f128", issue = "116909")]
pub const fn from_be_bytes(bytes: [u8; 16]) -> Self { pub const fn from_be_bytes(bytes: [u8; 16]) -> Self {
Self::from_bits(u128::from_be_bytes(bytes)) Self::from_bits(u128::from_be_bytes(bytes))
} }
@ -1104,7 +1104,7 @@ pub const fn from_bits(v: u128) -> Self {
#[inline] #[inline]
#[must_use] #[must_use]
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[rustc_const_unstable(feature = "f128_const", issue = "116909")] #[rustc_const_unstable(feature = "f128", issue = "116909")]
pub const fn from_le_bytes(bytes: [u8; 16]) -> Self { pub const fn from_le_bytes(bytes: [u8; 16]) -> Self {
Self::from_bits(u128::from_le_bytes(bytes)) Self::from_bits(u128::from_le_bytes(bytes))
} }
@ -1141,7 +1141,7 @@ pub const fn from_bits(v: u128) -> Self {
#[inline] #[inline]
#[must_use] #[must_use]
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[rustc_const_unstable(feature = "f128_const", issue = "116909")] #[rustc_const_unstable(feature = "f128", issue = "116909")]
pub const fn from_ne_bytes(bytes: [u8; 16]) -> Self { pub const fn from_ne_bytes(bytes: [u8; 16]) -> Self {
Self::from_bits(u128::from_ne_bytes(bytes)) Self::from_bits(u128::from_ne_bytes(bytes))
} }

View File

@ -896,7 +896,7 @@ pub unsafe fn to_int_unchecked<Int>(self) -> Int
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[rustc_const_unstable(feature = "f16_const", issue = "116909")] #[rustc_const_unstable(feature = "f16", issue = "116909")]
#[must_use = "this returns the result of the operation, without modifying the original"] #[must_use = "this returns the result of the operation, without modifying the original"]
pub const fn to_bits(self) -> u16 { pub const fn to_bits(self) -> u16 {
// SAFETY: `u16` is a plain old datatype so we can always transmute to it. // SAFETY: `u16` is a plain old datatype so we can always transmute to it.
@ -944,7 +944,7 @@ pub const fn to_bits(self) -> u16 {
#[inline] #[inline]
#[must_use] #[must_use]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[rustc_const_unstable(feature = "f16_const", issue = "116909")] #[rustc_const_unstable(feature = "f16", issue = "116909")]
pub const fn from_bits(v: u16) -> Self { pub const fn from_bits(v: u16) -> Self {
// It turns out the safety issues with sNaN were overblown! Hooray! // It turns out the safety issues with sNaN were overblown! Hooray!
// SAFETY: `u16` is a plain old datatype so we can always transmute from it. // SAFETY: `u16` is a plain old datatype so we can always transmute from it.
@ -970,7 +970,7 @@ pub const fn from_bits(v: u16) -> Self {
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[rustc_const_unstable(feature = "f16_const", issue = "116909")] #[rustc_const_unstable(feature = "f16", issue = "116909")]
#[must_use = "this returns the result of the operation, without modifying the original"] #[must_use = "this returns the result of the operation, without modifying the original"]
pub const fn to_be_bytes(self) -> [u8; 2] { pub const fn to_be_bytes(self) -> [u8; 2] {
self.to_bits().to_be_bytes() self.to_bits().to_be_bytes()
@ -995,7 +995,7 @@ pub const fn from_bits(v: u16) -> Self {
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[rustc_const_unstable(feature = "f16_const", issue = "116909")] #[rustc_const_unstable(feature = "f16", issue = "116909")]
#[must_use = "this returns the result of the operation, without modifying the original"] #[must_use = "this returns the result of the operation, without modifying the original"]
pub const fn to_le_bytes(self) -> [u8; 2] { pub const fn to_le_bytes(self) -> [u8; 2] {
self.to_bits().to_le_bytes() self.to_bits().to_le_bytes()
@ -1033,7 +1033,7 @@ pub const fn from_bits(v: u16) -> Self {
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[rustc_const_unstable(feature = "f16_const", issue = "116909")] #[rustc_const_unstable(feature = "f16", issue = "116909")]
#[must_use = "this returns the result of the operation, without modifying the original"] #[must_use = "this returns the result of the operation, without modifying the original"]
pub const fn to_ne_bytes(self) -> [u8; 2] { pub const fn to_ne_bytes(self) -> [u8; 2] {
self.to_bits().to_ne_bytes() self.to_bits().to_ne_bytes()
@ -1057,7 +1057,7 @@ pub const fn from_bits(v: u16) -> Self {
#[inline] #[inline]
#[must_use] #[must_use]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[rustc_const_unstable(feature = "f16_const", issue = "116909")] #[rustc_const_unstable(feature = "f16", issue = "116909")]
pub const fn from_be_bytes(bytes: [u8; 2]) -> Self { pub const fn from_be_bytes(bytes: [u8; 2]) -> Self {
Self::from_bits(u16::from_be_bytes(bytes)) Self::from_bits(u16::from_be_bytes(bytes))
} }
@ -1080,7 +1080,7 @@ pub const fn from_bits(v: u16) -> Self {
#[inline] #[inline]
#[must_use] #[must_use]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[rustc_const_unstable(feature = "f16_const", issue = "116909")] #[rustc_const_unstable(feature = "f16", issue = "116909")]
pub const fn from_le_bytes(bytes: [u8; 2]) -> Self { pub const fn from_le_bytes(bytes: [u8; 2]) -> Self {
Self::from_bits(u16::from_le_bytes(bytes)) Self::from_bits(u16::from_le_bytes(bytes))
} }
@ -1114,7 +1114,7 @@ pub const fn from_bits(v: u16) -> Self {
#[inline] #[inline]
#[must_use] #[must_use]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[rustc_const_unstable(feature = "f16_const", issue = "116909")] #[rustc_const_unstable(feature = "f16", issue = "116909")]
pub const fn from_ne_bytes(bytes: [u8; 2]) -> Self { pub const fn from_ne_bytes(bytes: [u8; 2]) -> Self {
Self::from_bits(u16::from_ne_bytes(bytes)) Self::from_bits(u16::from_ne_bytes(bytes))
} }

View File

@ -1,7 +1,7 @@
#![warn(clippy::transmute_float_to_int)] #![warn(clippy::transmute_float_to_int)]
#![allow(clippy::missing_transmute_annotations)] #![allow(clippy::missing_transmute_annotations)]
#![feature(f128, f128_const)] #![feature(f128)]
#![feature(f16, f16_const)] #![feature(f16)]
fn float_to_int() { fn float_to_int() {
let _: u32 = unsafe { 1f32.to_bits() }; let _: u32 = unsafe { 1f32.to_bits() };

View File

@ -1,7 +1,7 @@
#![warn(clippy::transmute_float_to_int)] #![warn(clippy::transmute_float_to_int)]
#![allow(clippy::missing_transmute_annotations)] #![allow(clippy::missing_transmute_annotations)]
#![feature(f128, f128_const)] #![feature(f128)]
#![feature(f16, f16_const)] #![feature(f16)]
fn float_to_int() { fn float_to_int() {
let _: u32 = unsafe { std::mem::transmute(1f32) }; let _: u32 = unsafe { std::mem::transmute(1f32) };

View File

@ -6,8 +6,8 @@
// This tests the float classification functions, for regular runtime code and for const evaluation. // This tests the float classification functions, for regular runtime code and for const evaluation.
#![feature(f16_const)] #![feature(f16)]
#![feature(f128_const)] #![feature(f128)]
use std::num::FpCategory::*; use std::num::FpCategory::*;

View File

@ -5,8 +5,6 @@
#![feature(f16)] #![feature(f16)]
#![feature(f128)] #![feature(f128)]
#![feature(f16_const)]
#![feature(f128_const)]
#![allow(unused_macro_rules)] #![allow(unused_macro_rules)]
use std::hint::black_box; use std::hint::black_box;