Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benschulz
Copy link
Contributor

With this change, more unused parentheses around bounds and types nested within bounds are detected.

@rustbot
Copy link
Collaborator

rustbot commented Jun 9, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 9, 2025

Some changes occurred in tests/ui/sanitizer

cc @rcvalle

Comment on lines +1316 to +1317
.span_to_snippet(poly_trait_ref.span)
.map(|snip| snip.starts_with('(') && snip.ends_with(')'))
Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants