Skip to content

Diagnostic for mismatching argument count is misleading on nightly #96880

Closed
@barafael

Description

@barafael

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).

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler 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