diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-09-19 01:29:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-19 01:29:42 +0200 |
| commit | 970ee09c2241f738fe7513460bcd0ad086fee82e (patch) | |
| tree | 9cedbcabcd03f1d92d84735a96769c66e04114e6 /tests | |
| parent | 48c605129beeae01a82ed35fd70ca56d6bf196ba (diff) | |
| parent | 9c5de75ce10fa6fe88f9ec7c133c9a138e09dabc (diff) | |
| download | rust-970ee09c2241f738fe7513460bcd0ad086fee82e.tar.gz rust-970ee09c2241f738fe7513460bcd0ad086fee82e.zip | |
Rollup merge of #115879 - clubby789:migrate-hir-typeck-cast, r=compiler-errors
Migrate diagnostics in `hir_typeck/src/cast.rs`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/cast/cast-as-bool.rs | 4 | ||||
| -rw-r--r-- | tests/ui/cast/cast-as-bool.stderr | 28 | ||||
| -rw-r--r-- | tests/ui/cast/cast-rfc0401-2.stderr | 7 | ||||
| -rw-r--r-- | tests/ui/error-codes/E0054.stderr | 7 | ||||
| -rw-r--r-- | tests/ui/error-festival.stderr | 7 | ||||
| -rw-r--r-- | tests/ui/mismatched_types/cast-rfc0401.stderr | 7 |
6 files changed, 50 insertions, 10 deletions
diff --git a/tests/ui/cast/cast-as-bool.rs b/tests/ui/cast/cast-as-bool.rs index 750a88f97eb..511a02718fe 100644 --- a/tests/ui/cast/cast-as-bool.rs +++ b/tests/ui/cast/cast-as-bool.rs @@ -1,11 +1,11 @@ fn main() { let u = 5 as bool; //~ ERROR cannot cast `i32` as `bool` //~| HELP compare with zero instead - //~| SUGGESTION 5 != 0 + //~| SUGGESTION != 0 let t = (1 + 2) as bool; //~ ERROR cannot cast `i32` as `bool` //~| HELP compare with zero instead - //~| SUGGESTION (1 + 2) != 0 + //~| SUGGESTION != 0 let _ = 5_u32 as bool; //~ ERROR cannot cast `u32` as `bool` //~| HELP compare with zero instead diff --git a/tests/ui/cast/cast-as-bool.stderr b/tests/ui/cast/cast-as-bool.stderr index 852fb30cc20..4ff56a95e49 100644 --- a/tests/ui/cast/cast-as-bool.stderr +++ b/tests/ui/cast/cast-as-bool.stderr @@ -2,25 +2,45 @@ error[E0054]: cannot cast `i32` as `bool` --> $DIR/cast-as-bool.rs:2:13 | LL | let u = 5 as bool; - | ^^^^^^^^^ help: compare with zero instead: `5 != 0` + | ^^^^^^^^^ + | +help: compare with zero instead + | +LL | let u = 5 != 0; + | ~~~~ error[E0054]: cannot cast `i32` as `bool` --> $DIR/cast-as-bool.rs:6:13 | LL | let t = (1 + 2) as bool; - | ^^^^^^^^^^^^^^^ help: compare with zero instead: `(1 + 2) != 0` + | ^^^^^^^^^^^^^^^ + | +help: compare with zero instead + | +LL | let t = (1 + 2) != 0; + | ~~~~ error[E0054]: cannot cast `u32` as `bool` --> $DIR/cast-as-bool.rs:10:13 | LL | let _ = 5_u32 as bool; - | ^^^^^^^^^^^^^ help: compare with zero instead: `5_u32 != 0` + | ^^^^^^^^^^^^^ + | +help: compare with zero instead + | +LL | let _ = 5_u32 != 0; + | ~~~~ error[E0054]: cannot cast `f64` as `bool` --> $DIR/cast-as-bool.rs:13:13 | LL | let _ = 64.0_f64 as bool; - | ^^^^^^^^^^^^^^^^ help: compare with zero instead: `64.0_f64 != 0` + | ^^^^^^^^^^^^^^^^ + | +help: compare with zero instead + | +LL | let _ = 64.0_f64 != 0; + | ~~~~ error[E0054]: cannot cast `IntEnum` as `bool` --> $DIR/cast-as-bool.rs:24:13 diff --git a/tests/ui/cast/cast-rfc0401-2.stderr b/tests/ui/cast/cast-rfc0401-2.stderr index 5dc21ca847c..dd90c3a9723 100644 --- a/tests/ui/cast/cast-rfc0401-2.stderr +++ b/tests/ui/cast/cast-rfc0401-2.stderr @@ -2,7 +2,12 @@ error[E0054]: cannot cast `i32` as `bool` --> $DIR/cast-rfc0401-2.rs:6:13 | LL | let _ = 3 as bool; - | ^^^^^^^^^ help: compare with zero instead: `3 != 0` + | ^^^^^^^^^ + | +help: compare with zero instead + | +LL | let _ = 3 != 0; + | ~~~~ error: aborting due to previous error diff --git a/tests/ui/error-codes/E0054.stderr b/tests/ui/error-codes/E0054.stderr index ea81f4476a7..0a4adabbaf6 100644 --- a/tests/ui/error-codes/E0054.stderr +++ b/tests/ui/error-codes/E0054.stderr @@ -2,7 +2,12 @@ error[E0054]: cannot cast `i32` as `bool` --> $DIR/E0054.rs:3:24 | LL | let x_is_nonzero = x as bool; - | ^^^^^^^^^ help: compare with zero instead: `x != 0` + | ^^^^^^^^^ + | +help: compare with zero instead + | +LL | let x_is_nonzero = x != 0; + | ~~~~ error: aborting due to previous error diff --git a/tests/ui/error-festival.stderr b/tests/ui/error-festival.stderr index 74a2bc8d768..9d75671c4e6 100644 --- a/tests/ui/error-festival.stderr +++ b/tests/ui/error-festival.stderr @@ -63,7 +63,12 @@ error[E0054]: cannot cast `{integer}` as `bool` --> $DIR/error-festival.rs:33:24 | LL | let x_is_nonzero = x as bool; - | ^^^^^^^^^ help: compare with zero instead: `x != 0` + | ^^^^^^^^^ + | +help: compare with zero instead + | +LL | let x_is_nonzero = x != 0; + | ~~~~ error[E0606]: casting `&u8` as `u32` is invalid --> $DIR/error-festival.rs:37:18 diff --git a/tests/ui/mismatched_types/cast-rfc0401.stderr b/tests/ui/mismatched_types/cast-rfc0401.stderr index 0cea60746bf..d63cec48917 100644 --- a/tests/ui/mismatched_types/cast-rfc0401.stderr +++ b/tests/ui/mismatched_types/cast-rfc0401.stderr @@ -86,7 +86,12 @@ error[E0054]: cannot cast `i32` as `bool` --> $DIR/cast-rfc0401.rs:39:13 | LL | let _ = 3_i32 as bool; - | ^^^^^^^^^^^^^ help: compare with zero instead: `3_i32 != 0` + | ^^^^^^^^^^^^^ + | +help: compare with zero instead + | +LL | let _ = 3_i32 != 0; + | ~~~~ error[E0054]: cannot cast `E` as `bool` --> $DIR/cast-rfc0401.rs:40:13 |
