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

"Unsupported associated type binding" when declaring local variable with associated type in default method #19850

Closed
kennytm opened this issue Dec 14, 2014 · 0 comments · Fixed by #20404
Labels
A-associated-items Area: Associated items (types, constants & functions)

Comments

@kennytm
Copy link
Member

kennytm commented Dec 14, 2014

Test case:

#![feature(associated_types)]

trait Int {
    fn one() -> Self;
    fn leading_zeros(self) -> uint;
}

trait Foo {
    type T : Int;

    fn test(&self) -> uint {
        let r: <Self as Foo>::T = Int::one();
        r.leading_zeros()
    }
}

fn main() {
}

Currently fails with:

1.rs:12:25: 12:28 error: unsupported associated type binding
1.rs:12         let r: <Self as Foo>::T = Int::one();
                                ^~~
error: aborting due to previous error

This can be worked around by making that Int::one() expression into a method of the trait returning <Self as Foo>::T, but then that method would become public as well, which may not be desirable.

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)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants