Skip to content

Diagnostic for mismatching argument count is misleading on nightly #96880

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

Closed
barafael opened this issue May 9, 2022 · 0 comments · Fixed by #98264
Closed

Diagnostic for mismatching argument count is misleading on nightly #96880

barafael opened this issue May 9, 2022 · 0 comments · Fixed by #98264
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@barafael
Copy link
Contributor

barafael commented May 9, 2022

The compiler nicely reports when calling a function with too few arguments:

let ok = Ok();

leads to

error[[E0061]]: this enum variant takes 1 argument but 0 arguments were supplied

The compiler (on nightly) suggests:

help: provide the argument
  |
6 |     let ok = Ok({_});
  |              ~~~~~~~

This looks like a literal fix suggestion. However, the {_} is probably intended as just a placeholder. Obviously inserting that directly yields another compiler error:

error: in expressions, `_` can only be used on the left-hand side of an assignment

See example on playground.

I personally think the warning is already meaningful enough without the provide the argument section (i.e. the way beta and stable handle this).

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels May 10, 2022
@TaKO8Ki TaKO8Ki self-assigned this May 10, 2022
@TaKO8Ki TaKO8Ki assigned compiler-errors and unassigned TaKO8Ki Jun 20, 2022
@bors bors closed this as completed in a5c039c Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants