Skip to content

Add suggestion to unused_parens lint #42892

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
killercup opened this issue Jun 25, 2017 · 4 comments
Closed

Add suggestion to unused_parens lint #42892

killercup opened this issue Jun 25, 2017 · 4 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@killercup
Copy link
Member

I just ran rustfix on https://github.com/space-wizards/bsdiff-rs and noticed that the built-in unused_parens lint has no suggestions.

Suggesting the underlined span without the surrounding parentheses should be enough.

warning: unnecessary parentheses around assigned value
   --> src/diff.rs:552:21
    |
552 |             lenf += (lens - overlap);
    |                     ^^^^^^^^^^^^^^^^
    |
    = note: #[warn(unused_parens)] on by default
@Mark-Simulacrum Mark-Simulacrum added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Jun 25, 2017
@est31
Copy link
Member

est31 commented Jun 25, 2017

While the rustfix use case is legitimate, I think that such a suggestion would pretty well qualify as noise in the "normal" usage of rustc, as the suggested change is so obvious. Maybe rustfix could special case the lint?

@nixpulvis
Copy link

I'm too lazy to go hunting right now, but isn't there an RFC or Issue or something somewhere about a machine formatted output for rustc's lints and stuff? Could that possibly have the suggestion?

@est31
Copy link
Member

est31 commented Jun 30, 2017

I'm too lazy to go hunting right now, but isn't there an RFC or Issue or something somewhere about a machine formatted output for rustc's lints and stuff?

There is (already since some time) the option to have json formatted error output for rustc. I'm not sure whether it also supports suggestions, but at least it supports spans and everything that's connected to those. However, the use cases this json format gets used for are various, they might be shown inline in some IDE or something. There is no guarantee whether the json gets churned by some external tool like in rustfix's case. You could of course add an additional mode, json_suggest_all_you_can or something, which also outputs obvious suggestions like how to remove unused parens or unused functions, etc. This is IMO the best way to tackle this from the compiler side.

@sanxiyn
Copy link
Member

sanxiyn commented Jul 4, 2017

--error-format json does support suggestions.

@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 28, 2017
@bors bors closed this as completed in 5c9f806 Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

5 participants