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 #953

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix clippy::precedence warning #953

wants to merge 1 commit into from

Conversation

psychon
Copy link
Owner

@psychon psychon commented Mar 1, 2025

With Rust 1.85.0, clippy started warning:

error: operator precedence can trip the unwary
   --> xcbgen-rs/src/defs/alignment.rs:258:30
    |
258 |                 incr = 1 << (incr | base | 1 << 31).trailing_zeros().min(31);
    |                              ^^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `incr | base | (1 << 31)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
    = note: `-D clippy::precedence` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::precedence)]`

This commit simply follows clippy's suggestion.

With Rust 1.85.0, clippy started warning:

```
error: operator precedence can trip the unwary
   --> xcbgen-rs/src/defs/alignment.rs:258:30
    |
258 |                 incr = 1 << (incr | base | 1 << 31).trailing_zeros().min(31);
    |                              ^^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `incr | base | (1 << 31)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
    = note: `-D clippy::precedence` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::precedence)]`
```

This commit simply follows clippy's suggestion.

Signed-off-by: Uli Schlachter <[email protected]>
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.

1 participant