diff options
| author | Trevor Gross <tmgross@umich.edu> | 2024-03-26 06:01:09 -0400 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2024-06-23 04:28:42 -0500 |
| commit | 6fb6c19c961369b98e2dd9466c1a83ac2d783ae2 (patch) | |
| tree | 685a1447dd914e65f19e28da055902571d3467f1 /tests/ui/pattern | |
| parent | acb62737aca7045f331e7a05adc38bed213e278d (diff) | |
| download | rust-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/pattern')
| -rw-r--r-- | tests/ui/pattern/usefulness/floats.rs | 48 | ||||
| -rw-r--r-- | tests/ui/pattern/usefulness/floats.stderr | 72 |
2 files changed, 97 insertions, 23 deletions
diff --git a/tests/ui/pattern/usefulness/floats.rs b/tests/ui/pattern/usefulness/floats.rs index b3d49ba8e15..0b27e33e4ef 100644 --- a/tests/ui/pattern/usefulness/floats.rs +++ b/tests/ui/pattern/usefulness/floats.rs @@ -1,4 +1,6 @@ #![deny(unreachable_patterns)] +#![feature(f128)] +#![feature(f16)] fn main() { match 0.0 { @@ -11,6 +13,32 @@ fn main() { 0.0..=1.0 => {} } + match 1.0f16 { + 0.01f16..=6.5f16 => {} + 0.01f16 => {} //~ ERROR unreachable pattern + 0.02f16 => {} //~ ERROR unreachable pattern + 6.5f16 => {} //~ ERROR unreachable pattern + _ => {} + }; + match 1.0f16 { + 0.01f16..6.5f16 => {} + 6.5f16 => {} // this is reachable + _ => {} + }; + + match 1.0f32 { + 0.01f32..=6.5f32 => {} + 0.01f32 => {} //~ ERROR unreachable pattern + 0.02f32 => {} //~ ERROR unreachable pattern + 6.5f32 => {} //~ ERROR unreachable pattern + _ => {} + }; + match 1.0f32 { + 0.01f32..6.5f32 => {} + 6.5f32 => {} // this is reachable + _ => {} + }; + match 1.0f64 { 0.01f64..=6.5f64 => {} 0.005f64 => {} @@ -28,16 +56,20 @@ fn main() { _ => {} }; - match 1.0f32 { - 0.01f32..=6.5f32 => {} - 0.01f32 => {} //~ ERROR unreachable pattern - 0.02f32 => {} //~ ERROR unreachable pattern - 6.5f32 => {} //~ ERROR unreachable pattern + match 1.0f128 { + 0.01f128..=6.5f128 => {} + 0.005f128 => {} + 0.01f128 => {} //~ ERROR unreachable pattern + 0.02f128 => {} //~ ERROR unreachable pattern + 6.5f128 => {} //~ ERROR unreachable pattern + 6.6f128 => {} + 1.0f128..=4.0f128 => {} //~ ERROR unreachable pattern + 5.0f128..=7.0f128 => {} _ => {} }; - match 1.0f32 { - 0.01f32..6.5f32 => {} - 6.5f32 => {} // this is reachable + match 1.0f128 { + 0.01f128..6.5f128 => {} + 6.5f128 => {} // this is reachable _ => {} }; } diff --git a/tests/ui/pattern/usefulness/floats.stderr b/tests/ui/pattern/usefulness/floats.stderr index 04f2fe3cd94..684f6c93a16 100644 --- a/tests/ui/pattern/usefulness/floats.stderr +++ b/tests/ui/pattern/usefulness/floats.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/floats.rs:9:11 + --> $DIR/floats.rs:11:11 | LL | match 0.0 { | ^^^ pattern `_` not covered @@ -12,9 +12,9 @@ LL + _ => todo!() | error: unreachable pattern - --> $DIR/floats.rs:17:9 + --> $DIR/floats.rs:18:9 | -LL | 0.01f64 => {} +LL | 0.01f16 => {} | ^^^^^^^ | note: the lint level is defined here @@ -24,41 +24,83 @@ LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/floats.rs:18:9 + --> $DIR/floats.rs:19:9 + | +LL | 0.02f16 => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:20:9 + | +LL | 6.5f16 => {} + | ^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:31:9 + | +LL | 0.01f32 => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:32:9 + | +LL | 0.02f32 => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:33:9 + | +LL | 6.5f32 => {} + | ^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:45:9 + | +LL | 0.01f64 => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:46:9 | LL | 0.02f64 => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/floats.rs:19:9 + --> $DIR/floats.rs:47:9 | LL | 6.5f64 => {} | ^^^^^^ error: unreachable pattern - --> $DIR/floats.rs:21:9 + --> $DIR/floats.rs:49:9 | LL | 1.0f64..=4.0f64 => {} | ^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/floats.rs:33:9 + --> $DIR/floats.rs:62:9 | -LL | 0.01f32 => {} - | ^^^^^^^ +LL | 0.01f128 => {} + | ^^^^^^^^ error: unreachable pattern - --> $DIR/floats.rs:34:9 + --> $DIR/floats.rs:63:9 | -LL | 0.02f32 => {} +LL | 0.02f128 => {} + | ^^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:64:9 + | +LL | 6.5f128 => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/floats.rs:35:9 + --> $DIR/floats.rs:66:9 | -LL | 6.5f32 => {} - | ^^^^^^ +LL | 1.0f128..=4.0f128 => {} + | ^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 15 previous errors For more information about this error, try `rustc --explain E0004`. |
