Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmov/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}

Expand Down
10 changes: 5 additions & 5 deletions cmov/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -267,9 +267,9 @@ unsafe fn cast_slice<T, U>(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])
}
}

Expand All @@ -287,9 +287,9 @@ unsafe fn cast_slice_mut<T, U>(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])
}
}

Expand Down