Skip to content

Sugg: do not parenthesize a double unary operator #14983

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

Merged
merged 1 commit into from
Jun 20, 2025

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Jun 5, 2025

For example, adding * in front of *expression is best shown as **expression rather than *(*expression).

This is not perfect, as it checks whether the operator is already a prefix of the expression, but it is better than it was before. For example, &+&mut x will get &&mut x but &mut +&x will get &mut (&x) as it did before this change.

changelog: none

@rustbot
Copy link
Collaborator

rustbot commented Jun 5, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 5, 2025
@samueltardieu samueltardieu force-pushed the better-unary-suggestions branch from 71a7aef to 2f94401 Compare June 5, 2025 21:22
For example, adding `*` in front of `*expression` is best shown as
`**expression` rather than `*(*expression)`.

This is not perfect, as it checks whether the operator is already a prefix
of the expression, but it is better than it was before. For example,
`&`+`&mut x` will get `&&mut x` but `&mut `+`&x` will get `&mut (&x)`
as it did before this change.
@samueltardieu samueltardieu force-pushed the better-unary-suggestions branch from 2f94401 to 2037075 Compare June 5, 2025 21:27
Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely hackish, but it does result in an improvement.

@Jarcho Jarcho added this pull request to the merge queue Jun 20, 2025
Merged via the queue into rust-lang:master with commit 37cb834 Jun 20, 2025
12 of 13 checks passed
@samueltardieu samueltardieu deleted the better-unary-suggestions branch June 21, 2025 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants