Skip to content

Commit

Permalink
Update Clippy and fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Aug 7, 2023
1 parent 7cda522 commit 59176e0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workspace.yml
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.60.0
toolchain: 1.71.0
components: clippy
- run: cargo clippy --all -- -D warnings

Expand Down
11 changes: 2 additions & 9 deletions blake2/src/as_bytes.rs
Expand Up @@ -19,19 +19,12 @@ pub trait AsBytes {
impl<T: Safe> AsBytes for [T] {
#[inline]
fn as_bytes(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(self.as_ptr() as *const u8, self.len() * mem::size_of::<T>())
}
unsafe { slice::from_raw_parts(self.as_ptr() as *const u8, mem::size_of_val(self)) }
}

#[inline]
fn as_mut_bytes(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self.as_mut_ptr() as *mut u8,
self.len() * mem::size_of::<T>(),
)
}
unsafe { slice::from_raw_parts_mut(self.as_mut_ptr() as *mut u8, mem::size_of_val(self)) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion blake2/src/simd/simd_opt/u32x4.rs
Expand Up @@ -25,7 +25,7 @@ pub fn rotate_right_const(vec: u32x4, n: u32) -> u32x4 {

#[inline(always)]
fn rotate_right_any(vec: u32x4, n: u32) -> u32x4 {
let r = n as u32;
let r = n;
let l = 32 - r;

(vec >> u32x4::new(r, r, r, r)) ^ (vec << u32x4::new(l, l, l, l))
Expand Down
2 changes: 1 addition & 1 deletion blake2/tests/mac.rs
Expand Up @@ -16,7 +16,7 @@ fn blake2b_new_test() {
.chain_update(DATA)
.finalize()
.into_bytes();
let res2 = <T as Mac>::new_from_slice(&key)
let res2 = <T as Mac>::new_from_slice(key)
.unwrap()
.chain_update(DATA)
.finalize()
Expand Down
1 change: 1 addition & 0 deletions streebog/src/table.rs
Expand Up @@ -2077,6 +2077,7 @@ mod test {
use super::SHUFFLED_LIN_TABLE;
use crate::consts::{A, P};

#[allow(clippy::needless_range_loop)]
fn gen_table() -> [[u64; 256]; 8] {
let mut table: [[u64; 256]; 8] = [[0; 256]; 8];
for i in 0..8 {
Expand Down
4 changes: 2 additions & 2 deletions tiger/src/lib.rs
Expand Up @@ -91,7 +91,7 @@ impl UpdateCore for TigerCore {
impl FixedOutputCore for TigerCore {
#[inline]
fn finalize_fixed_core(&mut self, buffer: &mut Buffer<Self>, out: &mut Output<Self>) {
let bs = Self::BlockSize::U64 as u64;
let bs = Self::BlockSize::U64;
let pos = buffer.get_pos() as u64;
let bit_len = 8 * (pos + bs * self.block_len);

Expand Down Expand Up @@ -165,7 +165,7 @@ impl UpdateCore for Tiger2Core {
impl FixedOutputCore for Tiger2Core {
#[inline]
fn finalize_fixed_core(&mut self, buffer: &mut Buffer<Self>, out: &mut Output<Self>) {
let bs = Self::BlockSize::U64 as u64;
let bs = Self::BlockSize::U64;
let pos = buffer.get_pos() as u64;
let bit_len = 8 * (pos + bs * self.block_len);

Expand Down

0 comments on commit 59176e0

Please sign in to comment.