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

rust 1.83 clippy fixup #1640

Merged
merged 16 commits into from
Jan 27, 2025
Merged

rust 1.83 clippy fixup #1640

merged 16 commits into from
Jan 27, 2025

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
@@ -132,7 +132,7 @@ const fn base128_byte(arc: Arc, pos: usize, total: usize) -> Result<u8> {
debug_assert!(pos < total);
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