From e0111f6dd18f9955f271892bb669ed5a30153d44 Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Fri, 29 Nov 2024 18:35:05 +0100 Subject: [PATCH] chore(ci): toolchain update --- tfhe-fft/src/unordered.rs | 2 +- tfhe/Cargo.toml | 2 +- tfhe/src/boolean/parameters/mod.rs | 1 + .../lwe_multi_bit_programmable_bootstrapping.rs | 3 +-- .../entities/fourier_pseudo_ggsw_ciphertext.rs | 2 +- .../core_crypto/fft_impl/fft128/math/fft/mod.rs | 2 +- .../fft_impl/fft128_u128/math/fft/mod.rs | 2 +- .../fft_impl/fft64/crypto/bootstrap.rs | 4 ++-- .../core_crypto/fft_impl/fft64/crypto/ggsw.rs | 2 +- .../fft_impl/fft64/math/decomposition.rs | 5 +++++ .../core_crypto/fft_impl/fft64/math/fft/mod.rs | 6 +++--- tfhe/src/core_crypto/gpu/slice.rs | 4 ++-- tfhe/src/high_level_api/array/cpu/booleans.rs | 10 +++++----- tfhe/src/high_level_api/array/cpu/integers.rs | 14 +++++++------- tfhe/src/high_level_api/array/cpu/mod.rs | 6 +++--- .../src/high_level_api/array/dynamic/booleans.rs | 8 ++++---- tfhe/src/high_level_api/array/dynamic/signed.rs | 8 ++++---- .../src/high_level_api/array/dynamic/unsigned.rs | 12 ++++++------ tfhe/src/high_level_api/array/ops.rs | 3 +-- tfhe/src/high_level_api/array/stride.rs | 16 ++++++++-------- tfhe/src/high_level_api/details.rs | 2 +- tfhe/src/high_level_api/tag.rs | 2 +- .../compressed_modulus_switched_ciphertext.rs | 6 +++--- .../gpu/server_key/radix/scalar_comparison.rs | 4 ++-- tfhe/src/integer/key_switching_key/mod.rs | 10 ++++------ .../server_key/radix_parallel/bit_extractor.rs | 2 +- .../radix_parallel/scalar_comparison.rs | 4 ++-- tfhe/src/keycache/mod.rs | 2 +- tfhe/src/lib.rs | 11 ++++++++--- tfhe/src/shortint/key_switching_key/mod.rs | 4 ++-- tfhe/src/strings/char_iter.rs | 8 ++++---- tfhe/src/strings/ciphertext.rs | 2 +- tfhe/src/strings/client_key.rs | 4 ++-- toolchain.txt | 2 +- 34 files changed, 91 insertions(+), 84 deletions(-) diff --git a/tfhe-fft/src/unordered.rs b/tfhe-fft/src/unordered.rs index c9336fb11d..00c5dde419 100644 --- a/tfhe-fft/src/unordered.rs +++ b/tfhe-fft/src/unordered.rs @@ -990,7 +990,7 @@ impl Plan { base_n: usize, } - impl<'de, 'a> Visitor<'de> for SeqVisitor<'a> { + impl<'de> Visitor<'de> for SeqVisitor<'_> { type Value = (); fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { diff --git a/tfhe/Cargo.toml b/tfhe/Cargo.toml index 67f89801b3..5ed2875a7d 100644 --- a/tfhe/Cargo.toml +++ b/tfhe/Cargo.toml @@ -17,7 +17,7 @@ exclude = [ "/js_on_wasm_tests/", "/web_wasm_parallel_tests/", ] -rust-version = "1.82" +rust-version = "1.83" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/tfhe/src/boolean/parameters/mod.rs b/tfhe/src/boolean/parameters/mod.rs index 3ce31df1a3..1f38bd5db0 100644 --- a/tfhe/src/boolean/parameters/mod.rs +++ b/tfhe/src/boolean/parameters/mod.rs @@ -126,6 +126,7 @@ impl BooleanKeySwitchingParameters { /// Parameter sets given in TFHE-lib: /// +/// /// Original security in 2020 was 129-bits, while it is currently around 120 bits. pub const TFHE_LIB_PARAMETERS: BooleanParameters = BooleanParameters { lwe_dimension: LweDimension(630), diff --git a/tfhe/src/core_crypto/algorithms/lwe_multi_bit_programmable_bootstrapping.rs b/tfhe/src/core_crypto/algorithms/lwe_multi_bit_programmable_bootstrapping.rs index 94a66b6e75..ea98a62310 100644 --- a/tfhe/src/core_crypto/algorithms/lwe_multi_bit_programmable_bootstrapping.rs +++ b/tfhe/src/core_crypto/algorithms/lwe_multi_bit_programmable_bootstrapping.rs @@ -77,10 +77,9 @@ pub struct StandardMultiBitModulusSwitchedCt< } impl< - 'a, Scalar: UnsignedInteger + CastInto + CastFrom, C: Container + Sync, - > MultiBitModulusSwitchedCt for StandardMultiBitModulusSwitchedCt<'a, Scalar, C> + > MultiBitModulusSwitchedCt for StandardMultiBitModulusSwitchedCt<'_, Scalar, C> { fn lwe_dimension(&self) -> LweDimension { self.input.lwe_size().to_lwe_dimension() diff --git a/tfhe/src/core_crypto/experimental/entities/fourier_pseudo_ggsw_ciphertext.rs b/tfhe/src/core_crypto/experimental/entities/fourier_pseudo_ggsw_ciphertext.rs index 39d386a405..5c194388b8 100644 --- a/tfhe/src/core_crypto/experimental/entities/fourier_pseudo_ggsw_ciphertext.rs +++ b/tfhe/src/core_crypto/experimental/entities/fourier_pseudo_ggsw_ciphertext.rs @@ -263,7 +263,7 @@ pub fn fill_with_forward_fourier_scratch(fft: FftView<'_>) -> Result PseudoFourierGgswCiphertextMutView<'a> { +impl PseudoFourierGgswCiphertextMutView<'_> { /// Fill a GGSW ciphertext with the Fourier transform of a GGSW ciphertext in the standard /// domain. pub fn fill_with_forward_fourier< diff --git a/tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs b/tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs index 14e9f888c3..8ec1926983 100644 --- a/tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs @@ -346,7 +346,7 @@ fn convert_backward_torus( } } -impl<'a> Fft128View<'a> { +impl Fft128View<'_> { pub fn polynomial_size(self) -> PolynomialSize { PolynomialSize(2 * self.plan.fft_size()) } diff --git a/tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs b/tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs index c98eceda28..b9915e6f5d 100644 --- a/tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs @@ -1218,7 +1218,7 @@ pub fn convert_add_backward_torus( ); } -impl<'a> Fft128View<'a> { +impl Fft128View<'_> { pub fn forward_as_integer_split( self, fourier_re0: &mut [f64], diff --git a/tfhe/src/core_crypto/fft_impl/fft64/crypto/bootstrap.rs b/tfhe/src/core_crypto/fft_impl/fft64/crypto/bootstrap.rs index ffe58a65aa..bf0f7b7b0d 100644 --- a/tfhe/src/core_crypto/fft_impl/fft64/crypto/bootstrap.rs +++ b/tfhe/src/core_crypto/fft_impl/fft64/crypto/bootstrap.rs @@ -184,7 +184,7 @@ pub fn fill_with_forward_fourier_scratch(fft: FftView<'_>) -> Result FourierLweBootstrapKeyMutView<'a> { +impl FourierLweBootstrapKeyMutView<'_> { /// Fill a bootstrapping key with the Fourier transform of a bootstrapping key in the standard /// domain. pub fn fill_with_forward_fourier( @@ -281,7 +281,7 @@ pub fn batch_bootstrap_scratch( )?) } -impl<'a> FourierLweBootstrapKeyView<'a> { +impl FourierLweBootstrapKeyView<'_> { // CastInto required for PBS modulus switch which returns a usize pub fn blind_rotate_assign( self, diff --git a/tfhe/src/core_crypto/fft_impl/fft64/crypto/ggsw.rs b/tfhe/src/core_crypto/fft_impl/fft64/crypto/ggsw.rs index 89cbcf4e63..f6435a98b8 100644 --- a/tfhe/src/core_crypto/fft_impl/fft64/crypto/ggsw.rs +++ b/tfhe/src/core_crypto/fft_impl/fft64/crypto/ggsw.rs @@ -250,7 +250,7 @@ pub fn fill_with_forward_fourier_scratch(fft: FftView<'_>) -> Result FourierGgswCiphertextMutView<'a> { +impl FourierGgswCiphertextMutView<'_> { /// Fill a GGSW ciphertext with the Fourier transform of a GGSW ciphertext in the standard /// domain. pub fn fill_with_forward_fourier( diff --git a/tfhe/src/core_crypto/fft_impl/fft64/math/decomposition.rs b/tfhe/src/core_crypto/fft_impl/fft64/math/decomposition.rs index 639619c1ab..13592e8cde 100644 --- a/tfhe/src/core_crypto/fft_impl/fft64/math/decomposition.rs +++ b/tfhe/src/core_crypto/fft_impl/fft64/math/decomposition.rs @@ -46,6 +46,11 @@ impl<'buffers, Scalar: UnsignedInteger> TensorSignedDecompositionLendingIter<'bu // inlining this improves perf of external product by about 25%, even in LTO builds #[inline] + #[allow( + clippy::type_complexity, + reason = "The type complexity would require a pub type = ...; \ + but impl Trait is not stable in pub type so we tell clippy to leave us alone" + )] pub fn next_term<'short>( &'short mut self, ) -> Option<( diff --git a/tfhe/src/core_crypto/fft_impl/fft64/math/fft/mod.rs b/tfhe/src/core_crypto/fft_impl/fft64/math/fft/mod.rs index c315ef31b8..666fef7142 100644 --- a/tfhe/src/core_crypto/fft_impl/fft64/math/fft/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/fft64/math/fft/mod.rs @@ -329,7 +329,7 @@ fn convert_add_backward_torus( convert_add_backward_torus_scalar::(out_re, out_im, inp, twisties); } -impl<'a> FftView<'a> { +impl FftView<'_> { /// Return the polynomial size that this FFT was made for. pub fn polynomial_size(self) -> PolynomialSize { PolynomialSize(2 * self.plan.fft_size()) @@ -629,7 +629,7 @@ impl> serde::Serialize for FourierPolynomialList buf: &'a [c64], } - impl<'a> serde::Serialize for SingleFourierPolynomial<'a> { + impl serde::Serialize for SingleFourierPolynomial<'_> { fn serialize( &self, serializer: S, @@ -701,7 +701,7 @@ impl<'de, C: IntoContainerOwned> serde::Deserialize<'de> buf: &'a mut [c64], } - impl<'de, 'a> serde::de::DeserializeSeed<'de> for FillFourier<'a> { + impl<'de> serde::de::DeserializeSeed<'de> for FillFourier<'_> { type Value = (); fn deserialize>( diff --git a/tfhe/src/core_crypto/gpu/slice.rs b/tfhe/src/core_crypto/gpu/slice.rs index d5788b07a7..3c80ded482 100644 --- a/tfhe/src/core_crypto/gpu/slice.rs +++ b/tfhe/src/core_crypto/gpu/slice.rs @@ -23,7 +23,7 @@ pub struct CudaSliceMut<'a, T: Numeric> { _phantom_2: PhantomData<&'a mut ()>, } -impl<'a, T> CudaSlice<'a, T> +impl CudaSlice<'_, T> where T: Numeric, { @@ -53,7 +53,7 @@ where } } -impl<'a, T> CudaSliceMut<'a, T> +impl CudaSliceMut<'_, T> where T: Numeric, { diff --git a/tfhe/src/high_level_api/array/cpu/booleans.rs b/tfhe/src/high_level_api/array/cpu/booleans.rs index 8cbf12c8af..d41a17fbcd 100644 --- a/tfhe/src/high_level_api/array/cpu/booleans.rs +++ b/tfhe/src/high_level_api/array/cpu/booleans.rs @@ -36,7 +36,7 @@ impl ArrayBackend for CpuFheBoolArrayBackend { type Owned = Vec; } -impl<'a> BackendDataContainer for &'a [BooleanBlock] { +impl BackendDataContainer for &[BooleanBlock] { type Backend = CpuFheBoolArrayBackend; fn len(&self) -> usize { @@ -55,7 +55,7 @@ impl<'a> BackendDataContainer for &'a [BooleanBlock] { } } -impl<'a> BackendDataContainer for &'a mut [BooleanBlock] { +impl BackendDataContainer for &mut [BooleanBlock] { type Backend = CpuFheBoolArrayBackend; fn len(&self) -> usize { @@ -74,7 +74,7 @@ impl<'a> BackendDataContainer for &'a mut [BooleanBlock] { } } -impl<'a> BackendDataContainerMut for &'a mut [BooleanBlock] { +impl BackendDataContainerMut for &mut [BooleanBlock] { fn as_sub_slice_mut( &mut self, range: impl RangeBounds, @@ -220,7 +220,7 @@ impl FheTryEncrypt<&[bool], ClientKey> for CpuFheBoolArray { } } -impl<'a> FheDecrypt> for CpuFheBoolSlice<'a> { +impl FheDecrypt> for CpuFheBoolSlice<'_> { fn decrypt(&self, key: &ClientKey) -> Vec { self.elems .iter() @@ -229,7 +229,7 @@ impl<'a> FheDecrypt> for CpuFheBoolSlice<'a> { } } -impl<'a> FheDecrypt> for CpuFheBoolSliceMut<'a> { +impl FheDecrypt> for CpuFheBoolSliceMut<'_> { fn decrypt(&self, key: &ClientKey) -> Vec { self.as_slice().decrypt(key) } diff --git a/tfhe/src/high_level_api/array/cpu/integers.rs b/tfhe/src/high_level_api/array/cpu/integers.rs index dd6be38fc3..dc9a639b9d 100644 --- a/tfhe/src/high_level_api/array/cpu/integers.rs +++ b/tfhe/src/high_level_api/array/cpu/integers.rs @@ -367,7 +367,7 @@ where } } -impl<'a, T> BackendDataContainer for &'a [T] +impl BackendDataContainer for &[T] where T: IntegerRadixCiphertext, { @@ -389,7 +389,7 @@ where } } -impl<'a, T> BackendDataContainer for &'a mut [T] +impl BackendDataContainer for &mut [T] where T: IntegerRadixCiphertext, { @@ -411,7 +411,7 @@ where } } -impl<'a, T> BackendDataContainerMut for &'a mut [T] +impl BackendDataContainerMut for &mut [T] where T: IntegerRadixCiphertext, { @@ -481,7 +481,7 @@ where } } -impl<'a, Clear, Id> FheDecrypt> for CpuFheUintSliceMut<'a, Id> +impl FheDecrypt> for CpuFheUintSliceMut<'_, Id> where Id: FheUintId, Clear: RecomposableFrom + UnsignedNumeric, @@ -491,7 +491,7 @@ where } } -impl<'a, Clear, Id> FheDecrypt> for CpuFheUintSlice<'a, Id> +impl FheDecrypt> for CpuFheUintSlice<'_, Id> where Id: FheUintId, Clear: RecomposableFrom + UnsignedNumeric, @@ -534,7 +534,7 @@ where } } -impl<'a, Clear, Id> FheDecrypt> for CpuFheIntSliceMut<'a, Id> +impl FheDecrypt> for CpuFheIntSliceMut<'_, Id> where Id: FheIntId, Clear: RecomposableSignedInteger, @@ -544,7 +544,7 @@ where } } -impl<'a, Clear, Id> FheDecrypt> for CpuFheIntSlice<'a, Id> +impl FheDecrypt> for CpuFheIntSlice<'_, Id> where Id: FheIntId, Clear: RecomposableSignedInteger, diff --git a/tfhe/src/high_level_api/array/cpu/mod.rs b/tfhe/src/high_level_api/array/cpu/mod.rs index 1092a9bd4d..d565c06161 100644 --- a/tfhe/src/high_level_api/array/cpu/mod.rs +++ b/tfhe/src/high_level_api/array/cpu/mod.rs @@ -57,7 +57,7 @@ where type Owned = ClearContainer>; } -impl<'a, T> BackendDataContainer for ClearContainer<&'a [T]> +impl BackendDataContainer for ClearContainer<&'_ [T]> where T: Copy, { @@ -79,7 +79,7 @@ where } } -impl<'a, T> BackendDataContainer for ClearContainer<&'a mut [T]> +impl BackendDataContainer for ClearContainer<&mut [T]> where T: Copy, { @@ -101,7 +101,7 @@ where } } -impl<'a, T> BackendDataContainerMut for ClearContainer<&'a mut [T]> +impl BackendDataContainerMut for ClearContainer<&mut [T]> where T: Copy, { diff --git a/tfhe/src/high_level_api/array/dynamic/booleans.rs b/tfhe/src/high_level_api/array/dynamic/booleans.rs index 14f22decd1..ff83541054 100644 --- a/tfhe/src/high_level_api/array/dynamic/booleans.rs +++ b/tfhe/src/high_level_api/array/dynamic/booleans.rs @@ -229,7 +229,7 @@ pub enum InnerBoolSlice<'a> { Cpu(&'a [BooleanBlock]), } -impl<'a> InnerBoolSlice<'a> { +impl InnerBoolSlice<'_> { fn on_cpu(&self) -> Cow<'_, [BooleanBlock]> { match self { InnerBoolSlice::Cpu(cpu_slice) => Cow::Borrowed(cpu_slice), @@ -237,7 +237,7 @@ impl<'a> InnerBoolSlice<'a> { } } -impl<'a> BackendDataContainer for InnerBoolSlice<'a> { +impl BackendDataContainer for InnerBoolSlice<'_> { type Backend = DynFheBoolArrayBackend; fn len(&self) -> usize { @@ -268,7 +268,7 @@ pub enum InnerBoolSliceMut<'a> { Cpu(&'a mut [BooleanBlock]), } -impl<'a> BackendDataContainer for InnerBoolSliceMut<'a> { +impl BackendDataContainer for InnerBoolSliceMut<'_> { type Backend = DynFheBoolArrayBackend; fn len(&self) -> usize { @@ -295,7 +295,7 @@ impl<'a> BackendDataContainer for InnerBoolSliceMut<'a> { } } -impl<'a> BackendDataContainerMut for InnerBoolSliceMut<'a> { +impl BackendDataContainerMut for InnerBoolSliceMut<'_> { fn as_sub_slice_mut( &mut self, range: impl RangeBounds, diff --git a/tfhe/src/high_level_api/array/dynamic/signed.rs b/tfhe/src/high_level_api/array/dynamic/signed.rs index 4b3f9e3363..77763b4912 100644 --- a/tfhe/src/high_level_api/array/dynamic/signed.rs +++ b/tfhe/src/high_level_api/array/dynamic/signed.rs @@ -74,7 +74,7 @@ pub enum InnerIntSlice<'a> { Cpu(&'a [SignedRadixCiphertext]), } -impl<'a> InnerIntSlice<'a> { +impl InnerIntSlice<'_> { pub(crate) fn on_cpu(&self) -> Cow<'_, [SignedRadixCiphertext]> { match self { Self::Cpu(cpu_slice) => Cow::Borrowed(cpu_slice), @@ -82,7 +82,7 @@ impl<'a> InnerIntSlice<'a> { } } -impl<'a> BackendDataContainer for InnerIntSlice<'a> { +impl BackendDataContainer for InnerIntSlice<'_> { type Backend = DynIntBackend; fn len(&self) -> usize { @@ -111,7 +111,7 @@ pub enum InnerIntSliceMut<'a> { Cpu(&'a mut [SignedRadixCiphertext]), } -impl<'a> BackendDataContainer for InnerIntSliceMut<'a> { +impl BackendDataContainer for InnerIntSliceMut<'_> { type Backend = DynIntBackend; fn len(&self) -> usize { @@ -136,7 +136,7 @@ impl<'a> BackendDataContainer for InnerIntSliceMut<'a> { } } -impl<'a> BackendDataContainerMut for InnerIntSliceMut<'a> { +impl BackendDataContainerMut for InnerIntSliceMut<'_> { fn as_sub_slice_mut(&mut self, range: impl RangeBounds) -> InnerIntSliceMut<'_> { match self { Self::Cpu(cpu_slice) => { diff --git a/tfhe/src/high_level_api/array/dynamic/unsigned.rs b/tfhe/src/high_level_api/array/dynamic/unsigned.rs index ae9f5b7b95..149e037060 100644 --- a/tfhe/src/high_level_api/array/dynamic/unsigned.rs +++ b/tfhe/src/high_level_api/array/dynamic/unsigned.rs @@ -36,7 +36,7 @@ pub enum InnerUintSlice<'a> { Cpu(&'a [RadixCiphertext]), } -impl<'a> InnerUintSlice<'a> { +impl InnerUintSlice<'_> { pub(crate) fn on_cpu(&self) -> Cow<'_, [RadixCiphertext]> { match self { InnerUintSlice::Cpu(cpu_slice) => Cow::Borrowed(cpu_slice), @@ -98,7 +98,7 @@ impl BackendDataContainerMut for InnerUintArray { } } -impl<'a> BackendDataContainer for InnerUintSlice<'a> { +impl BackendDataContainer for InnerUintSlice<'_> { type Backend = DynUintBackend; fn len(&self) -> usize { @@ -123,7 +123,7 @@ impl<'a> BackendDataContainer for InnerUintSlice<'a> { } } -impl<'a> BackendDataContainer for InnerUintSliceMut<'a> { +impl BackendDataContainer for InnerUintSliceMut<'_> { type Backend = DynUintBackend; fn len(&self) -> usize { @@ -148,7 +148,7 @@ impl<'a> BackendDataContainer for InnerUintSliceMut<'a> { } } -impl<'a> BackendDataContainerMut for InnerUintSliceMut<'a> { +impl BackendDataContainerMut for InnerUintSliceMut<'_> { fn as_sub_slice_mut(&mut self, range: impl RangeBounds) -> InnerUintSliceMut<'_> { match self { Self::Cpu(cpu_slice) => { @@ -403,7 +403,7 @@ where } } -impl<'a, Clear, Id> FheDecrypt> for FheUintSliceMut<'a, Id> +impl FheDecrypt> for FheUintSliceMut<'_, Id> where Id: FheUintId, Clear: RecomposableFrom + UnsignedNumeric, @@ -413,7 +413,7 @@ where } } -impl<'a, Clear, Id> FheDecrypt> for FheUintSlice<'a, Id> +impl FheDecrypt> for FheUintSlice<'_, Id> where Id: FheUintId, Clear: RecomposableFrom + UnsignedNumeric, diff --git a/tfhe/src/high_level_api/array/ops.rs b/tfhe/src/high_level_api/array/ops.rs index 7b311e436b..b6b9b7c3b4 100644 --- a/tfhe/src/high_level_api/array/ops.rs +++ b/tfhe/src/high_level_api/array/ops.rs @@ -111,9 +111,8 @@ where } } -impl<'a, 's, C1, Id> Not for &'a FheArrayBase +impl Not for &FheArrayBase where - 'a: 's, Id: Default, C1: BackendDataContainer, C1::Backend: BitwiseArrayBackend, diff --git a/tfhe/src/high_level_api/array/stride.rs b/tfhe/src/high_level_api/array/stride.rs index 15400f02b5..3be9b133af 100644 --- a/tfhe/src/high_level_api/array/stride.rs +++ b/tfhe/src/high_level_api/array/stride.rs @@ -194,13 +194,13 @@ impl<'a, T> Iterator for StridedIter<'a, T> { } } -impl<'a, T> ExactSizeIterator for StridedIter<'a, T> { +impl ExactSizeIterator for StridedIter<'_, T> { fn len(&self) -> usize { self.index_producer.len() } } -impl<'a, T> DoubleEndedIterator for StridedIter<'a, T> { +impl DoubleEndedIterator for StridedIter<'_, T> { fn next_back(&mut self) -> Option { let current_flat_index = self.index_producer.next_back()?; self.data.get(current_flat_index) @@ -240,13 +240,13 @@ impl<'a, T> Iterator for CountedStridedIter<'a, T> { } } -impl<'a, T> ExactSizeIterator for CountedStridedIter<'a, T> { +impl ExactSizeIterator for CountedStridedIter<'_, T> { fn len(&self) -> usize { self.max_count - self.current_count } } -impl<'a, T> DoubleEndedIterator for CountedStridedIter<'a, T> { +impl DoubleEndedIterator for CountedStridedIter<'_, T> { fn next_back(&mut self) -> Option { if self.current_count == 0 { None @@ -290,7 +290,7 @@ where } } -impl<'a, T> rayon::iter::IndexedParallelIterator for ParStridedIter<'a, T> +impl rayon::iter::IndexedParallelIterator for ParStridedIter<'_, T> where T: Send + Sync, { @@ -407,7 +407,7 @@ impl<'a, T> Iterator for OffsettedStridedIterMut<'a, T> { } } -impl<'a, T> DoubleEndedIterator for OffsettedStridedIterMut<'a, T> { +impl DoubleEndedIterator for OffsettedStridedIterMut<'_, T> { fn next_back(&mut self) -> Option { if self.current_count == 0 { None @@ -427,7 +427,7 @@ impl<'a, T> DoubleEndedIterator for OffsettedStridedIterMut<'a, T> { } } -impl<'a, T> ExactSizeIterator for OffsettedStridedIterMut<'a, T> { +impl ExactSizeIterator for OffsettedStridedIterMut<'_, T> { fn len(&self) -> usize { ExactSizeIterator::len(&self.index_producer) } @@ -466,7 +466,7 @@ where } } -impl<'a, T> rayon::iter::IndexedParallelIterator for ParStridedIterMut<'a, T> +impl rayon::iter::IndexedParallelIterator for ParStridedIterMut<'_, T> where T: Send, { diff --git a/tfhe/src/high_level_api/details.rs b/tfhe/src/high_level_api/details.rs index a846d5ce47..676a966cd8 100644 --- a/tfhe/src/high_level_api/details.rs +++ b/tfhe/src/high_level_api/details.rs @@ -7,7 +7,7 @@ pub(crate) enum MaybeCloned<'a, T> { Cloned(T), } -impl<'a, T> MaybeCloned<'a, T> { +impl MaybeCloned<'_, T> { pub(crate) fn into_owned(self) -> T where T: ToOwned, diff --git a/tfhe/src/high_level_api/tag.rs b/tfhe/src/high_level_api/tag.rs index 760b589530..2fdbd678fd 100644 --- a/tfhe/src/high_level_api/tag.rs +++ b/tfhe/src/high_level_api/tag.rs @@ -203,7 +203,7 @@ impl serde::Serialize for SmallVec { struct SmallVecVisitor; -impl<'de> serde::de::Visitor<'de> for SmallVecVisitor { +impl serde::de::Visitor<'_> for SmallVecVisitor { type Value = SmallVec; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/tfhe/src/integer/ciphertext/compressed_modulus_switched_ciphertext.rs b/tfhe/src/integer/ciphertext/compressed_modulus_switched_ciphertext.rs index 89b63c8ef1..ca791ac3c6 100644 --- a/tfhe/src/integer/ciphertext/compressed_modulus_switched_ciphertext.rs +++ b/tfhe/src/integer/ciphertext/compressed_modulus_switched_ciphertext.rs @@ -129,9 +129,9 @@ impl ParameterSetConformant for CompressedModulusSwitchedRadixCiphertextGeneric .all(|block| block.is_conformant(&shortint_params)); let last_item_ok = if params.num_blocks_per_integer % 2 == 1 { - last_block.as_ref().map_or(false, |last_block| { - last_block.is_conformant(¶ms.shortint_params) - }) + last_block + .as_ref() + .is_some_and(|last_block| last_block.is_conformant(¶ms.shortint_params)) } else { true }; diff --git a/tfhe/src/integer/gpu/server_key/radix/scalar_comparison.rs b/tfhe/src/integer/gpu/server_key/radix/scalar_comparison.rs index 9808634f23..39568ebaf5 100644 --- a/tfhe/src/integer/gpu/server_key/radix/scalar_comparison.rs +++ b/tfhe/src/integer/gpu/server_key/radix/scalar_comparison.rs @@ -41,7 +41,7 @@ impl CudaServerKey { let sign_bit_pos = self.message_modulus.0.ilog2() - 1; let sign_bit_is_set = scalar_blocks .get(ct_len.0 - 1) - .map_or(false, |block| (block >> sign_bit_pos) == 1); + .is_some_and(|block| (block >> sign_bit_pos) == 1); if scalar > Scalar::ZERO && (scalar_blocks.len() > ct_len.0 @@ -72,7 +72,7 @@ impl CudaServerKey { let sign_bit_pos = self.message_modulus.0.ilog2() - 1; let sign_bit_is_unset = scalar_blocks .get(ct_len.0 - 1) - .map_or(false, |block| (block >> sign_bit_pos) == 0); + .is_some_and(|block| (block >> sign_bit_pos) == 0); if at_least_one_block_is_not_full_of_1s || sign_bit_is_unset { // Scalar is smaller than lowest value of T diff --git a/tfhe/src/integer/key_switching_key/mod.rs b/tfhe/src/integer/key_switching_key/mod.rs index 338e087332..322c01a331 100644 --- a/tfhe/src/integer/key_switching_key/mod.rs +++ b/tfhe/src/integer/key_switching_key/mod.rs @@ -74,7 +74,7 @@ pub struct KeySwitchingKey { pub(crate) key: crate::shortint::KeySwitchingKey, } -impl<'keys> From> for KeySwitchingKey { +impl From> for KeySwitchingKey { fn from(value: KeySwitchingKeyBuildHelper) -> Self { Self { key: value.build_helper.into(), @@ -82,7 +82,7 @@ impl<'keys> From> for KeySwitchingKey { } } -impl<'keys> From> for KeySwitchingKeyMaterial { +impl From> for KeySwitchingKeyMaterial { fn from(value: KeySwitchingKeyBuildHelper) -> Self { Self { material: value.build_helper.key_switching_key_material, @@ -231,7 +231,7 @@ pub struct CompressedKeySwitchingKey { pub(crate) key: crate::shortint::CompressedKeySwitchingKey, } -impl<'keys> From> for CompressedKeySwitchingKey { +impl From> for CompressedKeySwitchingKey { fn from(value: CompressedKeySwitchingKeyBuildHelper) -> Self { Self { key: value.build_helper.into(), @@ -239,9 +239,7 @@ impl<'keys> From> for CompressedKeyS } } -impl<'keys> From> - for CompressedKeySwitchingKeyMaterial -{ +impl From> for CompressedKeySwitchingKeyMaterial { fn from(value: CompressedKeySwitchingKeyBuildHelper) -> Self { Self { material: value.build_helper.key_switching_key_material, diff --git a/tfhe/src/integer/server_key/radix_parallel/bit_extractor.rs b/tfhe/src/integer/server_key/radix_parallel/bit_extractor.rs index 415e4849ba..5953f2f289 100644 --- a/tfhe/src/integer/server_key/radix_parallel/bit_extractor.rs +++ b/tfhe/src/integer/server_key/radix_parallel/bit_extractor.rs @@ -18,7 +18,7 @@ pub(crate) struct BitExtractor<'a> { buffer: VecDeque, } -impl<'a> Iterator for BitExtractor<'a> { +impl Iterator for BitExtractor<'_> { type Item = Ciphertext; fn next(&mut self) -> Option { diff --git a/tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs b/tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs index a10d455e29..b558a15f1f 100644 --- a/tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs +++ b/tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs @@ -38,7 +38,7 @@ impl ServerKey { let sign_bit_pos = self.key.message_modulus.0.ilog2() - 1; let sign_bit_is_set = scalar_blocks .get(ct.blocks().len() - 1) - .map_or(false, |block| (block >> sign_bit_pos) == 1); + .is_some_and(|block| (block >> sign_bit_pos) == 1); if scalar > Scalar::ZERO && (scalar_blocks.len() > ct.blocks().len() @@ -69,7 +69,7 @@ impl ServerKey { let sign_bit_pos = self.key.message_modulus.0.ilog2() - 1; let sign_bit_is_unset = scalar_blocks .get(ct.blocks().len() - 1) - .map_or(false, |block| (block >> sign_bit_pos) == 0); + .is_some_and(|block| (block >> sign_bit_pos) == 0); if at_least_one_block_is_not_full_of_1s || sign_bit_is_unset { // Scalar is smaller than lowest value of T diff --git a/tfhe/src/keycache/mod.rs b/tfhe/src/keycache/mod.rs index 5968f2667b..d82059b5a2 100644 --- a/tfhe/src/keycache/mod.rs +++ b/tfhe/src/keycache/mod.rs @@ -87,7 +87,7 @@ pub mod utils { if path_buf.exists() { let file = File::open(&path_buf).unwrap(); // Lock for reading - file.lock_shared().unwrap(); + fs2::FileExt::lock_shared(&file).unwrap(); let file_reader = BufReader::new(file); bincode::deserialize_from::<_, (P, K)>(file_reader) .ok() diff --git a/tfhe/src/lib.rs b/tfhe/src/lib.rs index 93b220b05e..dd43fd7ec7 100644 --- a/tfhe/src/lib.rs +++ b/tfhe/src/lib.rs @@ -7,8 +7,14 @@ #![doc(test(attr(warn(unused))))] #![doc(test(attr(allow(unused_variables))))] #![doc(test(attr(allow(unused_imports))))] +// Enable all warnings first as it may break the "allow" priority/activation as some lints gets +// moved around in clippy categories + // Enable pedantic lints #![warn(clippy::pedantic)] +// Nursery lints +#![warn(clippy::nursery)] +#![warn(rustdoc::broken_intra_doc_links)] // The following lints have been temporarily allowed // They are expected to be fixed progressively #![allow(clippy::unreadable_literal)] // 830 @@ -50,8 +56,6 @@ #![allow(clippy::explicit_iter_loop)] // End allowed pedantic lints -// Nursery lints -#![warn(clippy::nursery)] // The following lints have been temporarily allowed // They are expected to be fixed progressively #![allow(clippy::missing_const_for_fn)] // 243 @@ -71,7 +75,8 @@ )] #![cfg_attr(all(doc, not(doctest)), feature(doc_auto_cfg))] #![cfg_attr(all(doc, not(doctest)), feature(doc_cfg))] -#![warn(rustdoc::broken_intra_doc_links)] +// Weird clippy lint triggering without any code location +#![cfg_attr(test, allow(clippy::large_stack_arrays))] #[cfg(feature = "__c_api")] pub mod c_api; diff --git a/tfhe/src/shortint/key_switching_key/mod.rs b/tfhe/src/shortint/key_switching_key/mod.rs index 60c61c45a4..b7ac707711 100644 --- a/tfhe/src/shortint/key_switching_key/mod.rs +++ b/tfhe/src/shortint/key_switching_key/mod.rs @@ -87,7 +87,7 @@ pub struct KeySwitchingKey { pub(crate) src_server_key: Option, } -impl<'keys> From> for KeySwitchingKey { +impl From> for KeySwitchingKey { fn from(value: KeySwitchingKeyBuildHelper) -> Self { let KeySwitchingKeyBuildHelper { key_switching_key_material, @@ -828,7 +828,7 @@ pub struct CompressedKeySwitchingKey { pub(crate) src_server_key: Option, } -impl<'keys> From> for CompressedKeySwitchingKey { +impl From> for CompressedKeySwitchingKey { fn from(value: CompressedKeySwitchingKeyBuildHelper) -> Self { let CompressedKeySwitchingKeyBuildHelper { key_switching_key_material, diff --git a/tfhe/src/strings/char_iter.rs b/tfhe/src/strings/char_iter.rs index 7ea508df5c..b73118a8c5 100644 --- a/tfhe/src/strings/char_iter.rs +++ b/tfhe/src/strings/char_iter.rs @@ -8,13 +8,13 @@ pub(super) struct OptionalEndSliceIter<'a, T> { last: Option<&'a T>, } -impl<'a, T> Clone for OptionalEndSliceIter<'a, T> { +impl Clone for OptionalEndSliceIter<'_, T> { fn clone(&self) -> Self { *self } } -impl<'a, T> Copy for OptionalEndSliceIter<'a, T> {} +impl Copy for OptionalEndSliceIter<'_, T> {} impl<'a, T> OptionalEndSliceIter<'a, T> { pub(super) fn len(&self) -> usize { @@ -62,7 +62,7 @@ pub mod iter { } } - impl<'a, T> DoubleEndedIterator for OptionalEndSliceIterator<'a, T> { + impl DoubleEndedIterator for OptionalEndSliceIterator<'_, T> { fn next_back(&mut self) -> Option { if let Some(last) = self.last.take() { Some(last) @@ -72,7 +72,7 @@ pub mod iter { } } - impl<'a, T> ExactSizeIterator for OptionalEndSliceIterator<'a, T> { + impl ExactSizeIterator for OptionalEndSliceIterator<'_, T> { fn len(&self) -> usize { self.slice_iter.len() + if self.last.is_some() { 1 } else { 0 } } diff --git a/tfhe/src/strings/ciphertext.rs b/tfhe/src/strings/ciphertext.rs index 583bdbd8ee..d770048361 100644 --- a/tfhe/src/strings/ciphertext.rs +++ b/tfhe/src/strings/ciphertext.rs @@ -65,7 +65,7 @@ pub enum GenericPatternRef<'a> { Enc(&'a FheString), } -impl<'a> GenericPatternRef<'a> { +impl GenericPatternRef<'_> { pub fn to_owned(self) -> GenericPattern { match self { GenericPatternRef::Clear(clear_string) => GenericPattern::Clear(clear_string.clone()), diff --git a/tfhe/src/strings/client_key.rs b/tfhe/src/strings/client_key.rs index 6ef66b8a4d..b7ac1a229d 100644 --- a/tfhe/src/strings/client_key.rs +++ b/tfhe/src/strings/client_key.rs @@ -21,7 +21,7 @@ impl ClientKey { pub fn trivial_encrypt_ascii(&self, str: &str, padding: Option) -> FheString { assert!(str.is_ascii() & !str.contains('\0')); - let padded = padding.map_or(false, |p| p != 0); + let padded = padding.is_some_and(|p| p != 0); let num_blocks = self.num_ascii_blocks(); @@ -54,7 +54,7 @@ impl ClientKey { pub fn encrypt_ascii(&self, str: &str, padding: Option) -> FheString { assert!(str.is_ascii() & !str.contains('\0')); - let padded = padding.map_or(false, |p| p != 0); + let padded = padding.is_some_and(|p| p != 0); let num_blocks = self.num_ascii_blocks(); diff --git a/toolchain.txt b/toolchain.txt index 25aa6fa47e..e56b2c71eb 100644 --- a/toolchain.txt +++ b/toolchain.txt @@ -1 +1 @@ -nightly-2024-10-03 +nightly-2024-11-29