Skip to content

Commit 260dbc5

Browse files
committed
enable const-float-classify test again, and explain the const float tests better
1 parent 8b267d6 commit 260dbc5

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

tests/ui/consts/const-float-bits-conv.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
//@ compile-flags: -Zmir-opt-level=0
22
//@ run-pass
33

4+
// This tests conversion between floats and bits, not just for const evaluation
5+
// but also for regular runtime code.
6+
47
#![feature(const_float_bits_conv)]
58
#![feature(const_float_classify)]
69
#![feature(f16)]
710
#![feature(f128)]
811
#![allow(unused_macro_rules)]
9-
// Don't promote
10-
const fn nop<T>(x: T) -> T { x }
12+
13+
use std::hint::black_box;
1114

1215
macro_rules! const_assert {
1316
($a:expr) => {
1417
{
1518
const _: () = assert!($a);
16-
assert!(nop($a));
19+
assert!(black_box($a));
1720
}
1821
};
1922
($a:expr, $b:expr) => {
2023
{
2124
const _: () = assert!($a == $b);
22-
assert_eq!(nop($a), nop($b));
25+
assert_eq!(black_box($a), black_box($b));
2326
}
2427
};
2528
}
2629

2730
fn has_broken_floats() -> bool {
2831
// i586 targets are broken due to <https://github.com/rust-lang/rust/issues/114479>.
29-
std::env::var("TARGET").is_ok_and(|v| v.contains("i586"))
32+
cfg!(all(target_arch = "x86", not(target_feature = "sse2")))
3033
}
3134

3235
#[cfg(target_arch = "x86_64")]

tests/ui/consts/const-float-classify.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
//@ compile-flags: -Zmir-opt-level=0 -Znext-solver
2-
//@ known-bug: #110395
3-
// FIXME(effects) run-pass
2+
//@ run-pass
3+
4+
// This tests the float classification functions, not just for const evaluation
5+
// but also for regular runtime code.
46

57
#![feature(const_float_bits_conv)]
68
#![feature(const_float_classify)]
7-
#![feature(const_trait_impl, effects)]
8-
#![allow(incomplete_features)]
9-
10-
// Don't promote
11-
const fn nop<T>(x: T) -> T { x }
129

13-
impl const PartialEq<NonDet> for bool {
14-
fn eq(&self, _: &NonDet) -> bool {
15-
true
16-
}
17-
}
10+
use std::hint::black_box;
1811

1912
macro_rules! const_assert {
13+
($a:expr, NonDet) => {
14+
{
15+
const _: () = { let _val = $a; };
16+
let _val = black_box($a);
17+
}
18+
};
2019
($a:expr, $b:expr) => {
2120
{
2221
const _: () = assert!($a == $b);
23-
assert!(nop($a) == nop($b));
22+
assert!(black_box($a) == black_box($b));
2423
}
2524
};
2625
}
@@ -52,12 +51,9 @@ macro_rules! suite_inner {
5251
( $ty:ident [$( $fn:ident ),*]) => {};
5352
}
5453

55-
#[derive(Debug)]
56-
struct NonDet;
57-
58-
// The result of the `is_sign` methods are not checked for correctness, since LLVM does not
54+
// The result of the `is_sign` methods are not checked for correctness, since we do not
5955
// guarantee anything about the signedness of NaNs. See
60-
// https://github.com/rust-lang/rust/issues/55131.
56+
// https://rust-lang.github.io/rfcs/3514-float-semantics.html.
6157

6258
suite! {
6359
[is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
@@ -74,4 +70,5 @@ suite! {
7470
fn main() {
7571
f32();
7672
f64();
73+
// FIXME(f16_f128): also test f16 and f128
7774
}

0 commit comments

Comments
 (0)