Skip to content

Conversation

@baloo
Copy link
Member

@baloo baloo commented Jan 27, 2025

A collection of small fixes clippy is going to raise with rust 1.83. Those did not come up in CI yet because we're pinned at 1.81 but they are annoying when running clippy manually.

@baloo baloo force-pushed the baloo/clippy-1.83 branch from e4f3875 to 541d76d Compare January 27, 2025 18:58
let last_byte = checked_add!(pos, 1) == total;
let mask = if last_byte { 0 } else { 0b10000000 };
let shift = checked_sub!(checked_sub!(total, pos), 1) * 7;
let shift = checked_mul!(checked_sub!(checked_sub!(total, pos), 1), 7);
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes this warning:

warning: arithmetic operation that can potentially result in unexpected side-effects
   --> const-oid/src/encoder.rs:135:17
    |
135 |     let shift = checked_sub!(checked_sub!(total, pos), 1) * 7;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects
note: the lint level is defined here
   --> const-oid/src/lib.rs:11:5
    |
11  |     clippy::arithmetic_side_effects,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I don't think the shift should overflow in the first place, but clippy still warns about it.

@baloo baloo merged commit a4f4ff7 into RustCrypto:master Jan 27, 2025
143 checks passed
@baloo baloo deleted the baloo/clippy-1.83 branch January 27, 2025 19:34
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