mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
clippy warnings
This commit is contained in:
parent
8e462c5944
commit
db005af1af
@ -1,7 +1,7 @@
|
|||||||
//! This is code from [Tungstenite project](https://github.com/snapview/tungstenite-rs)
|
//! This is code from [Tungstenite project](https://github.com/snapview/tungstenite-rs)
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
#![cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||||
use std::slice;
|
|
||||||
use std::ptr::copy_nonoverlapping;
|
use std::ptr::copy_nonoverlapping;
|
||||||
|
use std::slice;
|
||||||
|
|
||||||
// Holds a slice guaranteed to be shorter than 8 bytes
|
// Holds a slice guaranteed to be shorter than 8 bytes
|
||||||
struct ShortSlice<'a>(&'a mut [u8]);
|
struct ShortSlice<'a>(&'a mut [u8]);
|
||||||
@ -50,6 +50,7 @@ pub(crate) fn apply_mask(buf: &mut [u8], mask_u32: u32) {
|
|||||||
// TODO: copy_nonoverlapping here compiles to call memcpy. While it is not so
|
// TODO: copy_nonoverlapping here compiles to call memcpy. While it is not so
|
||||||
// inefficient, it could be done better. The compiler does not understand that
|
// inefficient, it could be done better. The compiler does not understand that
|
||||||
// a `ShortSlice` must be smaller than a u64.
|
// a `ShortSlice` must be smaller than a u64.
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
|
||||||
fn xor_short(buf: ShortSlice, mask: u64) {
|
fn xor_short(buf: ShortSlice, mask: u64) {
|
||||||
// Unsafe: we know that a `ShortSlice` fits in a u64
|
// Unsafe: we know that a `ShortSlice` fits in a u64
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -67,8 +68,8 @@ fn xor_short(buf: ShortSlice, mask: u64) {
|
|||||||
// Unsafe: caller must ensure the buffer has the correct size and alignment
|
// Unsafe: caller must ensure the buffer has the correct size and alignment
|
||||||
unsafe fn cast_slice(buf: &mut [u8]) -> &mut [u64] {
|
unsafe fn cast_slice(buf: &mut [u8]) -> &mut [u64] {
|
||||||
// Assert correct size and alignment in debug builds
|
// Assert correct size and alignment in debug builds
|
||||||
debug_assert!(buf.len() & 0x7 == 0);
|
debug_assert!(buf.len().trailing_zeros() >= 3);
|
||||||
debug_assert!(buf.as_ptr() as usize & 0x7 == 0);
|
debug_assert!((buf.as_ptr() as usize).trailing_zeros() >= 3);
|
||||||
|
|
||||||
slice::from_raw_parts_mut(buf.as_mut_ptr() as *mut u64, buf.len() >> 3)
|
slice::from_raw_parts_mut(buf.as_mut_ptr() as *mut u64, buf.len() >> 3)
|
||||||
}
|
}
|
||||||
@ -101,7 +102,6 @@ fn align_buf(buf: &mut [u8]) -> (ShortSlice, &mut [u64], ShortSlice) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::apply_mask;
|
use super::apply_mask;
|
||||||
|
Loading…
Reference in New Issue
Block a user