chore(all): fix new lints

This commit is contained in:
Mayeul@Zama
2024-09-06 16:33:00 +02:00
committed by mayeul-zama
parent d6f8e59394
commit 38b5759e88
8 changed files with 36 additions and 24 deletions

View File

@@ -1,3 +1,5 @@
#![allow(clippy::too_long_first_doc_paragraph)]
mod static_deque; mod static_deque;
mod kreyvium; mod kreyvium;

View File

@@ -61,7 +61,7 @@ impl ServerKey {
str: &'a FheString, str: &'a FheString,
pat: &'a FheString, pat: &'a FheString,
null: Option<&'a FheAsciiChar>, null: Option<&'a FheAsciiChar>,
) -> (CharIter, CharIter, Range<usize>) { ) -> (CharIter<'a>, CharIter<'a>, Range<usize>) {
let pat_len = pat.chars().len(); let pat_len = pat.chars().len();
let str_len = str.chars().len(); let str_len = str.chars().len();
@@ -138,7 +138,7 @@ impl ServerKey {
&'a self, &'a self,
str: &'a FheString, str: &'a FheString,
pat: &str, pat: &str,
) -> (CharIter, String, Range<usize>) { ) -> (CharIter<'a>, String, Range<usize>) {
let pat_len = pat.len(); let pat_len = pat.len();
let str_len = str.chars().len(); let str_len = str.chars().len();
@@ -165,7 +165,7 @@ impl ServerKey {
str: &'a FheString, str: &'a FheString,
pat: &'a FheString, pat: &'a FheString,
null: Option<&'a FheAsciiChar>, null: Option<&'a FheAsciiChar>,
) -> (CharIter, CharIter, Range<usize>) { ) -> (CharIter<'a>, CharIter<'a>, Range<usize>) {
let pat_len = pat.chars().len(); let pat_len = pat.chars().len();
let str_len = str.chars().len(); let str_len = str.chars().len();

View File

@@ -168,7 +168,9 @@ mod test {
destructor: Some(custom_destroy_vec_u8_buffer), destructor: Some(custom_destroy_vec_u8_buffer),
}; };
let res = unsafe { destroy_dynamic_buffer(&mut dynamic_buffer as *mut DynamicBuffer) }; let res = unsafe {
destroy_dynamic_buffer(std::ptr::from_mut::<DynamicBuffer>(&mut dynamic_buffer))
};
assert_eq!(res, 0); assert_eq!(res, 0);
assert!(dynamic_buffer.pointer.is_null()); assert!(dynamic_buffer.pointer.is_null());
@@ -176,7 +178,9 @@ mod test {
assert!(dynamic_buffer.destructor.is_none()); assert!(dynamic_buffer.destructor.is_none());
assert!(dynamic_buffer.pointer.is_null()); assert!(dynamic_buffer.pointer.is_null());
let res = unsafe { destroy_dynamic_buffer(&mut dynamic_buffer as *mut DynamicBuffer) }; let res = unsafe {
destroy_dynamic_buffer(std::ptr::from_mut::<DynamicBuffer>(&mut dynamic_buffer))
};
// Same as free in C, destroy on a NULL pointer does nothing // Same as free in C, destroy on a NULL pointer does nothing
assert_eq!(res, 0); assert_eq!(res, 0);
assert!(dynamic_buffer.pointer.is_null()); assert!(dynamic_buffer.pointer.is_null());
@@ -185,10 +189,12 @@ mod test {
let mut some_u8 = 0u8; let mut some_u8 = 0u8;
dynamic_buffer.pointer = &mut some_u8 as *mut u8; dynamic_buffer.pointer = std::ptr::from_mut::<u8>(&mut some_u8);
assert!(dynamic_buffer.destructor.is_none()); assert!(dynamic_buffer.destructor.is_none());
let res = unsafe { destroy_dynamic_buffer(&mut dynamic_buffer as *mut DynamicBuffer) }; let res = unsafe {
destroy_dynamic_buffer(std::ptr::from_mut::<DynamicBuffer>(&mut dynamic_buffer))
};
assert_eq!(res, 1); assert_eq!(res, 1);
} }
@@ -198,7 +204,9 @@ mod test {
let mut dynamic_buffer: DynamicBuffer = vec.clone().into(); let mut dynamic_buffer: DynamicBuffer = vec.clone().into();
let res = unsafe { destroy_dynamic_buffer(&mut dynamic_buffer as *mut DynamicBuffer) }; let res = unsafe {
destroy_dynamic_buffer(std::ptr::from_mut::<DynamicBuffer>(&mut dynamic_buffer))
};
assert_eq!(res, 0); assert_eq!(res, 0);
assert!(dynamic_buffer.pointer.is_null()); assert!(dynamic_buffer.pointer.is_null());

View File

@@ -254,7 +254,7 @@ pub trait ContiguousEntityContainer: AsRef<[Self::Element]> {
fn par_chunks<'this>( fn par_chunks<'this>(
&'this self, &'this self,
chunk_size: usize, chunk_size: usize,
) -> ParallelChunksWrappingLendingIterator<'_, Self::Element, Self::SelfView<'_>> ) -> ParallelChunksWrappingLendingIterator<'this, Self::Element, Self::SelfView<'this>>
where where
Self::Element: Sync, Self::Element: Sync,
Self::SelfView<'this>: Send, Self::SelfView<'this>: Send,
@@ -275,7 +275,7 @@ pub trait ContiguousEntityContainer: AsRef<[Self::Element]> {
fn par_chunks_exact<'this>( fn par_chunks_exact<'this>(
&'this self, &'this self,
chunk_size: usize, chunk_size: usize,
) -> ParallelChunksExactWrappingLendingIterator<'_, Self::Element, Self::SelfView<'_>> ) -> ParallelChunksExactWrappingLendingIterator<'this, Self::Element, Self::SelfView<'this>>
where where
Self::Element: Sync, Self::Element: Sync,
Self::SelfView<'this>: Send, Self::SelfView<'this>: Send,
@@ -457,7 +457,7 @@ pub trait ContiguousEntityContainerMut: ContiguousEntityContainer + AsMut<[Self:
fn par_chunks_mut<'this>( fn par_chunks_mut<'this>(
&'this mut self, &'this mut self,
chunk_size: usize, chunk_size: usize,
) -> ParallelChunksWrappingLendingIteratorMut<'_, Self::Element, Self::SelfMutView<'_>> ) -> ParallelChunksWrappingLendingIteratorMut<'this, Self::Element, Self::SelfMutView<'this>>
where where
Self::Element: Sync + Send, Self::Element: Sync + Send,
Self::SelfMutView<'this>: Send, Self::SelfMutView<'this>: Send,
@@ -478,7 +478,7 @@ pub trait ContiguousEntityContainerMut: ContiguousEntityContainer + AsMut<[Self:
fn par_chunks_exact_mut<'this>( fn par_chunks_exact_mut<'this>(
&'this mut self, &'this mut self,
chunk_size: usize, chunk_size: usize,
) -> ParallelChunksExactWrappingLendingIteratorMut<'_, Self::Element, Self::SelfMutView<'_>> ) -> ParallelChunksExactWrappingLendingIteratorMut<'this, Self::Element, Self::SelfMutView<'this>>
where where
Self::Element: Sync + Send, Self::Element: Sync + Send,
Self::SelfMutView<'this>: Send, Self::SelfMutView<'this>: Send,

View File

@@ -31,9 +31,8 @@
#![allow(clippy::float_cmp)] // 7 #![allow(clippy::float_cmp)] // 7
#![allow(clippy::bool_to_int_with_if)] // 6 #![allow(clippy::bool_to_int_with_if)] // 6
#![allow(clippy::unsafe_derive_deserialize)] // 1 #![allow(clippy::unsafe_derive_deserialize)] // 1
#![allow(clippy::cast_possible_wrap)] #![allow(clippy::cast_possible_wrap)] // 1
// 1 #![allow(clippy::too_long_first_doc_paragraph)]
// These pedantic lints are deemed to bring too little value therefore they are allowed (which are // These pedantic lints are deemed to bring too little value therefore they are allowed (which are
// their natural state anyways, being pedantic lints) // their natural state anyways, being pedantic lints)

View File

@@ -129,9 +129,10 @@ pub fn derive_versions_dispatch(input: TokenStream) -> TokenStream {
.into() .into()
} }
/// This derives the `Versionize` and `Unversionize` trait for the target type. This macro /// This derives the `Versionize` and `Unversionize` trait for the target type.
/// has a mandatory attribute parameter, which is the name of the versioned enum for this type. ///
/// This enum can be anywhere in the code but should be in scope. /// This macro has a mandatory attribute parameter, which is the name of the versioned enum for this
/// type. This enum can be anywhere in the code but should be in scope.
#[proc_macro_derive(Versionize, attributes(versionize))] #[proc_macro_derive(Versionize, attributes(versionize))]
pub fn derive_versionize(input: TokenStream) -> TokenStream { pub fn derive_versionize(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput); let input = parse_macro_input!(input as DeriveInput);

View File

@@ -49,6 +49,7 @@ pub trait VersionizeOwned {
} }
/// This trait is used as a proxy to be more felxible when deriving Versionize for Vec<T>. /// This trait is used as a proxy to be more felxible when deriving Versionize for Vec<T>.
///
/// This way, we can chose to skip versioning Vec<T> if T is a native types but still versionize in /// This way, we can chose to skip versioning Vec<T> if T is a native types but still versionize in
/// a loop if T is a custom type. /// a loop if T is a custom type.
/// This is used as a workaround for feature(specialization) and to bypass the orphan rule. /// This is used as a workaround for feature(specialization) and to bypass the orphan rule.
@@ -154,9 +155,10 @@ impl From<Infallible> for UnversionizeError {
} }
} }
/// This trait means that we can convert from a versioned enum into the target type. This trait /// This trait means that we can convert from a versioned enum into the target type.
/// can only be implemented on Owned/static types, whereas `Versionize` can also be implemented ///
/// on reference types. /// This trait can only be implemented on Owned/static types, whereas `Versionize` can also be
/// implemented on reference types.
pub trait Unversionize: VersionizeOwned + Sized { pub trait Unversionize: VersionizeOwned + Sized {
/// Creates an object from a versioned enum, and eventually upgrades from previous /// Creates an object from a versioned enum, and eventually upgrades from previous
/// variants. /// variants.

View File

@@ -59,9 +59,9 @@ fn test_types() {
aligned_box: ABox::new(0, -98765), aligned_box: ABox::new(0, -98765),
aligned_vec: AVec::from_slice(0, &[1, 2, 3, 4]), aligned_vec: AVec::from_slice(0, &[1, 2, 3, 4]),
never: (), never: (),
tuple: (3.14, 2.71), tuple: (std::f32::consts::PI, std::f64::consts::E),
set: HashSet::from_iter([1, 2, 3].into_iter()), set: HashSet::from_iter([1, 2, 3]),
map: HashMap::from_iter([('t', true), ('e', false), ('s', true)].into_iter()), map: HashMap::from_iter([('t', true), ('e', false), ('s', true)]),
}; };
let mut ser = Vec::new(); let mut ser = Vec::new();