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: resolve_trait_associated_const: unexpected vtable type #29924

Closed
oli-obk opened this issue Nov 19, 2015 · 8 comments
Closed

ICE: resolve_trait_associated_const: unexpected vtable type #29924

oli-obk opened this issue Nov 19, 2015 · 8 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Nov 19, 2015

the following code ices on nightly:

#![feature(const_fn, associated_consts)]

trait Trait {
    const N: usize;
}

impl Trait {
    const fn n() -> usize { Self::N }
}

It should give an error instead noting that you can't do Self::N.

@apasel422 apasel422 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 19, 2015
@bltavares
Copy link
Contributor

Triaging: this issue is already being tracked on https://github.com/steveklabnik/glacier

Reference: rust-lang/glacier#144

@niconii
Copy link
Contributor

niconii commented Jan 2, 2017

Still happens as of rustc 1.16.0-nightly (4ecc85beb 2016-12-28).

@aiwenar
Copy link

aiwenar commented Feb 7, 2017

As of rustc 1.17.0-nightly (ea7a6486a 2017-02-04) this can also be hit with <Trait as Trait>::CONST

#![feature(associated_consts)]

trait Trait {
  const N: usize;
}

fn n() -> usize {
  <Trait as Trait>::N
}

@Mark-Simulacrum
Copy link
Member

The first example doesn't compile due to the trait not being object safe and the last example also doesn't compile today. Neither ICEs; E-needstest.

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 22, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@kvark
Copy link
Contributor

kvark commented Sep 1, 2017

@Mark-Simulacrum
Here is a new case:

pub enum Foo {}
pub trait Food {
    const FOO: Foo;
}
pub trait Bard {
    type Foo: Food;
    fn get_foo() -> Foo { Self::Foo::FOO }
}

Error on Rust-1.20 (playground):

error: internal compiler error: /checkout/src/librustc_const_eval/eval.rs:529: resolve_trait_associated_const: unexpected vtable type

Note: this is sort of a blocker for us to get use of the associated consts.

@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 1, 2017

@kvark this is already fixed on beta/nightly

@kvark
Copy link
Contributor

kvark commented Sep 1, 2017

@oli-obk great, but what about stable? No hot patches planned?

@Mark-Simulacrum
Copy link
Member

We generally do not backport patches to stable unless they are critical bug fixes (for which I don't think I can give a concrete definition). We should have a stable out with the fix in 6 weeks, though.

@Mark-Simulacrum Mark-Simulacrum added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Sep 1, 2017
topecongiro added a commit to topecongiro/rust that referenced this issue Dec 30, 2017
bors added a commit that referenced this issue Dec 31, 2017
Add tests on fixed ICEs

Closes #29924. Closes #38857. Closes #39665. Closes #39872.
Closes #41210. Closes #41880. Closes #43483.

Note that compile-fail/E0599.rs is for #41210.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

8 participants