Skip to content

ICE when accessing value on a enum variant #38939

Closed
@bombless

Description

@bombless
#![feature(associated_consts)]

trait Foo {
    const X: u8 = 42;
    fn test();
}

enum Bar {
    X
}

impl Foo for Bar {
    fn test() {
        println!("{}", Self::X);
    }
}

fn main() {
    Bar::X::test();
}

https://is.gd/uL2NUM

rustc 1.16.0-nightly (7e38a89a7 2017-01-06)
error: internal compiler error: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_typeck/astconv.rs:1516: unexpected definition: Variant(DefId { krate: CrateNum(0), node: DefIndex(8) => rust_out/4089d7c8b778d88cec885baf7b69e6df-exe::Bar[0]::X[0] })
  �(B�[m--> <anon>:19:5�(B�[m
   �(B�[m|
19 �(B�[m|     Bar::X::test();�(B�[m
   �(B�[m|     �(B�[m^^^^^^^^^^^^

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

thread 'rustc' panicked at 'Box<Any>', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_errors/lib.rs:382
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions