From 695fc9a5f5cd373c79a63ef715078f1a0c0aa043 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Wed, 16 Oct 2024 02:54:28 +0300 Subject: [PATCH] Fix new Clippy lints (#1511) --- rand_core/src/block.rs | 4 ++-- rand_distr/src/utils.rs | 5 +---- src/distr/distribution.rs | 2 +- src/distr/slice.rs | 2 +- src/distr/uniform.rs | 2 +- src/distr/weighted_index.rs | 6 +++--- src/seq/index.rs | 4 ++-- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/rand_core/src/block.rs b/rand_core/src/block.rs index c0243d4c..aa2252e6 100644 --- a/rand_core/src/block.rs +++ b/rand_core/src/block.rs @@ -120,10 +120,10 @@ pub trait CryptoBlockRng: BlockRngCore {} #[cfg_attr( feature = "serde", serde( - bound = "for<'x> R: Serialize + Deserialize<'x> + Sized, for<'x> R::Results: Serialize + Deserialize<'x>" + bound = "for<'x> R: Serialize + Deserialize<'x>, for<'x> R::Results: Serialize + Deserialize<'x>" ) )] -pub struct BlockRng { +pub struct BlockRng { results: R::Results, index: usize, /// The *core* part of the RNG, implementing the `generate` function. diff --git a/rand_distr/src/utils.rs b/rand_distr/src/utils.rs index 5879a152..f0cf2a10 100644 --- a/rand_distr/src/utils.rs +++ b/rand_distr/src/utils.rs @@ -67,10 +67,7 @@ pub(crate) fn log_gamma(x: F) -> F { /// * `pdf`: the probability density function /// * `zero_case`: manual sampling from the tail when we chose the /// bottom box (i.e. i == 0) - -// the perf improvement (25-50%) is definitely worth the extra code -// size from force-inlining. -#[inline(always)] +#[inline(always)] // Forced inlining improves the perf by 25-50% pub(crate) fn ziggurat( rng: &mut R, symmetric: bool, diff --git a/src/distr/distribution.rs b/src/distr/distribution.rs index 702e439e..cab4ce62 100644 --- a/src/distr/distribution.rs +++ b/src/distr/distribution.rs @@ -110,7 +110,7 @@ pub trait Distribution { } } -impl<'a, T, D: Distribution + ?Sized> Distribution for &'a D { +impl + ?Sized> Distribution for &D { fn sample(&self, rng: &mut R) -> T { (*self).sample(rng) } diff --git a/src/distr/slice.rs b/src/distr/slice.rs index 4e85610a..3eee65a9 100644 --- a/src/distr/slice.rs +++ b/src/distr/slice.rs @@ -127,7 +127,7 @@ impl std::error::Error for EmptySlice {} /// Note: the `String` is potentially left with excess capacity; optionally the /// user may call `string.shrink_to_fit()` afterwards. #[cfg(feature = "alloc")] -impl<'a> super::DistString for Slice<'a, char> { +impl super::DistString for Slice<'_, char> { fn append_string(&self, rng: &mut R, string: &mut String, len: usize) { // Get the max char length to minimize extra space. // Limit this check to avoid searching for long slice. diff --git a/src/distr/uniform.rs b/src/distr/uniform.rs index 210b4a5e..2368e04f 100644 --- a/src/distr/uniform.rs +++ b/src/distr/uniform.rs @@ -393,7 +393,7 @@ where self } } -impl<'a, Borrowed> SampleBorrow for &'a Borrowed +impl SampleBorrow for &Borrowed where Borrowed: SampleUniform, { diff --git a/src/distr/weighted_index.rs b/src/distr/weighted_index.rs index 3aed484d..fef5728e 100644 --- a/src/distr/weighted_index.rs +++ b/src/distr/weighted_index.rs @@ -256,7 +256,7 @@ pub struct WeightedIndexIter<'a, X: SampleUniform + PartialOrd> { index: usize, } -impl<'a, X> Debug for WeightedIndexIter<'a, X> +impl Debug for WeightedIndexIter<'_, X> where X: SampleUniform + PartialOrd + Debug, X::Sampler: Debug, @@ -269,7 +269,7 @@ where } } -impl<'a, X> Clone for WeightedIndexIter<'a, X> +impl Clone for WeightedIndexIter<'_, X> where X: SampleUniform + PartialOrd, { @@ -281,7 +281,7 @@ where } } -impl<'a, X> Iterator for WeightedIndexIter<'a, X> +impl Iterator for WeightedIndexIter<'_, X> where X: for<'b> core::ops::SubAssign<&'b X> + SampleUniform + PartialOrd + Clone, { diff --git a/src/seq/index.rs b/src/seq/index.rs index e66b5039..b22d6dc4 100644 --- a/src/seq/index.rs +++ b/src/seq/index.rs @@ -153,7 +153,7 @@ pub enum IndexVecIter<'a> { U64(slice::Iter<'a, u64>), } -impl<'a> Iterator for IndexVecIter<'a> { +impl Iterator for IndexVecIter<'_> { type Item = usize; #[inline] @@ -176,7 +176,7 @@ impl<'a> Iterator for IndexVecIter<'a> { } } -impl<'a> ExactSizeIterator for IndexVecIter<'a> {} +impl ExactSizeIterator for IndexVecIter<'_> {} /// Return type of `IndexVec::into_iter`. #[derive(Clone, Debug)]