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

Improve generic arg–param mismatch errors #68437

Closed
varkor opened this issue Jan 21, 2020 · 9 comments · Fixed by #72271
Closed

Improve generic arg–param mismatch errors #68437

varkor opened this issue Jan 21, 2020 · 9 comments · Fixed by #72271
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@varkor
Copy link
Member

varkor commented Jan 21, 2020

The current diagnostics are a little ad hoc and rely on counting the number of mismatches (e.g. they will only produce an error for the first mismatch). It would be nice to produce diagnostics like:

missing generic arguments for `T`, `const N: usize`, `U`

cc @eddyb

This issue has been assigned to @rakshith-ravi via this comment.

@varkor varkor added C-cleanup Category: PRs that clean code up or issues documenting cleanup. 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. labels Jan 21, 2020
@varkor
Copy link
Member Author

varkor commented Jan 21, 2020

This is follow up work for #68434.

@contrun
Copy link
Contributor

contrun commented Mar 13, 2020

Please give more context on this. I am not sure the error message of which test should be improved.

@eddyb
Copy link
Member

eddyb commented Mar 13, 2020

@contrun This is more of the kind of issue opened to avoid forgetting about finishing some work, sorry for the confusion.

That is, this is @varkor leaving a TODO to themselves about improving the diagnostics from #68434.

@contrun
Copy link
Contributor

contrun commented Mar 13, 2020

Ok. I see. Thanks for the explanation.

@eddyb
Copy link
Member

eddyb commented Mar 13, 2020

That said, if @varkor is too busy to work on this, you could talk to them on Discord or Zulip to see what their plans were, and maybe turn this into a mentored issue.

@varkor
Copy link
Member Author

varkor commented Mar 14, 2020

The idea is essentially this. We currently emit errors telling the user that the generic arguments they provide are in the wrong order: https://github.com/rust-lang/rust/pull/68434/files#diff-5df0144261224cec2047029de05fa827R107
However, what we'd like to do is suggest reordering the parameters, and let rustfix automatically apply the suggestion.

I don't have the bandwidth to work on this at the moment, or any time soon, so if anyone is interested in tackling it, I'll be happy to mentor the issue.

@varkor varkor added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Mar 14, 2020
@rakshith-ravi
Copy link
Contributor

@varkor would you mind if I take this up?

@varkor
Copy link
Member Author

varkor commented May 9, 2020

@rakshith-ravi: you're very welcome to! Let me know if you need any guidance in tackling this issue!

@rakshith-ravi
Copy link
Contributor

@rustbot claim

@rustbot rustbot self-assigned this May 10, 2020
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 21, 2020
Improve compiler error message for wrong generic parameter order

- Added optional "help" parameter that shows a help message on the compiler error if required.
- Added a simple ordered parameter as a sample help.

@varkor will make more changes as required. Let me know if I'm heading in the right direction.

Fixes rust-lang#68437

r? @varkor
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 21, 2020
Improve compiler error message for wrong generic parameter order

- Added optional "help" parameter that shows a help message on the compiler error if required.
- Added a simple ordered parameter as a sample help.

@varkor will make more changes as required. Let me know if I'm heading in the right direction.

Fixes rust-lang#68437

r? @varkor
Manishearth added a commit to Manishearth/rust that referenced this issue Jun 22, 2020
Improve compiler error message for wrong generic parameter order

- Added optional "help" parameter that shows a help message on the compiler error if required.
- Added a simple ordered parameter as a sample help.

@varkor will make more changes as required. Let me know if I'm heading in the right direction.

Fixes rust-lang#68437

r? @varkor
@bors bors closed this as completed in 59e87c0 Jun 23, 2020
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 C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. 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.

5 participants