diff --git a/cmov/src/lib.rs b/cmov/src/lib.rs index 3fde4fdc..3c02bd7d 100644 --- a/cmov/src/lib.rs +++ b/cmov/src/lib.rs @@ -15,6 +15,9 @@ clippy::mod_module_files, clippy::panic, clippy::panic_in_result_fn, + clippy::ref_as_ptr, + clippy::return_self_not_must_use, + clippy::semicolon_if_nothing_returned, clippy::std_instead_of_alloc, clippy::std_instead_of_core, clippy::unwrap_used, @@ -50,7 +53,7 @@ pub trait Cmov { /// Moves `value` to `self` in constant-time if `condition` is equal to zero. fn cmovz(&mut self, value: &Self, condition: Condition) { let nz = masknz!(condition: Condition); - self.cmovnz(value, !nz) + self.cmovnz(value, !nz); } } diff --git a/cmov/src/slice.rs b/cmov/src/slice.rs index 36ae0baf..1592bb7a 100644 --- a/cmov/src/slice.rs +++ b/cmov/src/slice.rs @@ -3,7 +3,7 @@ use crate::{Cmov, CmovEq, Condition}; use core::{ ops::{BitOrAssign, Shl}, - slice, + ptr, slice, }; // Uses 64-bit words on 64-bit targets, 32-bit everywhere else @@ -267,9 +267,9 @@ unsafe fn cast_slice(slice: &[T]) -> &[U] { // SAFETY: // - Slices are of same-sized/aligned types as asserted above. // - It's up to the caller to ensure the pointer cast from `T` to `U` itself is valid. - #[allow(trivial_casts, unsafe_code)] + #[allow(unsafe_code)] unsafe { - &*((slice as *const [T]) as *const [U]) + &*(ptr::from_ref::<[T]>(slice) as *const [U]) } } @@ -287,9 +287,9 @@ unsafe fn cast_slice_mut(slice: &mut [T]) -> &mut [U] { // SAFETY: // - Slices are of same-sized/aligned types as asserted above. // - It's up to the caller to ensure the pointer cast from `T` to `U` itself is valid. - #[allow(trivial_casts, unsafe_code)] + #[allow(unsafe_code)] unsafe { - &mut *((slice as *mut [T]) as *mut [U]) + &mut *(ptr::from_mut::<[T]>(slice) as *mut [U]) } }