-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Detect more cases of unused_parens around types #142237
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
base: master
Are you sure you want to change the base?
Conversation
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
Some changes occurred in tests/ui/sanitizer cc @rcvalle |
.span_to_snippet(poly_trait_ref.span) | ||
.map(|snip| snip.starts_with('(') && snip.ends_with(')')) |
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.
There has to be a better way to test this.
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.
Could we pass it so that the AST stores it somehow from parsing?
Maybe the unused parens lint should also be emitted ad-hoc when parsing these things
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.
My gut feeling is that adding this to the parser is not a worth the added complexity. However, I could see adding another Span
to PolyTraitRef
which excludes the parens. That would be cleaner than what I have currently.
Given my limited experience working on rustc, I'll defer to your judgement on which way I should go. (Of course, you can change your mind later. 🙂)
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.
Yes, please explore whether we can add a parenthesized: bool
(or : Option<Span>
that gives the inner span) to PolyTraitRef
, we shouldn't resort to doing stringy operations here.
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
☔ The latest upstream changes (presumably #142878) made this pull request unmergeable. Please resolve the merge conflicts. |
With this change, more unused parentheses around bounds and types nested within bounds are detected.