Skip to content

hir-ty, ide-diagnostics: use E0057/E0061 for arg-count mismatch (was E0107) - #22947

Merged
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
kivancgnlp:fn-trait-arg-count
Jul 29, 2026
Merged

hir-ty, ide-diagnostics: use E0057/E0061 for arg-count mismatch (was E0107)#22947
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
kivancgnlp:fn-trait-arg-count

Conversation

@kivancgnlp

@kivancgnlp kivancgnlp commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The MismatchedArgCount diagnostic previously used code E0107, which is actually 'wrong number of generic arguments'. Split it based on how the call is made:

  • E0057 for calls through the Fn/FnMut/FnOnce traits (arguments bundled into a tuple via TupleArgumentsFlag::TupleArguments in the inference code)
  • E0061 for regular function calls

This adds an is_fn_trait_call flag on InferenceDiagnostic::MismatchedArgCount and the hir-surface MismatchedArgCount struct, populated from the tuple_arguments flag already tracked by check_call_arguments. The downstream 'if !args_count_matches' push in infer/expr.rs already covers both paths, so the two FIXMEs at the top of the tuple branch are addressed by threading the kind through rather than by adding a new push site. The nightly-only fallback FIXME below (E0059-ish) is left alone per discussion on issue #22140.

Adds a test 'arg_count_multi_arg_closure' that exercises the multi-argument tuple case via a closure with signature |_a: u8, _b: u8|. This complements the existing 'arg_count_lambda' test (1-tuple case).

Refs #22140

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 29, 2026
@rustbot

This comment has been minimized.

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the commit message like rustbot said.

View changes since this review

The MismatchedArgCount diagnostic previously used code E0107, which is
actually 'wrong number of generic arguments'. Split it based on how the
call is made:

- E0057 for calls through the Fn/FnMut/FnOnce traits (arguments bundled
  into a tuple via TupleArgumentsFlag::TupleArguments in the inference
  code)
- E0061 for regular function calls

This adds an is_fn_trait_call flag on InferenceDiagnostic::MismatchedArgCount
and the hir-surface MismatchedArgCount struct, populated from the
tuple_arguments flag already tracked by check_call_arguments. The
downstream 'if !args_count_matches' push in infer/expr.rs already
covers both paths, so the two FIXMEs at the top of the tuple branch
are addressed by threading the kind through rather than by adding a
new push site. The nightly-only fallback FIXME below (E0059-ish) is
left alone per discussion on rust-lang#22140.

Adds a test 'arg_count_multi_arg_closure' that exercises the
multi-argument tuple case via a closure with signature |_a: u8, _b: u8|.
This complements the existing 'arg_count_lambda' test (1-tuple case).

Refs rust-lang#22140
@kivancgnlp
kivancgnlp force-pushed the fn-trait-arg-count branch from 9ab5dcc to a779751 Compare July 29, 2026 11:00

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChayimFriedman2
ChayimFriedman2 added this pull request to the merge queue Jul 29, 2026
Merged via the queue into rust-lang:master with commit adc10c3 Jul 29, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 29, 2026
@kivancgnlp

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the E0057/E0061 pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants