Skip to content

Autoref faulty on universal trait implementations #14229

Closed
@SiegeLord

Description

@SiegeLord

Consider this code:

trait Foo
{
    fn foo(self) {}
}

trait Bar
{
    fn bar(self) {}
}

struct S;

impl<'l> Foo for &'l S {}

impl<T: Foo> Bar for T {}

fn main()
{
    let s = S;
    s.foo(); // Works fine
    (&s).bar(); // Works fine
    s.bar(); // Doesn't work
}

The error is:

test.rs:22:5: 22:12 error: failed to find an implementation of trait Foo for S
test.rs:22     s.bar();

It'd be nice if the explicit ref wasn't required in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions