-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
extend unused_parens lint to break
/return ()
#54440
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
src/librustc_lint/unused.rs
Outdated
|
||
use syntax::ast; | ||
use syntax::attr; | ||
use syntax::errors::Applicability; | ||
use syntax::feature_gate::{BUILTIN_ATTRIBUTES, AttributeType}; | ||
use syntax::feature_gate::{AttributeType, BUILTIN_ATTRIBUTES}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't include unrelated formatting/ordering changes like these in commits.
Seems like a good idea. However, it's difficult to review the change when the commit includes numerous unrelated formatting changes. Please don't do that. Formatting changes should go in a separate commit. |
0cd0e41
to
0fe83e5
Compare
I have removed the formatting changes for now, and tried to fix the tests instead. Let's keep formatting out of this. |
src/librustc_lint/unused.rs
Outdated
} | ||
check_must_use(cx, def.did, s.span, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems to be unrelated to this change. (It's a good change, but not related to this commit.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I backed this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! (Please do submit this cleanup separately.)
Looks much better now. I commented on one remaining nit; with that fixed, LGTM. |
0fe83e5
to
bbc66fc
Compare
This seems qualitatively different from the other situations that this lint covers, because from a grammar perspective these aren't parens, they're a unit expression. If we're going to have this (which I'm not at all opposed to), then it feels to me like it's a different lint (maybe fn foo() { () }
^^ help: remove this unit value Edit: Would probably cover things like this, too: fn bar() -> () {}
^^^^^^ help: remove this unit value |
@scottmcm That's a fair point. Same check, different lint name? |
I'm OK with that. Still I remember that we usually don't add new lints to rustc, unless for specific issues like forwards compatibility. cc @Manishearth |
I'm okay with this but I'm not sure if it's my decision to make. |
In that case I'll make it a new lint and we start a FCP. If it doesn't get merged, we can still add it to clippy. |
I think it makes more sense to extend the existing lint actually. It fits within the description pretty well, I'm actually surprised this lint doesn't handle this already. Edit: I misunderstood what this change does, it doesn't make as much sense to be part of the same lint now. Still could be though. I don't feel strongly on this either way. |
@Manishearth judgement call; I could well find arguments for extending |
So, some thoughts on this:
@rfcbot fcp merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged teams:
Concerns:
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I agree with @scottmcm about the lint name here and would add that I find this behavior coupled with the name @rfcbot concern should-be-a-separate-lint
I don't feel it needs to happen quickly since this is about style and not correctness; @rfcbot concern bake-in-clippy As for linting on
Since I think this is essentially a new lint that is different from what |
I've said this before: That part of the policy has not really been exercised before (and AIUI it wasn't added with an RFC), I think we really should get an explicit RFC reestablishing that policy or something else in its place. The governance landscape has changed significantly since then: There is a style WG, a rustfmt subteam, and a clippy sub-WG ( eventually subteam) as well. I find lints not much different from documentation when it comes to their relationship with language design. |
// the suggested replacement, but we also want to test that suggested | ||
// replacement only removes one set of parentheses, rather than naïvely | ||
// stripping away any starting or ending parenthesis characters—hence this | ||
// test of the JSON error format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the kind of thing that // run-rustfix
is for? Checking the full JSON feels fragile...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I didn't know about run-rustfix
! I mainly wanted to check the applicability, so this should work nicely.
The implementation looks good to me, relabeling as waiting-on-team. |
I disagree with this lint. Here's my reasoning:
The lint therefore provides zero tangible benefit (or at least, none has been given here in this thread) at the expense of making macros more annoying. |
@whataloadofwhat
|
Also it should be easy to extend the lint to cover |
If the lint won't trigger for macros then I retract my objection. Apologies. |
@whataloadofwhat it's all good, I can improve the code based on your input. |
☔ The latest upstream changes (presumably #54453) made this pull request unmergeable. Please resolve the merge conflicts. |
I agree with the already-raised concerns here. I feel like explicit- And that seems completely separate from excessively-parenthesizing expressions, even though the unicode codepoints involved are the same. |
We discussed this in the lang team meeting and several of us don't think this belongs under the Some of us also preferred that a new lint bake in clippy before adding it to rustc. |
@withoutboats in that case I'll close this here and put the code in a clippy PR. Thanks for the review, folks! |
No description provided.