clippy: fix warnings in various modules in components (#31568)

* clippy: fix warnings in various modules in components

* fix: unit tests

* fix: build on android

* fix: all samplers use new_boxed
This commit is contained in:
eri 2024-03-08 15:28:04 +01:00 committed by GitHub
parent 19f1f2a8f4
commit 3a5ca785d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 107 additions and 118 deletions

View file

@ -29,16 +29,23 @@ const CHUNK_SIZE: usize = 16;
pub type FlowList = SmallVec<[UnsafeFlow; CHUNK_SIZE]>;
/// Vtable + pointer representation of a Flow trait object.
#[derive(Clone, Copy, Eq, PartialEq)]
#[derive(Clone, Copy, Eq)]
pub struct UnsafeFlow(*const dyn Flow);
unsafe impl Sync for UnsafeFlow {}
unsafe impl Send for UnsafeFlow {}
impl PartialEq for UnsafeFlow {
fn eq(&self, other: &Self) -> bool {
// Compare the pointers explicitly to avoid clippy lint
self.0 as *const u8 == other.0 as *const u8
}
}
fn null_unsafe_flow() -> UnsafeFlow {
UnsafeFlow(ptr::null::<BlockFlow>())
}
#[allow(clippy::not_unsafe_ptr_arg_deref)] // It has an unsafe block inside
pub fn mut_owned_flow_to_unsafe_flow(flow: *mut FlowRef) -> UnsafeFlow {
unsafe { UnsafeFlow(&**flow) }
}