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

Fix clippy::precedence warning in current beta #887

Merged
merged 1 commit into from
Jan 13, 2025
Merged

Conversation

jannic
Copy link
Member

@jannic jannic commented Jan 9, 2025

With current beta (1.85.0-beta.1), rustc introduced new clippy warnings regarding non-obvious operator precedence:

warning: operator precedence can trip the unwary
   --> src/adc.rs:876:14
    |
876 |         Self(1 << pins.0.channel() | 1 << pins.1.channel())
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(1 << pins.0.channel()) | (1 << pins.1.channel())`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
    = note: `#[warn(clippy::precedence)]` on by default

These can be easily fixed by adding some parentheses, as shown in this pull request.

I'm not sure if this really helps readability. Alternatively, we could silence clippy for this warning. (#[allow(clippy::precedence)])

Copy link
Contributor

@jonathanpallant jonathanpallant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely better

@jannic jannic merged commit c7c44d8 into rp-rs:main Jan 13, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants