Skip to content

Conversation

samueltardieu
Copy link
Member

Commit 2550530 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.

Fix #14097

changelog: [precedence_bits]: new lint

@rustbot
Copy link
Collaborator

rustbot commented Jan 30, 2025

r? @llogiq

rustbot has assigned @llogiq.
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 30, 2025
Commit 2550530 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.
@llogiq
Copy link
Contributor

llogiq commented Jan 30, 2025

Agree. I'll merge this right away without a FCP because I understand that we're reducing a lot of churn, and we want to do that quickly.

@llogiq llogiq added this pull request to the merge queue Jan 30, 2025
Merged via the queue into rust-lang:master with commit 398a5c2 Jan 30, 2025
11 checks passed
@samueltardieu samueltardieu deleted the push-totmvtpxwrsp branch January 30, 2025 21:07
smalis-msft added a commit to microsoft/openvmm that referenced this pull request Feb 20, 2025
Mostly cleaning up some more map_ors, but the one big change of note is
temporarily allowing the clippy:precedence lint. Previously this lint
only applied to arithmetic operations, however a change in 1.85 causes
it to apply to bitwise operations as well. This is overly noisy, and
unnecessary. And the clippy maintainers agree, as they've since split
out this change into a separate lint, precedence_bits, that is
allow-by-default. However that split will not be present until 1.86. See
rust-lang/rust-clippy#14115 for details on that.
Yarwin added a commit to Yarwin/gdext that referenced this pull request Feb 22, 2025
- Allow clippy::precedence which includes bitmasking and shift operations in Rust 1.85. This behaviour will be reverted in 1.86: rust-lang/rust-clippy#14115.
Yarwin added a commit to Yarwin/gdext that referenced this pull request Feb 22, 2025
- Allow clippy::precedence which includes bitmasking and shift operations in Rust 1.85. This behaviour will be reverted in 1.86: rust-lang/rust-clippy#14115.
averms added a commit to averms/glvs that referenced this pull request Mar 25, 2025
averms added a commit to averms/glvs that referenced this pull request Mar 25, 2025
@Ironedde Ironedde mentioned this pull request Apr 16, 2025
7 tasks
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.

Please separate clippy::precedence into multiple lints
3 participants