Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when accessing value on a enum variant #38939

Closed
bombless opened this issue Jan 9, 2017 · 2 comments
Closed

ICE when accessing value on a enum variant #38939

bombless opened this issue Jan 9, 2017 · 2 comments

Comments

@bombless
Copy link
Contributor

bombless commented Jan 9, 2017

#![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.
@bombless
Copy link
Contributor Author

bombless commented Jan 9, 2017

Seems that the real issue is about accessing a value on a enum variant.

enum Bar {
    X
}


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

The ICE is only triggered on nightly, no feature-gate required.

@bombless bombless changed the title ICE when using associated_consts ICE when accessing value on a enum variant Jan 9, 2017
@petrochenkov
Copy link
Contributor

Duplicate of #38862, fixed in #38925

@bombless bombless closed this as completed Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants