4

Parenthesize blocks in `needless_bool` suggestion by llogiq · Pull Request #8066...

 2 years ago
source link: https://github.com/rust-lang/rust-clippy/pull/8066
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Collaborator

llogiq commented 9 days ago

Because the if .. {} statement already puts the condition in expression scope, contained blocks would be parsed as complete
statements, so any & binary expression whose left operand ended in a block would lead to a non-compiling suggestion.

We identify such expressions and add parentheses. Note that we don't make a difference between normal and unsafe blocks because the parsing problems are the same for both.

This fixes #8052.


changelog: none


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK