about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-02-09 19:21:18 +0100
committerGitHub <noreply@github.com>2024-02-09 19:21:18 +0100
commitd9a957b32ab798724f8d332b26f94b42f2e9850f (patch)
treed45f18e83cdd1466e12588310acf20c9fcb481c7 /compiler/rustc_codegen_llvm/src
parent40f998d7e92ddd4efb2414c45d0632eabe2351df (diff)
parent6e37f955e57454d25ef590b5215a6f20cecb9e2e (diff)
downloadrust-d9a957b32ab798724f8d332b26f94b42f2e9850f.tar.gz
rust-d9a957b32ab798724f8d332b26f94b42f2e9850f.zip
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.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions