]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #89234 - nbdd0121:discr, r=jackh726
authorMatthias Krüger <matthias.krueger@famsik.de>
Thu, 2 Dec 2021 14:52:00 +0000 (15:52 +0100)
committerGitHub <noreply@github.com>
Thu, 2 Dec 2021 14:52:00 +0000 (15:52 +0100)
commit0666a33a6b8d39112f77cff65b6742092cfa736a
treeb3a16008d55866bffbea5f99886f504e4fb6a84e
parentd9baa361902b172be716f96619b909f340802dea
parentf7ef1c9f4163df30ae67ab177d5c306cb90b3d47
Rollup merge of #89234 - nbdd0121:discr, r=jackh726

Disallow non-c-like but "fieldless" ADTs from being casted to integer if they use arbitrary enum discriminant

Code like

```rust
#[repr(u8)]
enum Enum {
    Foo /* = 0 */,
    Bar(),
    Baz{}
}

let x = Enum::Bar() as u8;
```

seems to be unintentionally allowed so we couldn't disallow them now ~~, but we could disallow them if arbitrary enum discriminant is used before 1.56 hits stable~~ (stabilization was reverted).

Related: #88621

`@rustbot` label +T-lang