Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lcnr opened this issue Feb 3, 2025 · 0 comments
Open
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Feb 3, 2025

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

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 3, 2025
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants