Skip to content

Duplicate methods defined in multiple inherent impls do not report as duplicates #32491

Closed
@shepmaster

Description

@shepmaster

Given this code:

struct A;

impl A {
    fn get(&self) -> u8 { 42 }
}

impl A {
    fn get(&self) -> u8 { 24 }
}

fn main() {
    let a = A;
    a.get();
}

I would expect to get

error: duplicate method

but instead I get

error: multiple applicable items in scope

As far as I am aware, there's no way to actually pick one of the multiple methods, is there?

This seems to be highly related to #22889, but the same behavior occurs with the nightly on the playground, even when using static methods instead of instance methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions