Skip to content
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

short_circuit_statement: handle macros and parenthesis better #14047

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

Conversation

samueltardieu
Copy link
Contributor

  • The lint no longer triggers if one of the operands in the boolean expression comes from a macro expansion.
  • Parenthesis are now removed inside the generated block if they are no longer necessary.
  • Error markers have been added.

changelog: [short_circuit_statement]: better handling of macros and better looking suggestions

@rustbot
Copy link
Collaborator

rustbot commented Jan 20, 2025

r? @y21

rustbot has assigned @y21.
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 Jan 20, 2025
@y21
Copy link
Member

y21 commented Jan 21, 2025

The lint no longer triggers if one of the operands in the boolean expression comes from a macro expansion.

Isn't it fine to lint something like m1!() && m2!();? This could/should still be written as an if expression. I guess you want to rule out the mac!(f and g); case in the tests, but isn't the issue there moreso that the binary expression and semicolon statement are in different SyntaxContexts? So I think we would just want to check that the binary expression and statement aren't from an expansion, rather than the binop operands.

- The lint no longer triggers if the expression comes from macro
  expansion
- Parenthesis are now removed inside the generated block if they are no
  longer necessary.
@samueltardieu
Copy link
Contributor Author

The lint no longer triggers if one of the operands in the boolean expression comes from a macro expansion.

Isn't it fine to lint something like m1!() && m2!();? This could/should still be written as an if expression. I guess you want to rule out the mac!(f and g); case in the tests, but isn't the issue there moreso that the binary expression and semicolon statement are in different SyntaxContexts? So I think we would just want to check that the binary expression and statement aren't from an expansion, rather than the binop operands.

Done, and indeed this is better.

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