Skip to content

Commit 99672aa

Browse files
committed
fix a pile of lint warnings
1 parent 66c7935 commit 99672aa

File tree

12 files changed

+70
-79
lines changed

12 files changed

+70
-79
lines changed

examples/linalg/Cargo.lock

Lines changed: 11 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/array.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub type PyArray6<T> = PyArray<T, Ix6>;
117117
pub type PyArrayDyn<T> = PyArray<T, IxDyn>;
118118

119119
/// Returns a handle to NumPy's multiarray module.
120-
pub fn get_array_module<'py>(py: Python<'py>) -> PyResult<Bound<'py, PyModule>> {
120+
pub fn get_array_module(py: Python<'_>) -> PyResult<Bound<'_, PyModule>> {
121121
PyModule::import(py, npyffi::array::mod_name(py)?)
122122
}
123123

@@ -127,7 +127,7 @@ unsafe impl<T: Element, D: Dimension> PyTypeInfo for PyArray<T, D> {
127127
const NAME: &'static str = "PyArray<T, D>";
128128
const MODULE: Option<&'static str> = Some("numpy");
129129

130-
fn type_object_raw<'py>(py: Python<'py>) -> *mut ffi::PyTypeObject {
130+
fn type_object_raw(py: Python<'_>) -> *mut ffi::PyTypeObject {
131131
unsafe { npyffi::PY_ARRAY_API.get_type_object(py, npyffi::NpyTypes::PyArray_Type) }
132132
}
133133

@@ -208,20 +208,20 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
208208
/// assert_eq!(arr.shape(), &[4, 5, 6]);
209209
/// });
210210
/// ```
211-
pub unsafe fn new<'py, ID>(py: Python<'py>, dims: ID, is_fortran: bool) -> Bound<'py, Self>
211+
pub unsafe fn new<ID>(py: Python<'_>, dims: ID, is_fortran: bool) -> Bound<'_, Self>
212212
where
213213
ID: IntoDimension<Dim = D>,
214214
{
215215
let flags = c_int::from(is_fortran);
216216
Self::new_uninit(py, dims, ptr::null_mut(), flags)
217217
}
218218

219-
pub(crate) unsafe fn new_uninit<'py, ID>(
220-
py: Python<'py>,
219+
pub(crate) unsafe fn new_uninit<ID>(
220+
py: Python<'_>,
221221
dims: ID,
222222
strides: *const npy_intp,
223223
flag: c_int,
224-
) -> Bound<'py, Self>
224+
) -> Bound<'_, Self>
225225
where
226226
ID: IntoDimension<Dim = D>,
227227
{
@@ -241,13 +241,13 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
241241
Bound::from_owned_ptr(py, ptr).downcast_into_unchecked()
242242
}
243243

244-
unsafe fn new_with_data<'py, ID>(
245-
py: Python<'py>,
244+
unsafe fn new_with_data<ID>(
245+
py: Python<'_>,
246246
dims: ID,
247247
strides: *const npy_intp,
248248
data_ptr: *const T,
249249
container: *mut PyAny,
250-
) -> Bound<'py, Self>
250+
) -> Bound<'_, Self>
251251
where
252252
ID: IntoDimension<Dim = D>,
253253
{
@@ -273,13 +273,13 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
273273
Bound::from_owned_ptr(py, ptr).downcast_into_unchecked()
274274
}
275275

276-
pub(crate) unsafe fn from_raw_parts<'py>(
277-
py: Python<'py>,
276+
pub(crate) unsafe fn from_raw_parts(
277+
py: Python<'_>,
278278
dims: D,
279279
strides: *const npy_intp,
280280
data_ptr: *const T,
281281
container: PySliceContainer,
282-
) -> Bound<'py, Self> {
282+
) -> Bound<'_, Self> {
283283
let container = Bound::new(py, container)
284284
.expect("Failed to create slice container")
285285
.into_ptr();
@@ -530,7 +530,7 @@ impl<T: Element> PyArray<T, Ix1> {
530530
/// });
531531
/// ```
532532
#[inline(always)]
533-
pub fn from_vec<'py>(py: Python<'py>, vec: Vec<T>) -> Bound<'py, Self> {
533+
pub fn from_vec(py: Python<'_>, vec: Vec<T>) -> Bound<'_, Self> {
534534
vec.into_pyarray(py)
535535
}
536536

@@ -682,7 +682,7 @@ impl<T: Element + AsPrimitive<f64>> PyArray<T, Ix1> {
682682
///
683683
/// [numpy.arange]: https://numpy.org/doc/stable/reference/generated/numpy.arange.html
684684
/// [PyArray_Arange]: https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_Arange
685-
pub fn arange<'py>(py: Python<'py>, start: T, stop: T, step: T) -> Bound<'py, Self> {
685+
pub fn arange(py: Python<'_>, start: T, stop: T, step: T) -> Bound<'_, Self> {
686686
unsafe {
687687
let ptr = PY_ARRAY_API.PyArray_Arange(
688688
py,

src/borrow/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ where
372372
}
373373
}
374374

375-
impl<'py, T, D> Clone for PyReadonlyArray<'py, T, D>
375+
impl<T, D> Clone for PyReadonlyArray<'_, T, D>
376376
where
377377
T: Element,
378378
D: Dimension,
@@ -386,7 +386,7 @@ where
386386
}
387387
}
388388

389-
impl<'py, T, D> Drop for PyReadonlyArray<'py, T, D>
389+
impl<T, D> Drop for PyReadonlyArray<'_, T, D>
390390
where
391391
T: Element,
392392
D: Dimension,
@@ -396,7 +396,7 @@ where
396396
}
397397
}
398398

399-
impl<'py, T, D> fmt::Debug for PyReadonlyArray<'py, T, D>
399+
impl<T, D> fmt::Debug for PyReadonlyArray<'_, T, D>
400400
where
401401
T: Element,
402402
D: Dimension,
@@ -590,7 +590,7 @@ where
590590
}
591591
}
592592

593-
impl<'py, T> PyReadwriteArray<'py, T, Ix1>
593+
impl<T> PyReadwriteArray<'_, T, Ix1>
594594
where
595595
T: Element,
596596
{
@@ -630,7 +630,7 @@ where
630630
}
631631
}
632632

633-
impl<'py, T, D> Drop for PyReadwriteArray<'py, T, D>
633+
impl<T, D> Drop for PyReadwriteArray<'_, T, D>
634634
where
635635
T: Element,
636636
D: Dimension,
@@ -640,7 +640,7 @@ where
640640
}
641641
}
642642

643-
impl<'py, T, D> fmt::Debug for PyReadwriteArray<'py, T, D>
643+
impl<T, D> fmt::Debug for PyReadwriteArray<'_, T, D>
644644
where
645645
T: Element,
646646
D: Dimension,

src/borrow/shared.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ unsafe impl Sync for SharedPtr {}
103103

104104
static SHARED: SharedPtr = SharedPtr(GILOnceCell::new());
105105

106-
fn get_or_insert_shared<'py>(py: Python<'py>) -> PyResult<&'py Shared> {
106+
fn get_or_insert_shared(py: Python<'_>) -> PyResult<&Shared> {
107107
let shared = SHARED.0.get_or_try_init(py, || insert_shared(py))?;
108108

109109
// SAFETY: We inserted the capsule if it was missing
@@ -116,7 +116,7 @@ fn get_or_insert_shared<'py>(py: Python<'py>) -> PyResult<&'py Shared> {
116116
// immediately initialize the cache used access it from this extension.
117117

118118
#[cold]
119-
fn insert_shared<'py>(py: Python<'py>) -> PyResult<*const Shared> {
119+
fn insert_shared(py: Python<'_>) -> PyResult<*const Shared> {
120120
let module = get_array_module(py)?;
121121

122122
let capsule = match module.getattr("_RUST_NUMPY_BORROW_CHECKING_API") {
@@ -167,7 +167,7 @@ fn insert_shared<'py>(py: Python<'py>) -> PyResult<*const Shared> {
167167

168168
// These entry points will be used to access the shared borrow checking API from this extension:
169169

170-
pub fn acquire<'py>(py: Python<'py>, array: *mut PyArrayObject) -> Result<(), BorrowError> {
170+
pub fn acquire(py: Python<'_>, array: *mut PyArrayObject) -> Result<(), BorrowError> {
171171
let shared = get_or_insert_shared(py).expect("Interal borrow checking API error");
172172

173173
let rc = unsafe { (shared.acquire)(shared.flags, array) };
@@ -179,7 +179,7 @@ pub fn acquire<'py>(py: Python<'py>, array: *mut PyArrayObject) -> Result<(), Bo
179179
}
180180
}
181181

182-
pub fn acquire_mut<'py>(py: Python<'py>, array: *mut PyArrayObject) -> Result<(), BorrowError> {
182+
pub fn acquire_mut(py: Python<'_>, array: *mut PyArrayObject) -> Result<(), BorrowError> {
183183
let shared = get_or_insert_shared(py).expect("Interal borrow checking API error");
184184

185185
let rc = unsafe { (shared.acquire_mut)(shared.flags, array) };
@@ -192,15 +192,15 @@ pub fn acquire_mut<'py>(py: Python<'py>, array: *mut PyArrayObject) -> Result<()
192192
}
193193
}
194194

195-
pub fn release<'py>(py: Python<'py>, array: *mut PyArrayObject) {
195+
pub fn release(py: Python<'_>, array: *mut PyArrayObject) {
196196
let shared = get_or_insert_shared(py).expect("Interal borrow checking API error");
197197

198198
unsafe {
199199
(shared.release)(shared.flags, array);
200200
}
201201
}
202202

203-
pub fn release_mut<'py>(py: Python<'py>, array: *mut PyArrayObject) {
203+
pub fn release_mut(py: Python<'_>, array: *mut PyArrayObject) {
204204
let shared = get_or_insert_shared(py).expect("Interal borrow checking API error");
205205

206206
unsafe {
@@ -360,7 +360,7 @@ impl BorrowFlags {
360360
}
361361
}
362362

363-
fn base_address<'py>(py: Python<'py>, mut array: *mut PyArrayObject) -> *mut c_void {
363+
fn base_address(py: Python<'_>, mut array: *mut PyArrayObject) -> *mut c_void {
364364
loop {
365365
let base = unsafe { (*array).base };
366366

@@ -374,7 +374,7 @@ fn base_address<'py>(py: Python<'py>, mut array: *mut PyArrayObject) -> *mut c_v
374374
}
375375
}
376376

377-
fn borrow_key<'py>(py: Python<'py>, array: *mut PyArrayObject) -> BorrowKey {
377+
fn borrow_key(py: Python<'_>, array: *mut PyArrayObject) -> BorrowKey {
378378
let range = data_range(py, array);
379379

380380
let data_ptr = unsafe { (*array).data };
@@ -387,7 +387,7 @@ fn borrow_key<'py>(py: Python<'py>, array: *mut PyArrayObject) -> BorrowKey {
387387
}
388388
}
389389

390-
fn data_range<'py>(py: Python<'py>, array: *mut PyArrayObject) -> (*mut c_char, *mut c_char) {
390+
fn data_range(py: Python<'_>, array: *mut PyArrayObject) -> (*mut c_char, *mut c_char) {
391391
let nd = unsafe { (*array).nd } as usize;
392392
let data = unsafe { (*array).data };
393393

src/convert.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ pub trait IntoPyArray: Sized {
4141
type Dim: Dimension;
4242

4343
/// Consumes `self` and moves its data into a NumPy array.
44-
fn into_pyarray<'py>(self, py: Python<'py>) -> Bound<'py, PyArray<Self::Item, Self::Dim>>;
44+
fn into_pyarray(self, py: Python<'_>) -> Bound<'_, PyArray<Self::Item, Self::Dim>>;
4545
}
4646

4747
impl<T: Element> IntoPyArray for Box<[T]> {
4848
type Item = T;
4949
type Dim = Ix1;
5050

51-
fn into_pyarray<'py>(self, py: Python<'py>) -> Bound<'py, PyArray<Self::Item, Self::Dim>> {
51+
fn into_pyarray(self, py: Python<'_>) -> Bound<'_, PyArray<Self::Item, Self::Dim>> {
5252
let container = PySliceContainer::from(self);
5353
let dims = Dim([container.len]);
5454
let strides = [mem::size_of::<T>() as npy_intp];
@@ -64,7 +64,7 @@ impl<T: Element> IntoPyArray for Vec<T> {
6464
type Item = T;
6565
type Dim = Ix1;
6666

67-
fn into_pyarray<'py>(mut self, py: Python<'py>) -> Bound<'py, PyArray<Self::Item, Self::Dim>> {
67+
fn into_pyarray(mut self, py: Python<'_>) -> Bound<'_, PyArray<Self::Item, Self::Dim>> {
6868
let dims = Dim([self.len()]);
6969
let strides = [mem::size_of::<T>() as npy_intp];
7070
let data_ptr = self.as_mut_ptr();
@@ -88,7 +88,7 @@ where
8888
type Item = A;
8989
type Dim = D;
9090

91-
fn into_pyarray<'py>(self, py: Python<'py>) -> Bound<'py, PyArray<Self::Item, Self::Dim>> {
91+
fn into_pyarray(self, py: Python<'_>) -> Bound<'_, PyArray<Self::Item, Self::Dim>> {
9292
PyArray::from_owned_array(py, self)
9393
}
9494
}

src/dtype.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ unsafe impl PyTypeInfo for PyArrayDescr {
5757
const MODULE: Option<&'static str> = Some("numpy");
5858

5959
#[inline]
60-
fn type_object_raw<'py>(py: Python<'py>) -> *mut ffi::PyTypeObject {
60+
fn type_object_raw(py: Python<'_>) -> *mut ffi::PyTypeObject {
6161
unsafe { PY_ARRAY_API.get_type_object(py, NpyTypes::PyArrayDescr_Type) }
6262
}
6363
}
6464

6565
/// Returns the type descriptor ("dtype") for a registered type.
6666
#[inline]
67-
pub fn dtype<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr> {
67+
pub fn dtype<T: Element>(py: Python<'_>) -> Bound<'_, PyArrayDescr> {
6868
T::get_dtype(py)
6969
}
7070

@@ -109,18 +109,18 @@ impl PyArrayDescr {
109109

110110
/// Returns the type descriptor for a registered type.
111111
#[inline]
112-
pub fn of<'py, T: Element>(py: Python<'py>) -> Bound<'py, Self> {
112+
pub fn of<T: Element>(py: Python<'_>) -> Bound<'_, Self> {
113113
T::get_dtype(py)
114114
}
115115

116-
fn from_npy_type<'py>(py: Python<'py>, npy_type: NPY_TYPES) -> Bound<'py, Self> {
116+
fn from_npy_type(py: Python<'_>, npy_type: NPY_TYPES) -> Bound<'_, Self> {
117117
unsafe {
118118
let descr = PY_ARRAY_API.PyArray_DescrFromType(py, npy_type as _);
119119
Bound::from_owned_ptr(py, descr.cast()).downcast_into_unchecked()
120120
}
121121
}
122122

123-
pub(crate) fn new_from_npy_type<'py>(py: Python<'py>, npy_type: NPY_TYPES) -> Bound<'py, Self> {
123+
pub(crate) fn new_from_npy_type(py: Python<'_>, npy_type: NPY_TYPES) -> Bound<'_, Self> {
124124
unsafe {
125125
let descr = PY_ARRAY_API.PyArray_DescrNewFromType(py, npy_type as _);
126126
Bound::from_owned_ptr(py, descr.cast()).downcast_into_unchecked()

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ macro_rules! impl_pyerr {
2222
impl Error for $err_type {}
2323

2424
impl PyErrArguments for $err_type {
25-
fn arguments<'py>(self, py: Python<'py>) -> PyObject {
25+
fn arguments(self, py: Python<'_>) -> PyObject {
2626
self.to_string()
2727
.into_pyobject(py)
2828
.unwrap()
@@ -91,7 +91,7 @@ struct TypeErrorArguments {
9191
}
9292

9393
impl PyErrArguments for TypeErrorArguments {
94-
fn arguments<'py>(self, py: Python<'py>) -> PyObject {
94+
fn arguments(self, py: Python<'_>) -> PyObject {
9595
let err = TypeError {
9696
from: self.from.into_bound(py),
9797
to: self.to.into_bound(py),

0 commit comments

Comments
 (0)