Skip to content

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

Closed
@brendanzab

Description

@brendanzab
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions