Skip to content

Commit 43dee8b

Browse files
authored
Rollup merge of #120822 - gurry:120756-terse-non-prim-cast-diag, r=petrochenkov
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.
2 parents 9662a4b + fc596cd commit 43dee8b

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)