Skip to content

empty arg lists get ignored when considering whether to apply default args #136488

Open
@lcnr

Description

@lcnr
struct Foo<T = u32, U = i32>(T, U);

impl<T, U> Foo<T, U> {
    fn foo() -> Self {
        loop {}
    }
}

fn main() {
    let a = Foo::<u32, i32>::foo();
    let b = Foo::<u32>::foo(); // ok
    let c = Foo::<>::foo(); // ambiguity error
    let d = Foo::foo(); // ambiguity error
}

The same way Foo::<u32> instantiates U with i32, so should Foo::<> for T and U.

My expected behavior is that d is ambiguous while c compiles

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions