Emit more specific diagnostics when enums fail to cast with `as` Fixes #120756 Changes this diagnostic reported in the issue: ``` error[E0605]: non-primitive cast: `Bad` as `u32` --> src/main.rs:18:10 | 18 | dbg!(bad as u32); | ^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object ``` to this: ``` error[E0605]: non-primitive cast: `Bad` as `u32` --> src/main.rs:18:10 | 18 | dbg!(bad as u32); | ^^^^^^^^^^ an `as` expression can be used to convert enum types to numeric types only if the enum type is unit-only or field-less | = note: see https://doc.rust-lang.org/reference/items/enumerations.html#casting for more information ``` This change is only for enums. The diagnostic remains unchanged for all other cases. |
||
|---|---|---|
| .. | ||
| assembly | ||
| auxiliary | ||
| codegen | ||
| codegen-units | ||
| coverage | ||
| coverage-run-rustdoc | ||
| debuginfo | ||
| incremental | ||
| mir-opt | ||
| pretty | ||
| run-make | ||
| run-make-fulldeps | ||
| run-pass-valgrind | ||
| rustdoc | ||
| rustdoc-gui | ||
| rustdoc-js | ||
| rustdoc-js-std | ||
| rustdoc-json | ||
| rustdoc-ui | ||
| ui | ||
| ui-fulldeps | ||
| COMPILER_TESTS.md | ||