Skip to content

Anonymous impls on traits do not work #4075

@brson

Description

@brson

Neither of these are able to resolve foo.

trait A { }

impl A {
    fn foo() -> int { 10 }
}

impl int: A { }

fn main() {
    let x = &0;
    let y = x as &A;
    y.foo();
}
trait A { }

impl A {
    fn foo() -> int { 10 }
}

impl int: A { }

fn f<T: A>(x: &T) {
    assert x.foo() == 10;
}

fn main() { }

This pattern is makes semantic sense, though it is odd and possibly useless.

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