Rollup merge of #76199 - Mark-Simulacrum:void-zero, r=nikomatsakis
Permit uninhabited enums to cast into ints This essentially reverts part of #6204; it is unclear why that [commit](https://github.com/rust-lang/rust/pull/6204/commits/c0f587de34f30b060df8a88c4068740e587b9340) was introduced, and I suspect no one remembers. The changed code was only called from casting checks and appears to not affect any callers of that code (other than permitting this one case). Fixes #75647.
This commit is contained in:
commit
496e2feed6
4 changed files with 12 additions and 12 deletions
|
|
@ -1,7 +1,9 @@
|
|||
// check-pass
|
||||
|
||||
enum E {}
|
||||
|
||||
fn f(e: E) {
|
||||
println!("{}", (e as isize).to_string()); //~ ERROR non-primitive cast
|
||||
println!("{}", (e as isize).to_string());
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0605]: non-primitive cast: `E` as `isize`
|
||||
--> $DIR/uninhabited-enum-cast.rs:4:20
|
||||
|
|
||||
LL | println!("{}", (e as isize).to_string());
|
||||
| ^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0605`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue