diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 65afdd2969b8..67515a3b7ad2 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -137,10 +137,8 @@ pub mod consts { pub const LN_10: f128 = 2.30258509299404568401799145468436420760110148862877297603333_f128; } +#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), allow(internal_features))))] impl f128 { - // FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const - // implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE. - /// The radix or base of the internal representation of `f128`. #[unstable(feature = "f128", issue = "116909")] pub const RADIX: u32 = 2; @@ -277,8 +275,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `unordtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let nan = f128::NAN; /// let f = 7.0_f128; @@ -300,8 +297,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let f = 7.0f128; /// let inf = f128::INFINITY; @@ -326,8 +322,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `lttf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let f = 7.0f128; /// let inf: f128 = f128::INFINITY; @@ -355,8 +350,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let min = f128::MIN_POSITIVE; // 3.362103143e-4932f128 /// let max = f128::MAX; @@ -386,8 +380,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let min = f128::MIN_POSITIVE; // 3.362103143e-4932f128 /// let max = f128::MAX; @@ -419,8 +412,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// use std::num::FpCategory; /// @@ -514,8 +506,7 @@ impl f128 { /// /// ```rust /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// // f128::EPSILON is the difference between 1.0 and the next number up. /// assert_eq!(1.0f128.next_up(), 1.0 + f128::EPSILON); @@ -569,8 +560,7 @@ impl f128 { /// /// ```rust /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let x = 1.0f128; /// // Clamp value into range [0, 1). @@ -613,8 +603,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let x = 2.0_f128; /// let abs_difference = (x.recip() - (1.0 / x)).abs(); @@ -640,8 +629,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let angle = std::f128::consts::PI; /// @@ -671,8 +659,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let angle = 180.0f128; /// @@ -706,8 +693,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // Using aarch64 because `reliable_f128_math` is needed - /// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128_math)] { /// /// let x = 1.0f128; /// let y = 2.0f128; @@ -738,8 +724,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // Using aarch64 because `reliable_f128_math` is needed - /// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128_math)] { /// /// let x = 1.0f128; /// let y = 2.0f128; @@ -771,8 +756,7 @@ impl f128 { /// ``` /// #![feature(f128)] /// #![feature(float_minimum_maximum)] - /// # // Using aarch64 because `reliable_f128_math` is needed - /// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128_math)] { /// /// let x = 1.0f128; /// let y = 2.0f128; @@ -804,8 +788,7 @@ impl f128 { /// ``` /// #![feature(f128)] /// #![feature(float_minimum_maximum)] - /// # // Using aarch64 because `reliable_f128_math` is needed - /// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128_math)] { /// /// let x = 1.0f128; /// let y = 2.0f128; @@ -831,8 +814,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // Using aarch64 because `reliable_f128_math` is needed - /// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// assert_eq!(1f128.midpoint(4.0), 2.5); /// assert_eq!((-5.5f128).midpoint(8.0), 1.25); @@ -862,8 +844,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `float*itf` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let value = 4.6_f128; /// let rounded = unsafe { value.to_int_unchecked::() }; @@ -952,8 +933,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let v = f128::from_bits(0x40029000000000000000000000000000); /// assert_eq!(v, 12.5); @@ -1064,8 +1044,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let value = f128::from_be_bytes( /// [0x40, 0x02, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1090,8 +1069,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let value = f128::from_le_bytes( /// [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1123,8 +1101,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `eqtf2` is available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let value = f128::from_ne_bytes(if cfg!(target_endian = "big") { /// [0x40, 0x02, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1257,8 +1234,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # // FIXME(f16_f128): remove when `{eq,gt,unord}tf` are available - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// assert!((-3.0f128).clamp(-2.0, 1.0) == -2.0); /// assert!((0.0f128).clamp(-2.0, 1.0) == 0.0); @@ -1333,7 +1309,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let x = 3.5_f128; /// let y = -3.5_f128; @@ -1364,7 +1340,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let f = 3.5_f128; /// @@ -1400,7 +1376,7 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { + /// # #[cfg(target_has_reliable_f128)] { /// /// let f = 3.5_f128; /// @@ -1477,8 +1453,6 @@ impl f128 { } // Functions in this module fall into `core_float_math` -// FIXME(f16_f128): all doctests must be gated to platforms that have `long double` === `_Float128` -// due to https://github.com/llvm/llvm-project/issues/44744. aarch64 linux matches this. // #[unstable(feature = "core_float_math", issue = "137578")] #[cfg(not(test))] #[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))] diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index 344f58da277b..0487b667d83e 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -134,9 +134,6 @@ pub mod consts { #[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), allow(internal_features))))] impl f16 { - // FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const - // implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE. - /// The radix or base of the internal representation of `f16`. #[unstable(feature = "f16", issue = "116909")] pub const RADIX: u32 = 2; diff --git a/library/coretests/tests/floats/mod.rs b/library/coretests/tests/floats/mod.rs index 87e21b21f310..3f0d98e905fd 100644 --- a/library/coretests/tests/floats/mod.rs +++ b/library/coretests/tests/floats/mod.rs @@ -1357,15 +1357,11 @@ float_test! { } } -// FIXME(f16): Tests involving sNaN are disabled because without optimizations, `total_cmp` is -// getting incorrectly lowered to code that includes a `extend`/`trunc` round trip, which quiets -// sNaNs. See: https://github.com/llvm/llvm-project/issues/104915 - float_test! { name: total_cmp_s_nan, attrs: { const: #[cfg(false)], - f16: #[cfg(miri)], + f16: #[cfg(any(miri, target_has_reliable_f16_math))], f128: #[cfg(any(miri, target_has_reliable_f128_math))], }, test { diff --git a/library/coretests/tests/num/dec2flt/decimal.rs b/library/coretests/tests/num/dec2flt/decimal.rs index f759e1dbde6c..f5ecc604a99a 100644 --- a/library/coretests/tests/num/dec2flt/decimal.rs +++ b/library/coretests/tests/num/dec2flt/decimal.rs @@ -7,7 +7,6 @@ const FPATHS_F32: &[FPath] = const FPATHS_F64: &[FPath] = &[((0, 0, false, false), Some(0.0)), ((0, 0, false, false), Some(0.0))]; -// FIXME(f16_f128): enable on all targets once possible. #[test] #[cfg(target_has_reliable_f16)] fn check_fast_path_f16() { diff --git a/library/coretests/tests/num/dec2flt/float.rs b/library/coretests/tests/num/dec2flt/float.rs index 8bf4094ced72..734cb7e4f7db 100644 --- a/library/coretests/tests/num/dec2flt/float.rs +++ b/library/coretests/tests/num/dec2flt/float.rs @@ -2,7 +2,6 @@ use core::num::dec2flt::float::RawFloat; use crate::num::{ldexp_f32, ldexp_f64}; -// FIXME(f16_f128): enable on all targets once possible. #[test] #[cfg(target_has_reliable_f16)] fn test_f16_integer_decode() { @@ -54,7 +53,6 @@ fn test_f64_integer_decode() { /* Sanity checks of computed magic numbers */ -// FIXME(f16_f128): enable on all targets once possible. #[test] #[cfg(target_has_reliable_f16)] fn test_f16_consts() { diff --git a/library/coretests/tests/num/dec2flt/lemire.rs b/library/coretests/tests/num/dec2flt/lemire.rs index 6d49d85170e2..ba359a0495fe 100644 --- a/library/coretests/tests/num/dec2flt/lemire.rs +++ b/library/coretests/tests/num/dec2flt/lemire.rs @@ -17,7 +17,6 @@ fn compute_float64(q: i64, w: u64) -> (i32, u64) { (fp.p_biased, fp.m) } -// FIXME(f16_f128): enable on all targets once possible. #[test] #[cfg(target_has_reliable_f16)] fn compute_float_f16_rounding() { diff --git a/library/coretests/tests/num/dec2flt/mod.rs b/library/coretests/tests/num/dec2flt/mod.rs index b8ca220847cf..37136e62c6f4 100644 --- a/library/coretests/tests/num/dec2flt/mod.rs +++ b/library/coretests/tests/num/dec2flt/mod.rs @@ -92,8 +92,6 @@ fn fast_path_correct() { test_literal!(1.448997445238699); } -// FIXME(f16_f128): remove gates once tests work on all targets - #[test] fn lonely_dot() { #[cfg(target_has_reliable_f16)] diff --git a/library/std/tests/floats/f128.rs b/library/std/tests/floats/f128.rs index e7c90faa05c2..6db468b0ce26 100644 --- a/library/std/tests/floats/f128.rs +++ b/library/std/tests/floats/f128.rs @@ -1,4 +1,3 @@ -// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy #![cfg(target_has_reliable_f128)] use std::f128::consts; diff --git a/library/std/tests/floats/f16.rs b/library/std/tests/floats/f16.rs index 0f8b4138d226..cc0960765f41 100644 --- a/library/std/tests/floats/f16.rs +++ b/library/std/tests/floats/f16.rs @@ -1,4 +1,3 @@ -// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy #![cfg(target_has_reliable_f16)] use std::f16::consts; @@ -258,8 +257,6 @@ fn test_ln_gamma() { #[test] fn test_real_consts() { - // FIXME(f16_f128): add math tests when available - let pi: f16 = consts::PI; let frac_pi_2: f16 = consts::FRAC_PI_2; let frac_pi_3: f16 = consts::FRAC_PI_3; diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs b/tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs index a89b22925128..df1b9e164c76 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs @@ -1,9 +1,11 @@ //@ run-pass +//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f128) // Test half-open range patterns against their expression equivalents // via `.contains(...)` and make sure the dynamic semantics match. #![allow(unreachable_patterns)] +#![feature(cfg_target_has_reliable_f16_f128)] #![feature(f128)] #![feature(f16)] @@ -42,8 +44,7 @@ fn range_to_inclusive() { assert!(!yes!('b', ..='a')); // f16; `..=X` - // FIXME(f16_f128): remove gate when ABI issues are resolved - #[cfg(all(target_arch = "aarch64", target_os = "linux"))] + #[cfg(target_has_reliable_f16)] { assert!(yes!(f16::NEG_INFINITY, ..=f16::NEG_INFINITY)); assert!(yes!(f16::NEG_INFINITY, ..=1.0f16)); @@ -64,8 +65,7 @@ fn range_to_inclusive() { assert!(!yes!(1.6f64, ..=-1.5f64)); // f128; `..=X` - // FIXME(f16_f128): remove gate when ABI issues are resolved - #[cfg(all(target_arch = "aarch64", target_os = "linux"))] + #[cfg(target_has_reliable_f128)] { assert!(yes!(f128::NEG_INFINITY, ..=f128::NEG_INFINITY)); assert!(yes!(f128::NEG_INFINITY, ..=1.0f128)); @@ -106,8 +106,7 @@ fn range_to() { assert!(!yes!('b', ..'a')); // f16; `..X` - // FIXME(f16_f128): remove gate when ABI issues are resolved - #[cfg(all(target_arch = "aarch64", target_os = "linux"))] + #[cfg(target_has_reliable_f16)] { assert!(yes!(f16::NEG_INFINITY, ..1.0f16)); assert!(!yes!(1.5f16, ..1.5f16)); @@ -131,8 +130,7 @@ fn range_to() { assert!(!yes!(1.6f64, ..1.5f64)); // f128; `..X` - // FIXME(f16_f128): remove gate when ABI issues are resolved - #[cfg(all(target_arch = "aarch64", target_os = "linux"))] + #[cfg(target_has_reliable_f128)] { assert!(yes!(f128::NEG_INFINITY, ..1.0f128)); assert!(!yes!(1.5f128, ..1.5f128)); @@ -174,8 +172,7 @@ fn range_from() { assert!(yes!(core::char::MAX, core::char::MAX..)); // f16; `X..` - // FIXME(f16_f128): remove gate when ABI issues are resolved - #[cfg(all(target_arch = "aarch64", target_os = "linux"))] + #[cfg(target_has_reliable_f16)] { assert!(yes!(f16::NEG_INFINITY, f16::NEG_INFINITY..)); assert!(yes!(f16::INFINITY, f16::NEG_INFINITY..)); @@ -208,8 +205,7 @@ fn range_from() { assert!(yes!(f64::INFINITY, f64::INFINITY..)); // f128; `X..` - // FIXME(f16_f128): remove gate when ABI issues are resolved - #[cfg(all(target_arch = "aarch64", target_os = "linux"))] + #[cfg(target_has_reliable_f128)] { assert!(yes!(f128::NEG_INFINITY, f128::NEG_INFINITY..)); assert!(yes!(f128::INFINITY, f128::NEG_INFINITY..)); diff --git a/tests/ui/match/match-float.rs b/tests/ui/match/match-float.rs index 70283eaeec52..279bb5927ac4 100644 --- a/tests/ui/match/match-float.rs +++ b/tests/ui/match/match-float.rs @@ -1,12 +1,12 @@ //@ run-pass +//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f128) // Makes sure we use `==` (not bitwise) semantics for float comparison. +#![feature(cfg_target_has_reliable_f16_f128)] #![feature(f128)] #![feature(f16)] -// FIXME(f16_f128): remove gates when ABI issues are resolved - -#[cfg(all(target_arch = "aarch64", target_os = "linux"))] +#[cfg(target_has_reliable_f16)] fn check_f16() { const F1: f16 = 0.0; const F2: f16 = -0.0; @@ -34,7 +34,7 @@ fn check_f64() { assert!(matches!(F2, F1)); } -#[cfg(all(target_arch = "aarch64", target_os = "linux"))] +#[cfg(target_has_reliable_f128)] fn check_f128() { const F1: f128 = 0.0; const F2: f128 = -0.0; @@ -45,10 +45,10 @@ fn check_f128() { } fn main() { - #[cfg(all(target_arch = "aarch64", target_os = "linux"))] + #[cfg(target_has_reliable_f16)] check_f16(); check_f32(); check_f64(); - #[cfg(all(target_arch = "aarch64", target_os = "linux"))] + #[cfg(target_has_reliable_f128)] check_f128(); }