rust/tests/ui/precedence_bits.stderr
Samuel Tardieu 8db9ecfd74 New lint: precedence_bits, with recent additions to precedence
Commit 2550530266 has extended the
`precedence` lint to include bitmasking and shift operations. The lint
is warn by default, and this generates many hits, especially in embedded
or system code, where it is very idiomatic to use expressions such as
`1 << 3 | 1 << 5` without parentheses.

This commit splits the recent addition into a new lint, which is put
into the "restriction" category, while the original one stays in
"complexity", because mixing bitmasking and arithmetic operations is
less typical.
2025-01-30 17:07:50 +01:00

29 lines
1 KiB
Text

error: operator precedence might not be obvious
--> tests/ui/precedence_bits.rs:28:5
|
LL | 0x0F00 & 0x00F0 << 4;
| ^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `0x0F00 & (0x00F0 << 4)`
|
= note: `-D clippy::precedence-bits` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::precedence_bits)]`
error: operator precedence might not be obvious
--> tests/ui/precedence_bits.rs:29:5
|
LL | 0x0F00 & 0xF000 >> 4;
| ^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `0x0F00 & (0xF000 >> 4)`
error: operator precedence might not be obvious
--> tests/ui/precedence_bits.rs:30:5
|
LL | 0x0F00 << 1 ^ 3;
| ^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(0x0F00 << 1) ^ 3`
error: operator precedence might not be obvious
--> tests/ui/precedence_bits.rs:31:5
|
LL | 0x0F00 << 1 | 2;
| ^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(0x0F00 << 1) | 2`
error: aborting due to 4 previous errors