Skip to content

Commit c66d408

Browse files
authored
Merge pull request #1171 from aganders3/fix-ci
Fix CI failures (mostly linting with clippy)
2 parents 1839ec6 + f1fd0d4 commit c66d408

12 files changed

+30
-28
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
name = "ndarray"
44
version = "0.15.5"
55
edition = "2018"
6+
rust-version = "1.51"
67
authors = [
78
"Ulrik Sverdrup \"bluss\"",
89
"Jim Turner"

src/arrayformat.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ where
189189
/// to each element.
190190
///
191191
/// The array is shown in multiline style.
192-
impl<'a, A: fmt::Display, S, D: Dimension> fmt::Display for ArrayBase<S, D>
192+
impl<A: fmt::Display, S, D: Dimension> fmt::Display for ArrayBase<S, D>
193193
where
194194
S: Data<Elem = A>,
195195
{
@@ -203,7 +203,7 @@ where
203203
/// to each element.
204204
///
205205
/// The array is shown in multiline style.
206-
impl<'a, A: fmt::Debug, S, D: Dimension> fmt::Debug for ArrayBase<S, D>
206+
impl<A: fmt::Debug, S, D: Dimension> fmt::Debug for ArrayBase<S, D>
207207
where
208208
S: Data<Elem = A>,
209209
{
@@ -217,7 +217,7 @@ where
217217
", shape={:?}, strides={:?}, layout={:?}",
218218
self.shape(),
219219
self.strides(),
220-
layout = self.view().layout()
220+
self.view().layout(),
221221
)?;
222222
match D::NDIM {
223223
Some(ndim) => write!(f, ", const ndim={}", ndim)?,
@@ -231,7 +231,7 @@ where
231231
/// to each element.
232232
///
233233
/// The array is shown in multiline style.
234-
impl<'a, A: fmt::LowerExp, S, D: Dimension> fmt::LowerExp for ArrayBase<S, D>
234+
impl<A: fmt::LowerExp, S, D: Dimension> fmt::LowerExp for ArrayBase<S, D>
235235
where
236236
S: Data<Elem = A>,
237237
{
@@ -245,7 +245,7 @@ where
245245
/// to each element.
246246
///
247247
/// The array is shown in multiline style.
248-
impl<'a, A: fmt::UpperExp, S, D: Dimension> fmt::UpperExp for ArrayBase<S, D>
248+
impl<A: fmt::UpperExp, S, D: Dimension> fmt::UpperExp for ArrayBase<S, D>
249249
where
250250
S: Data<Elem = A>,
251251
{
@@ -258,7 +258,7 @@ where
258258
/// to each element.
259259
///
260260
/// The array is shown in multiline style.
261-
impl<'a, A: fmt::LowerHex, S, D: Dimension> fmt::LowerHex for ArrayBase<S, D>
261+
impl<A: fmt::LowerHex, S, D: Dimension> fmt::LowerHex for ArrayBase<S, D>
262262
where
263263
S: Data<Elem = A>,
264264
{
@@ -272,7 +272,7 @@ where
272272
/// to each element.
273273
///
274274
/// The array is shown in multiline style.
275-
impl<'a, A: fmt::Binary, S, D: Dimension> fmt::Binary for ArrayBase<S, D>
275+
impl<A: fmt::Binary, S, D: Dimension> fmt::Binary for ArrayBase<S, D>
276276
where
277277
S: Data<Elem = A>,
278278
{

src/arraytraits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ where
252252
}
253253
}
254254

255-
impl<'a, S, D> hash::Hash for ArrayBase<S, D>
255+
impl<S, D> hash::Hash for ArrayBase<S, D>
256256
where
257257
D: Dimension,
258258
S: Data,

src/data_traits.rs

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub unsafe trait DataMut: Data + RawDataMut {
162162
/// Returns whether the array has unique access to its data.
163163
#[doc(hidden)]
164164
#[inline]
165+
#[allow(clippy::wrong_self_convention)] // mut needed for Arc types
165166
fn is_unique(&mut self) -> bool {
166167
self.try_is_unique().unwrap()
167168
}

src/dimension/dimension_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub trait Dimension:
293293
let mut cstride = 1;
294294
for &i in order.slice() {
295295
// a dimension of length 1 can have unequal strides
296-
if dim_slice[i] != 1 && (strides[i] as isize).abs() as usize != cstride {
296+
if dim_slice[i] != 1 && (strides[i] as isize).unsigned_abs() != cstride {
297297
return false;
298298
}
299299
cstride *= dim_slice[i];

src/dimension/dynindeximpl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<T> Deref for IxDynRepr<T> {
2121
debug_assert!(len as usize <= ar.len());
2222
unsafe { ar.get_unchecked(..len as usize) }
2323
}
24-
IxDynRepr::Alloc(ref ar) => &*ar,
24+
IxDynRepr::Alloc(ref ar) => ar,
2525
}
2626
}
2727
}
@@ -33,7 +33,7 @@ impl<T> DerefMut for IxDynRepr<T> {
3333
debug_assert!(len as usize <= ar.len());
3434
unsafe { ar.get_unchecked_mut(..len as usize) }
3535
}
36-
IxDynRepr::Alloc(ref mut ar) => &mut *ar,
36+
IxDynRepr::Alloc(ref mut ar) => ar,
3737
}
3838
}
3939
}

src/dimension/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ where
185185
.try_fold(0usize, |acc, (&d, &s)| {
186186
let s = s as isize;
187187
// Calculate maximum possible absolute movement along this axis.
188-
let off = d.saturating_sub(1).checked_mul(s.abs() as usize)?;
188+
let off = d.saturating_sub(1).checked_mul(s.unsigned_abs())?;
189189
acc.checked_add(off)
190190
})
191191
.ok_or_else(|| from_kind(ErrorKind::Overflow))?;
@@ -333,7 +333,7 @@ where
333333
}
334334
}
335335

336-
impl<'a> DimensionExt for [Ix] {
336+
impl DimensionExt for [Ix] {
337337
#[inline]
338338
fn axis(&self, axis: Axis) -> Ix {
339339
self[axis.index()]
@@ -457,7 +457,7 @@ pub fn do_slice(dim: &mut usize, stride: &mut usize, slice: Slice) -> isize {
457457
};
458458

459459
// Update dimension.
460-
let abs_step = step.abs() as usize;
460+
let abs_step = step.unsigned_abs();
461461
*dim = if abs_step == 1 {
462462
m
463463
} else {
@@ -651,7 +651,7 @@ pub fn slices_intersect<D: Dimension>(
651651
Some(m) => m,
652652
None => return false,
653653
};
654-
if ind < min || ind > max || (ind - min) % step.abs() as usize != 0 {
654+
if ind < min || ind > max || (ind - min) % step.unsigned_abs() != 0 {
655655
return false;
656656
}
657657
}

src/dimension/ndindex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ unsafe impl<'a> NdIndex<IxDyn> for &'a IxDyn {
230230

231231
unsafe impl<'a> NdIndex<IxDyn> for &'a [Ix] {
232232
fn index_checked(&self, dim: &IxDyn, strides: &IxDyn) -> Option<isize> {
233-
stride_offset_checked(dim.ix(), strides.ix(), *self)
233+
stride_offset_checked(dim.ix(), strides.ix(), self)
234234
}
235235
fn index_unchecked(&self, strides: &IxDyn) -> isize {
236236
zip(strides.ix(), *self)

src/impl_constructors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ where
634634

635635
#[deprecated(note = "This method is hard to use correctly. Use `uninit` instead.",
636636
since = "0.15.0")]
637+
#[allow(clippy::uninit_vec)] // this is explicitly intended to create uninitialized memory
637638
/// Create an array with uninitialized elements, shape `shape`.
638639
///
639640
/// Prefer to use [`uninit()`](ArrayBase::uninit) if possible, because it is

src/iterators/lanes.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,16 @@ impl<'a, A, D: Dimension> Lanes<'a, A, D> {
3939
let ndim = v.ndim();
4040
let len;
4141
let stride;
42-
let iter_v;
43-
if ndim == 0 {
42+
let iter_v = if ndim == 0 {
4443
len = 1;
4544
stride = 1;
46-
iter_v = v.try_remove_axis(Axis(0))
45+
v.try_remove_axis(Axis(0))
4746
} else {
4847
let i = axis.index();
4948
len = v.dim[i];
5049
stride = v.strides[i] as isize;
51-
iter_v = v.try_remove_axis(axis)
52-
}
50+
v.try_remove_axis(axis)
51+
};
5352
Lanes {
5453
inner_len: len,
5554
inner_stride: stride,
@@ -108,17 +107,16 @@ impl<'a, A, D: Dimension> LanesMut<'a, A, D> {
108107
let ndim = v.ndim();
109108
let len;
110109
let stride;
111-
let iter_v;
112-
if ndim == 0 {
110+
let iter_v = if ndim == 0 {
113111
len = 1;
114112
stride = 1;
115-
iter_v = v.try_remove_axis(Axis(0))
113+
v.try_remove_axis(Axis(0))
116114
} else {
117115
let i = axis.index();
118116
len = v.dim[i];
119117
stride = v.strides[i] as isize;
120-
iter_v = v.try_remove_axis(axis)
121-
}
118+
v.try_remove_axis(axis)
119+
};
122120
LanesMut {
123121
inner_len: len,
124122
inner_stride: stride,

src/iterators/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<A, D: Dimension> Iterator for Baseiter<A, D> {
103103
}
104104
}
105105

106-
impl<'a, A, D: Dimension> ExactSizeIterator for Baseiter<A, D> {
106+
impl<A, D: Dimension> ExactSizeIterator for Baseiter<A, D> {
107107
fn len(&self) -> usize {
108108
match self.index {
109109
None => 0,

src/itertools.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ where
8686
/// **Note:** To enable the macros in this crate, use the `#[macro_use]`
8787
/// attribute when importing the crate:
8888
///
89-
/// ```
89+
/// ```no_run
90+
/// # #[allow(unused_imports)]
9091
/// #[macro_use] extern crate itertools;
9192
/// # fn main() { }
9293
/// ```

0 commit comments

Comments
 (0)