rust
rust copied to clipboard
Crash with C-style enums
This snippet crashes the compiler:
enum foo {
a = 1,
b = 2,
c = a | b
}
With this error:
$ rustc bug.rs
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
Using an expression that I'd actually expect to work (like c = a as int | b as int) also yields a suspicious looking message:
error: internal compiler error: node_id_to_type: no type for node `expr a as int (id=11)`
Nominating for well-defined.
just a bug, removing milestone/nomination.
accepted for production-ready milestone
The latter form (with the casts) still ICEs. The former form now gives a more pleasant error:
t.rs:4:8: 4:13 error: Bad operands for binary
t.rs:4 c = a | b
^~~~~
But still doesn't compile.
This works if you cast the variants first, which is expected.
Closing.