Skip to content

Commit 0b55d24

Browse files
committed
Fix clippy lints
1 parent 3653fae commit 0b55d24

File tree

10 files changed

+40
-24
lines changed

10 files changed

+40
-24
lines changed

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
[workspace]
22
members = ["crates/*"]
33

4+
[workspace.lints.rust]
5+
elided-lifetimes-in-paths = "warn"
6+
unsafe_op_in_unsafe_fn = "warn"
7+
8+
[workspace.lints.clippy]
9+
needless_borrow = "allow"
10+
411
[workspace.package]
512
version = "0.3.0"
613
authors = ["Ross MacArthur <ross@macarthur.io>"]
@@ -37,6 +44,9 @@ default = ["macro", "std"]
3744
std = []
3845
macro = ["dep:vectrix-macro"]
3946

47+
[lints]
48+
workspace = true
49+
4050
[[bench]]
4151
name = "euler"
4252
harness = false

clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msrv = "1.87"

crates/macro/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ proc-macro = true
1616
proc-macro2 = "1.0"
1717
quote = "1.0"
1818
syn = "2.0"
19+
20+
[lints]
21+
workspace = true

crates/macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct Input {
1313
}
1414

1515
impl Parse for Input {
16-
fn parse(input: ParseStream) -> Result<Self> {
16+
fn parse(input: ParseStream<'_>) -> Result<Self> {
1717
let matrix = Matrix::parse_terminated_with(input, Vector::parse_separated_nonempty)?;
1818
Ok(Self { matrix })
1919
}

crates/stride/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ authors.workspace = true
1010
edition.workspace = true
1111
repository.workspace = true
1212
license.workspace = true
13+
14+
[lints]
15+
workspace = true

crates/stride/src/index.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ unsafe impl<T, const S: usize> StrideIndex<Stride<T, S>> for usize {
138138

139139
unsafe fn get_unchecked(self, stride: *const Stride<T, S>) -> *const Self::Output {
140140
let i = self.unstride::<S>();
141-
unsafe { (*stride).data.get_unchecked(i) }
141+
unsafe { (&*stride).data.get_unchecked(i) }
142142
}
143143

144144
unsafe fn get_unchecked_mut(self, stride: *mut Stride<T, S>) -> *mut Self::Output {
145145
let i = self.unstride::<S>();
146-
unsafe { (*stride).data.get_unchecked_mut(i) }
146+
unsafe { (&mut *stride).data.get_unchecked_mut(i) }
147147
}
148148

149149
#[track_caller]
@@ -176,13 +176,13 @@ macro_rules! impl_stride_index {
176176

177177
unsafe fn get_unchecked(self, stride: *const Stride<T, S>) -> *const Self::Output {
178178
let i = self.unstride::<S>();
179-
let slice = unsafe { (*stride).data.get_unchecked(i) };
179+
let slice = unsafe { (&*stride).data.get_unchecked(i) };
180180
Stride::new(slice)
181181
}
182182

183183
unsafe fn get_unchecked_mut(self, stride: *mut Stride<T, S>) -> *mut Self::Output {
184184
let i = self.unstride::<S>();
185-
let slice = unsafe { (*stride).data.get_unchecked_mut(i) };
185+
let slice = unsafe { (&mut *stride).data.get_unchecked_mut(i) };
186186
Stride::new_mut(slice)
187187
}
188188

crates/stride/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl<T, const S: usize> Stride<T, S> {
294294
/// assert_eq!(iterator.next(), Some(&5));
295295
/// assert_eq!(iterator.next(), None);
296296
/// ```
297-
pub fn iter(&self) -> Iter<T, S> {
297+
pub fn iter(&self) -> Iter<'_, T, S> {
298298
Iter::new(self)
299299
}
300300

@@ -312,7 +312,7 @@ impl<T, const S: usize> Stride<T, S> {
312312
/// }
313313
/// assert_eq!(slice, &[2, 1, 4, 2, 6, 3]);
314314
/// ```
315-
pub fn iter_mut(&mut self) -> IterMut<T, S> {
315+
pub fn iter_mut(&mut self) -> IterMut<'_, T, S> {
316316
IterMut::new(self)
317317
}
318318
}

crates/stride/tests/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use stride::Stride;
66
#[test]
77
fn stride_debug() {
88
let stride = Stride::<_, 1>::new(&[1, 2, 3, 4, 5]);
9-
assert_eq!(format!("{:?}", stride), "[1, 2, 3, 4, 5]");
9+
assert_eq!(format!("{stride:?}"), "[1, 2, 3, 4, 5]");
1010

1111
let stride = Stride::<_, 2>::new(&[1, 2, 3, 4, 5]);
12-
assert_eq!(format!("{:?}", stride), "[1, 3, 5]");
12+
assert_eq!(format!("{stride:?}"), "[1, 3, 5]");
1313

1414
let stride = Stride::<_, 3>::new(&[1, 2, 3, 4, 5]);
15-
assert_eq!(format!("{:?}", stride), "[1, 4]");
15+
assert_eq!(format!("{stride:?}"), "[1, 4]");
1616
}
1717

1818
#[test]

src/lib.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@
8282
//! Three types of element access are available.
8383
//!
8484
//! - `usize` indexing selects the nth element in the matrix as viewed in
85-
//! column-major order.
86-
//! ```
87-
//! # use vectrix::*;
88-
//! #
89-
//! let m = matrix![
90-
//! 1, 2, 3;
91-
//! 4, 5, 6;
92-
//! ];
93-
//! assert_eq!(m[1], 4);
94-
//! ```
85+
//! column-major order.
86+
//! ```
87+
//! # use vectrix::*;
88+
//! #
89+
//! let m = matrix![
90+
//! 1, 2, 3;
91+
//! 4, 5, 6;
92+
//! ];
93+
//! assert_eq!(m[1], 4);
94+
//! ```
9595
//!
9696
//! - `(usize, usize)` indexing selects the element at a particular row and
9797
//! column position.
@@ -278,7 +278,6 @@
278278
//! ```
279279
280280
#![no_std]
281-
#![warn(unsafe_op_in_unsafe_fn)]
282281

283282
#[cfg(feature = "std")]
284283
extern crate std;

tests/iter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use vectrix::{matrix, Matrix};
33
#[test]
44
fn into_iter_debug() {
55
let mut into_iter = matrix![1, 3; 3, 7].into_iter();
6-
assert_eq!(format!("{:?}", into_iter), "IntoIter([1, 3, 3, 7])");
6+
assert_eq!(format!("{into_iter:?}"), "IntoIter([1, 3, 3, 7])");
77
into_iter.next();
8-
assert_eq!(format!("{:?}", into_iter), "IntoIter([3, 3, 7])");
8+
assert_eq!(format!("{into_iter:?}"), "IntoIter([3, 3, 7])");
99
into_iter.next_back();
10-
assert_eq!(format!("{:?}", into_iter), "IntoIter([3, 3])");
10+
assert_eq!(format!("{into_iter:?}"), "IntoIter([3, 3])");
1111
}
1212

1313
#[test]

0 commit comments

Comments
 (0)