Skip to content

Incorrect inherent method resolution with multiple impls #9938

Closed
@jonas-schievink

Description

@jonas-schievink
struct S<T>(T);

trait Tr {}

impl<T: Tr> S<T> {
    fn call(&self, arg: u8) {}
}

impl S<()> {
    fn call(&self) {}
}

fn main() {
    S(()).call();
}

This gets a false-positive mismatched-arg-count diagnostic, because we choose the first impl block (despite the missing (): Tr impl), while the second one is actually correct.

This causes issues when using wasmer or wasm3, since they expose function handles with impls like these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions