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

"unable to find implementation of trait" with a combination of a generic trait & a static method #4306

Closed
brendanzab opened this issue Dec 28, 2012 · 9 comments
Labels
A-traits Area: Trait system

Comments

@brendanzab
Copy link
Member

struct Foo<T>(T);

impl<T> Foo<T> {
    static pure fn foo<U>(theta: U) -> Foo<T> {
        Bar::bar(theta)
    }
}

impl<T> Foo<T>: Bar<T> {
    static pure fn bar<U>(_theta: U) -> Foo<T> { fail(~"") }
}

trait Bar<T> {
    static pure fn bar<U>(theta: U) -> self;
}

fn main() {}
$ rustc cross_mod_traits.rs
test.rs:5:8: 5:16 error: failed to find an implementation of trait @Bar<<V1>> for <V2>
test.rs:5         Bar::bar(theta)

When I remove the type parameters on any of the items it compiles.

@ghost ghost assigned catamorphism Jan 24, 2013
@brendanzab
Copy link
Member Author

@catamorphism (nag nag)

@graydon
Copy link
Contributor

graydon commented Mar 25, 2013

reproduced on 2013-03-25

@graydon
Copy link
Contributor

graydon commented Mar 25, 2013

non-critical for 0.6, de-milestoning

@metajack
Copy link
Contributor

Still reproducible. Here's the updated example:

struct Foo<T>(T);

impl<T> Foo<T> {
    fn foo<U>(theta: U) -> Foo<T> {
        Bar::bar(theta)
    }
}

impl<T> Bar<T> for Foo<T> {
    fn bar<U>(_theta: U) -> Foo<T> { fail!(~"") }
}

trait Bar<T> {
    fn bar<U>(theta: U) -> Self;
}

fn main() {}

I'm not sure how important this is. Nominating for production ready.

@graydon
Copy link
Contributor

graydon commented May 16, 2013

accepted for production-ready milestone

@graydon
Copy link
Contributor

graydon commented May 16, 2013

see also #5527, this is somewhat of a sub-bug or case to define.

@emberian
Copy link
Member

Still reproducible.

@msullivan
Copy link
Contributor

OK, this seems fixed.

@emberian
Copy link
Member

@msullivan is there a test case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system
Projects
None yet
Development

No branches or pull requests

6 participants