From 5b449e882da9f545547108184398005155862b2a Mon Sep 17 00:00:00 2001 From: Adam Kern Date: Sat, 30 Nov 2024 12:32:26 -0500 Subject: [PATCH 1/2] Fixes a variety of lifetime elision warnings in CI/CD I frankly don't understand why these are just showing up now --- ndarray-rand/tests/tests.rs | 2 +- src/argument_traits.rs | 8 +++---- src/array_serde.rs | 4 ++-- src/arraytraits.rs | 4 ++-- src/data_traits.rs | 24 ++++++++++---------- src/dimension/axes.rs | 4 ++-- src/dimension/ndindex.rs | 6 ++--- src/impl_cow.rs | 2 +- src/impl_views/constructors.rs | 4 ++-- src/impl_views/indexing.rs | 2 +- src/impl_views/splitting.rs | 2 +- src/iterators/mod.rs | 40 +++++++++++++++++----------------- src/lib.rs | 2 +- src/split_at.rs | 2 +- tests/azip.rs | 12 +++++----- 15 files changed, 59 insertions(+), 59 deletions(-) diff --git a/ndarray-rand/tests/tests.rs b/ndarray-rand/tests/tests.rs index e39347c0c..d38e8636e 100644 --- a/ndarray-rand/tests/tests.rs +++ b/ndarray-rand/tests/tests.rs @@ -122,7 +122,7 @@ fn sampling_works(a: &Array2, strategy: SamplingStrategy, axis: Axis, n_sam let samples = a.sample_axis(axis, n_samples, strategy); samples .axis_iter(axis) - .all(|lane| is_subset(&a, &lane, axis)) + .all(|lane| is_subset(a, &lane, axis)) } // Check if, when sliced along `axis`, there is at least one lane in `a` equal to `b` diff --git a/src/argument_traits.rs b/src/argument_traits.rs index de8ac7f99..c4e85186a 100644 --- a/src/argument_traits.rs +++ b/src/argument_traits.rs @@ -11,7 +11,7 @@ pub trait AssignElem } /// Assignable element, simply `*self = input`. -impl<'a, T> AssignElem for &'a mut T +impl AssignElem for &mut T { fn assign_elem(self, input: T) { @@ -20,7 +20,7 @@ impl<'a, T> AssignElem for &'a mut T } /// Assignable element, simply `self.set(input)`. -impl<'a, T> AssignElem for &'a Cell +impl AssignElem for &Cell { fn assign_elem(self, input: T) { @@ -29,7 +29,7 @@ impl<'a, T> AssignElem for &'a Cell } /// Assignable element, simply `self.set(input)`. -impl<'a, T> AssignElem for &'a MathCell +impl AssignElem for &MathCell { fn assign_elem(self, input: T) { @@ -39,7 +39,7 @@ impl<'a, T> AssignElem for &'a MathCell /// Assignable element, the item in the MaybeUninit is overwritten (prior value, if any, is not /// read or dropped). -impl<'a, T> AssignElem for &'a mut MaybeUninit +impl AssignElem for &mut MaybeUninit { fn assign_elem(self, input: T) { diff --git a/src/array_serde.rs b/src/array_serde.rs index 31b613d4c..50d9c2905 100644 --- a/src/array_serde.rs +++ b/src/array_serde.rs @@ -98,7 +98,7 @@ where // private iterator wrapper struct Sequence<'a, A, D>(Iter<'a, A, D>); -impl<'a, A, D> Serialize for Sequence<'a, A, D> +impl Serialize for Sequence<'_, A, D> where A: Serialize, D: Dimension + Serialize, @@ -162,7 +162,7 @@ impl<'de> Deserialize<'de> for ArrayField { struct ArrayFieldVisitor; - impl<'de> Visitor<'de> for ArrayFieldVisitor + impl Visitor<'_> for ArrayFieldVisitor { type Value = ArrayField; diff --git a/src/arraytraits.rs b/src/arraytraits.rs index e68b5d56a..d7a00fcfe 100644 --- a/src/arraytraits.rs +++ b/src/arraytraits.rs @@ -128,7 +128,7 @@ where /// Return `true` if the array shapes and all elements of `self` and /// `rhs` are equal. Return `false` otherwise. #[allow(clippy::unconditional_recursion)] // false positive -impl<'a, A, B, S, S2, D> PartialEq<&'a ArrayBase> for ArrayBase +impl PartialEq<&ArrayBase> for ArrayBase where A: PartialEq, S: Data, @@ -144,7 +144,7 @@ where /// Return `true` if the array shapes and all elements of `self` and /// `rhs` are equal. Return `false` otherwise. #[allow(clippy::unconditional_recursion)] // false positive -impl<'a, A, B, S, S2, D> PartialEq> for &'a ArrayBase +impl PartialEq> for &ArrayBase where A: PartialEq, S: Data, diff --git a/src/data_traits.rs b/src/data_traits.rs index f43bfb4ef..fc2fe4bfa 100644 --- a/src/data_traits.rs +++ b/src/data_traits.rs @@ -407,7 +407,7 @@ where A: Clone } } -unsafe impl<'a, A> RawData for ViewRepr<&'a A> +unsafe impl RawData for ViewRepr<&A> { type Elem = A; @@ -420,7 +420,7 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a A> private_impl! {} } -unsafe impl<'a, A> Data for ViewRepr<&'a A> +unsafe impl Data for ViewRepr<&A> { fn into_owned(self_: ArrayBase) -> Array where @@ -437,7 +437,7 @@ unsafe impl<'a, A> Data for ViewRepr<&'a A> } } -unsafe impl<'a, A> RawDataClone for ViewRepr<&'a A> +unsafe impl RawDataClone for ViewRepr<&A> { unsafe fn clone_with_ptr(&self, ptr: NonNull) -> (Self, NonNull) { @@ -445,7 +445,7 @@ unsafe impl<'a, A> RawDataClone for ViewRepr<&'a A> } } -unsafe impl<'a, A> RawData for ViewRepr<&'a mut A> +unsafe impl RawData for ViewRepr<&mut A> { type Elem = A; @@ -458,7 +458,7 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a mut A> private_impl! {} } -unsafe impl<'a, A> RawDataMut for ViewRepr<&'a mut A> +unsafe impl RawDataMut for ViewRepr<&mut A> { #[inline] fn try_ensure_unique(_: &mut ArrayBase) @@ -475,7 +475,7 @@ unsafe impl<'a, A> RawDataMut for ViewRepr<&'a mut A> } } -unsafe impl<'a, A> Data for ViewRepr<&'a mut A> +unsafe impl Data for ViewRepr<&mut A> { fn into_owned(self_: ArrayBase) -> Array where @@ -492,7 +492,7 @@ unsafe impl<'a, A> Data for ViewRepr<&'a mut A> } } -unsafe impl<'a, A> DataMut for ViewRepr<&'a mut A> {} +unsafe impl DataMut for ViewRepr<&mut A> {} /// Array representation trait. /// @@ -533,7 +533,7 @@ pub unsafe trait DataOwned: Data pub unsafe trait DataShared: Clone + Data + RawDataClone {} unsafe impl DataShared for OwnedArcRepr {} -unsafe impl<'a, A> DataShared for ViewRepr<&'a A> {} +unsafe impl DataShared for ViewRepr<&A> {} unsafe impl DataOwned for OwnedRepr { @@ -571,7 +571,7 @@ unsafe impl DataOwned for OwnedArcRepr } } -unsafe impl<'a, A> RawData for CowRepr<'a, A> +unsafe impl RawData for CowRepr<'_, A> { type Elem = A; @@ -587,7 +587,7 @@ unsafe impl<'a, A> RawData for CowRepr<'a, A> private_impl! {} } -unsafe impl<'a, A> RawDataMut for CowRepr<'a, A> +unsafe impl RawDataMut for CowRepr<'_, A> where A: Clone { #[inline] @@ -615,7 +615,7 @@ where A: Clone } } -unsafe impl<'a, A> RawDataClone for CowRepr<'a, A> +unsafe impl RawDataClone for CowRepr<'_, A> where A: Clone { unsafe fn clone_with_ptr(&self, ptr: NonNull) -> (Self, NonNull) @@ -681,7 +681,7 @@ unsafe impl<'a, A> Data for CowRepr<'a, A> } } -unsafe impl<'a, A> DataMut for CowRepr<'a, A> where A: Clone {} +unsafe impl DataMut for CowRepr<'_, A> where A: Clone {} unsafe impl<'a, A> DataOwned for CowRepr<'a, A> { diff --git a/src/dimension/axes.rs b/src/dimension/axes.rs index 45b7a75f0..c7aaff149 100644 --- a/src/dimension/axes.rs +++ b/src/dimension/axes.rs @@ -60,7 +60,7 @@ pub struct AxisDescription copy_and_clone!(AxisDescription); copy_and_clone!(['a, D] Axes<'a, D>); -impl<'a, D> Iterator for Axes<'a, D> +impl Iterator for Axes<'_, D> where D: Dimension { /// Description of the axis, its length and its stride. @@ -99,7 +99,7 @@ where D: Dimension } } -impl<'a, D> DoubleEndedIterator for Axes<'a, D> +impl DoubleEndedIterator for Axes<'_, D> where D: Dimension { fn next_back(&mut self) -> Option diff --git a/src/dimension/ndindex.rs b/src/dimension/ndindex.rs index 7bc2c54ef..ca2a3ea69 100644 --- a/src/dimension/ndindex.rs +++ b/src/dimension/ndindex.rs @@ -255,7 +255,7 @@ unsafe impl NdIndex for [Ix; N] } } -impl<'a> IntoDimension for &'a [Ix] +impl IntoDimension for &[Ix] { type Dim = IxDyn; fn into_dimension(self) -> Self::Dim @@ -264,7 +264,7 @@ impl<'a> IntoDimension for &'a [Ix] } } -unsafe impl<'a> NdIndex for &'a IxDyn +unsafe impl NdIndex for &IxDyn { fn index_checked(&self, dim: &IxDyn, strides: &IxDyn) -> Option { @@ -276,7 +276,7 @@ unsafe impl<'a> NdIndex for &'a IxDyn } } -unsafe impl<'a> NdIndex for &'a [Ix] +unsafe impl NdIndex for &[Ix] { fn index_checked(&self, dim: &IxDyn, strides: &IxDyn) -> Option { diff --git a/src/impl_cow.rs b/src/impl_cow.rs index f064ce7bd..4843e305b 100644 --- a/src/impl_cow.rs +++ b/src/impl_cow.rs @@ -11,7 +11,7 @@ use crate::imp_prelude::*; /// Methods specific to `CowArray`. /// /// ***See also all methods for [`ArrayBase`]*** -impl<'a, A, D> CowArray<'a, A, D> +impl CowArray<'_, A, D> where D: Dimension { /// Returns `true` iff the array is the view (borrowed) variant. diff --git a/src/impl_views/constructors.rs b/src/impl_views/constructors.rs index 15f2b9b6b..d0089057d 100644 --- a/src/impl_views/constructors.rs +++ b/src/impl_views/constructors.rs @@ -230,7 +230,7 @@ where D: Dimension } /// Private array view methods -impl<'a, A, D> ArrayView<'a, A, D> +impl ArrayView<'_, A, D> where D: Dimension { /// Create a new `ArrayView` @@ -254,7 +254,7 @@ where D: Dimension } } -impl<'a, A, D> ArrayViewMut<'a, A, D> +impl ArrayViewMut<'_, A, D> where D: Dimension { /// Create a new `ArrayView` diff --git a/src/impl_views/indexing.rs b/src/impl_views/indexing.rs index 2b72c2142..827313478 100644 --- a/src/impl_views/indexing.rs +++ b/src/impl_views/indexing.rs @@ -100,7 +100,7 @@ pub trait IndexLonger unsafe fn uget(self, index: I) -> Self::Output; } -impl<'a, 'b, I, A, D> IndexLonger for &'b ArrayView<'a, A, D> +impl<'a, I, A, D> IndexLonger for &ArrayView<'a, A, D> where I: NdIndex, D: Dimension, diff --git a/src/impl_views/splitting.rs b/src/impl_views/splitting.rs index 6d6ea275b..58d0a7556 100644 --- a/src/impl_views/splitting.rs +++ b/src/impl_views/splitting.rs @@ -11,7 +11,7 @@ use crate::slice::MultiSliceArg; use num_complex::Complex; /// Methods for read-only array views. -impl<'a, A, D> ArrayView<'a, A, D> +impl ArrayView<'_, A, D> where D: Dimension { /// Split the array view along `axis` and return one view strictly before the diff --git a/src/iterators/mod.rs b/src/iterators/mod.rs index e7321d15b..01fff14f5 100644 --- a/src/iterators/mod.rs +++ b/src/iterators/mod.rs @@ -260,7 +260,7 @@ impl<'a, A> DoubleEndedIterator for ElementsBase<'a, A, Ix1> } } -impl<'a, A, D> ExactSizeIterator for ElementsBase<'a, A, D> +impl ExactSizeIterator for ElementsBase<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -503,7 +503,7 @@ impl<'a, A> DoubleEndedIterator for Iter<'a, A, Ix1> } } -impl<'a, A, D> ExactSizeIterator for Iter<'a, A, D> +impl ExactSizeIterator for Iter<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -534,7 +534,7 @@ impl<'a, A, D: Dimension> Iterator for IndexedIter<'a, A, D> } } -impl<'a, A, D> ExactSizeIterator for IndexedIter<'a, A, D> +impl ExactSizeIterator for IndexedIter<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -635,7 +635,7 @@ impl<'a, A> DoubleEndedIterator for IterMut<'a, A, Ix1> } } -impl<'a, A, D> ExactSizeIterator for IterMut<'a, A, D> +impl ExactSizeIterator for IterMut<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -686,7 +686,7 @@ impl<'a, A> DoubleEndedIterator for ElementsBaseMut<'a, A, Ix1> } } -impl<'a, A, D> ExactSizeIterator for ElementsBaseMut<'a, A, D> +impl ExactSizeIterator for ElementsBaseMut<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -717,7 +717,7 @@ impl<'a, A, D: Dimension> Iterator for IndexedIterMut<'a, A, D> } } -impl<'a, A, D> ExactSizeIterator for IndexedIterMut<'a, A, D> +impl ExactSizeIterator for IndexedIterMut<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -767,7 +767,7 @@ where D: Dimension } } -impl<'a, A, D> ExactSizeIterator for LanesIter<'a, A, D> +impl ExactSizeIterator for LanesIter<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -776,7 +776,7 @@ where D: Dimension } } -impl<'a, A> DoubleEndedIterator for LanesIter<'a, A, Ix1> +impl DoubleEndedIterator for LanesIter<'_, A, Ix1> { fn next_back(&mut self) -> Option { @@ -819,7 +819,7 @@ where D: Dimension } } -impl<'a, A, D> ExactSizeIterator for LanesIterMut<'a, A, D> +impl ExactSizeIterator for LanesIterMut<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -828,7 +828,7 @@ where D: Dimension } } -impl<'a, A> DoubleEndedIterator for LanesIterMut<'a, A, Ix1> +impl DoubleEndedIterator for LanesIterMut<'_, A, Ix1> { fn next_back(&mut self) -> Option { @@ -1079,7 +1079,7 @@ where D: Dimension } } -impl<'a, A, D> DoubleEndedIterator for AxisIter<'a, A, D> +impl DoubleEndedIterator for AxisIter<'_, A, D> where D: Dimension { fn next_back(&mut self) -> Option @@ -1088,7 +1088,7 @@ where D: Dimension } } -impl<'a, A, D> ExactSizeIterator for AxisIter<'a, A, D> +impl ExactSizeIterator for AxisIter<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -1169,7 +1169,7 @@ where D: Dimension } } -impl<'a, A, D> DoubleEndedIterator for AxisIterMut<'a, A, D> +impl DoubleEndedIterator for AxisIterMut<'_, A, D> where D: Dimension { fn next_back(&mut self) -> Option @@ -1178,7 +1178,7 @@ where D: Dimension } } -impl<'a, A, D> ExactSizeIterator for AxisIterMut<'a, A, D> +impl ExactSizeIterator for AxisIterMut<'_, A, D> where D: Dimension { fn len(&self) -> usize @@ -1187,7 +1187,7 @@ where D: Dimension } } -impl<'a, A, D: Dimension> NdProducer for AxisIter<'a, A, D> +impl NdProducer for AxisIter<'_, A, D> { type Item = ::Item; type Dim = Ix1; @@ -1246,7 +1246,7 @@ impl<'a, A, D: Dimension> NdProducer for AxisIter<'a, A, D> private_impl! {} } -impl<'a, A, D: Dimension> NdProducer for AxisIterMut<'a, A, D> +impl NdProducer for AxisIterMut<'_, A, D> { type Item = ::Item; type Dim = Ix1; @@ -1555,12 +1555,12 @@ unsafe impl TrustedIterator for Linspace {} unsafe impl TrustedIterator for Geomspace {} #[cfg(feature = "std")] unsafe impl TrustedIterator for Logspace {} -unsafe impl<'a, A, D> TrustedIterator for Iter<'a, A, D> {} -unsafe impl<'a, A, D> TrustedIterator for IterMut<'a, A, D> {} +unsafe impl TrustedIterator for Iter<'_, A, D> {} +unsafe impl TrustedIterator for IterMut<'_, A, D> {} unsafe impl TrustedIterator for std::iter::Cloned where I: TrustedIterator {} unsafe impl TrustedIterator for std::iter::Map where I: TrustedIterator {} -unsafe impl<'a, A> TrustedIterator for slice::Iter<'a, A> {} -unsafe impl<'a, A> TrustedIterator for slice::IterMut<'a, A> {} +unsafe impl TrustedIterator for slice::Iter<'_, A> {} +unsafe impl TrustedIterator for slice::IterMut<'_, A> {} unsafe impl TrustedIterator for ::std::ops::Range {} // FIXME: These indices iter are dubious -- size needs to be checked up front. unsafe impl TrustedIterator for IndicesIter where D: Dimension {} diff --git a/src/lib.rs b/src/lib.rs index f52f25e5e..b163f16a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1498,7 +1498,7 @@ pub enum CowRepr<'a, A> Owned(OwnedRepr), } -impl<'a, A> CowRepr<'a, A> +impl CowRepr<'_, A> { /// Returns `true` iff the data is the `View` variant. pub fn is_view(&self) -> bool diff --git a/src/split_at.rs b/src/split_at.rs index 4af1403c0..5dee44b63 100644 --- a/src/split_at.rs +++ b/src/split_at.rs @@ -35,7 +35,7 @@ where D: Dimension } } -impl<'a, A, D> SplitAt for ArrayViewMut<'a, A, D> +impl SplitAt for ArrayViewMut<'_, A, D> where D: Dimension { fn split_at(self, axis: Axis, index: usize) -> (Self, Self) diff --git a/tests/azip.rs b/tests/azip.rs index 96be9d913..9d8bebab7 100644 --- a/tests/azip.rs +++ b/tests/azip.rs @@ -118,7 +118,7 @@ fn test_zip_collect_drop() struct Recorddrop<'a>((usize, usize), &'a RefCell>); - impl<'a> Drop for Recorddrop<'a> + impl Drop for Recorddrop<'_> { fn drop(&mut self) { @@ -470,9 +470,9 @@ fn test_zip_all() let b = Array::::ones(62); let mut c = Array::::ones(62); c[5] = 0.0; - assert_eq!(true, Zip::from(&a).and(&b).all(|&x, &y| x + y == 1.0)); - assert_eq!(false, Zip::from(&a).and(&b).all(|&x, &y| x == y)); - assert_eq!(false, Zip::from(&a).and(&c).all(|&x, &y| x + y == 1.0)); + assert!(Zip::from(&a).and(&b).all(|&x, &y| x + y == 1.0)); + assert!(!Zip::from(&a).and(&b).all(|&x, &y| x == y)); + assert!(!Zip::from(&a).and(&c).all(|&x, &y| x + y == 1.0)); } #[test] @@ -480,6 +480,6 @@ fn test_zip_all_empty_array() { let a = Array::::zeros(0); let b = Array::::ones(0); - assert_eq!(true, Zip::from(&a).and(&b).all(|&_x, &_y| true)); - assert_eq!(true, Zip::from(&a).and(&b).all(|&_x, &_y| false)); + assert!(Zip::from(&a).and(&b).all(|&_x, &_y| true)); + assert!(Zip::from(&a).and(&b).all(|&_x, &_y| false)); } From 84f6c2efbc54c9c1db06ca0892fe6586e3c14623 Mon Sep 17 00:00:00 2001 From: Adam Kern Date: Sat, 30 Nov 2024 12:36:24 -0500 Subject: [PATCH 2/2] And two more? --- crates/ndarray-gen/src/lib.rs | 1 - examples/bounds_check_elim.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/ndarray-gen/src/lib.rs b/crates/ndarray-gen/src/lib.rs index 7f9ca89fc..09440e68d 100644 --- a/crates/ndarray-gen/src/lib.rs +++ b/crates/ndarray-gen/src/lib.rs @@ -8,5 +8,4 @@ // except according to those terms. /// Build ndarray arrays for test purposes - pub mod array_builder; diff --git a/examples/bounds_check_elim.rs b/examples/bounds_check_elim.rs index e6b57c719..f1a91cca0 100644 --- a/examples/bounds_check_elim.rs +++ b/examples/bounds_check_elim.rs @@ -57,7 +57,7 @@ pub fn test1d_single_mut(a: &mut Array1, i: usize) -> f64 #[no_mangle] pub fn test1d_len_of(a: &Array1) -> f64 { - let a = &*a; + let a = a; let mut sum = 0.; for i in 0..a.len_of(Axis(0)) { sum += a[i];