Skip to content

Duplicate argument names silently allowed in trait methods and fn pointers. #140087

Closed as duplicate of#33995
@theemathas

Description

@theemathas

I tried this code:

pub trait Trait {
    fn foo(x: i32, x: i32);
}

pub fn bar() {
    let _: fn(y: i32, y: i32);
}

I expected to get two warnings and/or errors, due to the duplicate function argument names. However, the code compiles fine without warnings.

See also #140088

Meta

Issue reproduces on the playground with version 1.88.0-nightly (2025-04-07 e643f59f6da3a84f43e7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions