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

Associated constant using associated type generates E0277 #30396

Closed
Popog opened this issue Dec 15, 2015 · 2 comments
Closed

Associated constant using associated type generates E0277 #30396

Popog opened this issue Dec 15, 2015 · 2 comments
Labels
A-associated-items Area: Associated items such as associated types and consts.

Comments

@Popog
Copy link

Popog commented Dec 15, 2015

Either a bug or a bad error message.

#![feature(associated_consts)]

trait Foo {
    type Associated;
    const ID: Self::Associated;
}

impl Foo for i32 {
    type Associated = f32;
    const ID: f32 = 1f32;
}

fn main() {
    assert_eq!(1f32, i32::ID);
}

Results in

<anon>:5:5: 5:32 error: the trait `Foo` is not implemented for the type `Self` [E0277]
<anon>:5     const ID: Self::Associated;
@Popog
Copy link
Author

Popog commented Dec 15, 2015

Not sure if it's easier or harder to debug, but it also occurs when separated into 2 traits:

#![feature(associated_consts)]

trait Foo {
    type Associated;
}

trait FooConst: Foo {
    const ID: <Self as Foo>::Associated;
}

impl Foo for i32 {
    type Associated = f32;
}

impl FooConst for i32 {
    const ID: f32 = 1f32;
}

fn main() {
    assert_eq!(1f32, i32::ID);
}

@steveklabnik steveklabnik added the A-associated-items Area: Associated items such as associated types and consts. label Dec 18, 2015
@Popog
Copy link
Author

Popog commented Oct 15, 2016

No longer repros as of rustc 1.14.0-nightly (6e8f92f 2016-10-07).

@Popog Popog closed this as completed Oct 15, 2016
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 such as associated types and consts.
Projects
None yet
Development

No branches or pull requests

2 participants