# Ideas around anonymous enum types

**URL:** <https://internals.rust-lang.org/t/ideas-around-anonymous-enum-types/12627>\
**Category:** language design\
**Created:** [June 25, 2020, 5:36pm UTC](https://internals.rust-lang.org/t/ideas-around-anonymous-enum-types/12627 "2020-06-25T17:36:29Z")\
**Posts on this page:** 1\
**Showing post:** 163

<div class="post-metadata">

**Author:** ![steffahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steffahn/32/13288_2.png) [@steffahn](https://internals.rust-lang.org/u/steffahn)\
**Post date:** [August 4, 2020, 1:26pm UTC](https://internals.rust-lang.org/t/ideas-around-anonymous-enum-types/12627/163 "2020-08-04T13:26:18Z")

</div>

> [@steffahn](#):
>
> I feel like there _might be_ problems from this indeed

Yep, you must not “override” any blanket implementations for `Any`, otherwise this would be a problem:

```rust
use std::any::Any;

fn main() {
    let x: enum(i32, bool) = 42;
    // ^^^ implements Any based on dispatch
    let y: &dyn Any = &x;
    // ^^^ unsize coercion: enum(i32, bool) is sized and implements Any
    let z: &i32 = y.downcast_ref::<i32>().unwrap()
    // ^^^ created internally by casting y, so we get an invalid reference (UB)
    // ^^^ succeeds since y.type_id() gives is TypeId of `i32` by dispatch
    // see: https://doc.rust-lang.org/src/core/any.rs.html#195-204
}

```

---

_[View the full topic](https://internals.rust-lang.org/t/ideas-around-anonymous-enum-types/12627)._
