Skip to content

Commit

Permalink
clarify message for non-obvious precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Jan 20, 2025
1 parent 2280b8a commit bef4120
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/precedence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl EarlyLintPass for Precedence {
cx,
PRECEDENCE,
expr.span,
"operator precedence can trip the unwary",
"operator precedence may not be obvious",
"consider parenthesizing your expression",
sugg,
appl,
Expand Down
22 changes: 11 additions & 11 deletions tests/ui/precedence.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:16:5
|
LL | 1 << 2 + 3;
Expand All @@ -7,61 +7,61 @@ LL | 1 << 2 + 3;
= note: `-D clippy::precedence` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::precedence)]`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:17:5
|
LL | 1 + 2 << 3;
| ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:18:5
|
LL | 4 >> 1 + 1;
| ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:19:5
|
LL | 1 + 3 >> 2;
| ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:20:5
|
LL | 1 ^ 1 - 1;
| ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:21:5
|
LL | 3 | 2 - 1;
| ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:22:5
|
LL | 3 & 5 - 2;
| ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:23:5
|
LL | 0x0F00 & 0x00F0 << 4;
| ^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `0x0F00 & (0x00F0 << 4)`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:24:5
|
LL | 0x0F00 & 0xF000 >> 4;
| ^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `0x0F00 & (0xF000 >> 4)`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:25:5
|
LL | 0x0F00 << 1 ^ 3;
| ^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(0x0F00 << 1) ^ 3`

error: operator precedence can trip the unwary
error: operator precedence may not be obvious
--> tests/ui/precedence.rs:26:5
|
LL | 0x0F00 << 1 | 2;
Expand Down

0 comments on commit bef4120

Please sign in to comment.