about summary refs log tree commit diff
path: root/tests/ui/half-open-range-patterns
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2024-03-26 06:01:09 -0400
committerTrevor Gross <tmgross@umich.edu>2024-06-23 04:28:42 -0500
commit6fb6c19c961369b98e2dd9466c1a83ac2d783ae2 (patch)
tree685a1447dd914e65f19e28da055902571d3467f1 /tests/ui/half-open-range-patterns
parentacb62737aca7045f331e7a05adc38bed213e278d (diff)
downloadrust-6fb6c19c961369b98e2dd9466c1a83ac2d783ae2.tar.gz
rust-6fb6c19c961369b98e2dd9466c1a83ac2d783ae2.zip
Replace `f16` and `f128` pattern matching stubs with real implementations
This section of code depends on `rustc_apfloat` rather than our internal
types, so this is one potential ICE that we should be able to melt now.

This also fixes some missing range and match handling in `rustc_middle`.
Diffstat (limited to 'tests/ui/half-open-range-patterns')
-rw-r--r--tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs78
-rw-r--r--tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs1
-rw-r--r--tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr6
3 files changed, 82 insertions, 3 deletions
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 3487bac5282..38ade060cb1 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
@@ -4,6 +4,8 @@
 // via `.contains(...)` and make sure the dynamic semantics match.
 
 #![allow(unreachable_patterns)]
+#![feature(f128)]
+#![feature(f16)]
 
 macro_rules! yes {
     ($scrutinee:expr, $($t:tt)+) => {
@@ -39,6 +41,17 @@ fn range_to_inclusive() {
     assert!(yes!('a', ..='a'));
     assert!(!yes!('b', ..='a'));
 
+    // f16; `..=X`
+    // FIXME(f16_f128): remove gate when ABI issues are resolved
+    #[cfg(all(target_arch = "aarch64", target_os = "linux"))]
+    {
+        // FIXME(f16_f128): enable infinity tests when constants are available
+        // assert!(yes!(f16::NEG_INFINITY, ..=f16::NEG_INFINITY));
+        // assert!(yes!(f16::NEG_INFINITY, ..=1.0f16));
+        assert!(yes!(1.5f16, ..=1.5f16));
+        assert!(!yes!(1.6f16, ..=-1.5f16));
+    }
+
     // f32; `..=X`
     assert!(yes!(f32::NEG_INFINITY, ..=f32::NEG_INFINITY));
     assert!(yes!(f32::NEG_INFINITY, ..=1.0f32));
@@ -50,6 +63,17 @@ fn range_to_inclusive() {
     assert!(yes!(f64::NEG_INFINITY, ..=1.0f64));
     assert!(yes!(1.5f64, ..=1.5f64));
     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"))]
+    {
+        // FIXME(f16_f128): enable infinity tests when constants are available
+        // assert!(yes!(f128::NEG_INFINITY, ..=f128::NEG_INFINITY));
+        // assert!(yes!(f128::NEG_INFINITY, ..=1.0f128));
+        assert!(yes!(1.5f128, ..=1.5f128));
+        assert!(!yes!(1.6f128, ..=-1.5f128));
+    }
 }
 
 fn range_to() {
@@ -83,6 +107,18 @@ fn range_to() {
     assert!(!yes!('a', ..'a'));
     assert!(!yes!('b', ..'a'));
 
+    // f16; `..X`
+    // FIXME(f16_f128): remove gate when ABI issues are resolved
+    #[cfg(all(target_arch = "aarch64", target_os = "linux"))]
+    {
+        // FIXME(f16_f128): enable infinity tests when constants are available
+        // assert!(yes!(f16::NEG_INFINITY, ..1.0f16));
+        assert!(!yes!(1.5f16, ..1.5f16));
+        const E16: f16 = 1.5f16 + f16::EPSILON;
+        assert!(yes!(1.5f16, ..E16));
+        assert!(!yes!(1.6f16, ..1.5f16));
+    }
+
     // f32; `..X`
     assert!(yes!(f32::NEG_INFINITY, ..1.0f32));
     assert!(!yes!(1.5f32, ..1.5f32));
@@ -96,6 +132,18 @@ fn range_to() {
     const E64: f64 = 1.5f64 + f64::EPSILON;
     assert!(yes!(1.5f64, ..E64));
     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"))]
+    {
+        // FIXME(f16_f128): enable infinity tests when constants are available
+        // assert!(yes!(f128::NEG_INFINITY, ..1.0f128));
+        assert!(!yes!(1.5f128, ..1.5f128));
+        const E128: f128 = 1.5f128 + f128::EPSILON;
+        assert!(yes!(1.5f128, ..E128));
+        assert!(!yes!(1.6f128, ..1.5f128));
+    }
 }
 
 fn range_from() {
@@ -129,6 +177,21 @@ fn range_from() {
     assert!(!yes!('a', 'b'..));
     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"))]
+    {
+        // FIXME(f16_f128): enable infinity tests when constants are available
+        // assert!(yes!(f16::NEG_INFINITY, f16::NEG_INFINITY..));
+        // assert!(yes!(f16::INFINITY, f16::NEG_INFINITY..));
+        // assert!(!yes!(f16::NEG_INFINITY, 1.0f16..));
+        // assert!(yes!(f16::INFINITY, 1.0f16..));
+        assert!(!yes!(1.0f16 - f16::EPSILON, 1.0f16..));
+        assert!(yes!(1.0f16, 1.0f16..));
+        // assert!(yes!(f16::INFINITY, 1.0f16..));
+        // assert!(yes!(f16::INFINITY, f16::INFINITY..));
+    }
+
     // f32; `X..`
     assert!(yes!(f32::NEG_INFINITY, f32::NEG_INFINITY..));
     assert!(yes!(f32::INFINITY, f32::NEG_INFINITY..));
@@ -148,6 +211,21 @@ fn range_from() {
     assert!(yes!(1.0f64, 1.0f64..));
     assert!(yes!(f64::INFINITY, 1.0f64..));
     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"))]
+    {
+        // FIXME(f16_f128): enable infinity tests when constants are available
+        // assert!(yes!(f128::NEG_INFINITY, f128::NEG_INFINITY..));
+        // assert!(yes!(f128::INFINITY, f128::NEG_INFINITY..));
+        // assert!(!yes!(f128::NEG_INFINITY, 1.0f128..));
+        // assert!(yes!(f128::INFINITY, 1.0f128..));
+        assert!(!yes!(1.0f128 - f128::EPSILON, 1.0f128..));
+        assert!(yes!(1.0f128, 1.0f128..));
+        // assert!(yes!(f128::INFINITY, 1.0f128..));
+        // assert!(yes!(f128::INFINITY, f128::INFINITY..));
+    }
 }
 
 fn main() {
diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs
index 9ca8dd25ed7..a35bb51acbc 100644
--- a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs
+++ b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs
@@ -27,6 +27,7 @@ fn main() {
     m!(0, ..i128::MIN);
     //~^ ERROR lower range bound must be less than upper
 
+    // FIXME(f16_f128): add tests when NEG_INFINITY is available
     m!(0f32, ..f32::NEG_INFINITY);
     //~^ ERROR lower range bound must be less than upper
     m!(0f64, ..f64::NEG_INFINITY);
diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr
index 668b5c858f0..fb2f1841a6d 100644
--- a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr
+++ b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr
@@ -59,19 +59,19 @@ LL |     m!(0, ..i128::MIN);
    |           ^^^^^^^^^^^
 
 error[E0579]: lower range bound must be less than upper
-  --> $DIR/half-open-range-pats-thir-lower-empty.rs:30:14
+  --> $DIR/half-open-range-pats-thir-lower-empty.rs:31:14
    |
 LL |     m!(0f32, ..f32::NEG_INFINITY);
    |              ^^^^^^^^^^^^^^^^^^^
 
 error[E0579]: lower range bound must be less than upper
-  --> $DIR/half-open-range-pats-thir-lower-empty.rs:32:14
+  --> $DIR/half-open-range-pats-thir-lower-empty.rs:33:14
    |
 LL |     m!(0f64, ..f64::NEG_INFINITY);
    |              ^^^^^^^^^^^^^^^^^^^
 
 error[E0579]: lower range bound must be less than upper
-  --> $DIR/half-open-range-pats-thir-lower-empty.rs:35:13
+  --> $DIR/half-open-range-pats-thir-lower-empty.rs:36:13
    |
 LL |     m!('a', ..'\u{0}');
    |             ^^^^^^^^^