Skip to content

Commit 8bfbb27

Browse files
authored
fix lint warning with Rust 1.87 (#494)
* move lint config into `Cargo.toml` * fix lint warning on 1.87
1 parent 66c7935 commit 8bfbb27

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

Cargo.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "numpy"
33
version = "0.25.0"
44
authors = [
55
"The rust-numpy Project Developers",
6-
"PyO3 Project and Contributors <https://github.com/PyO3>"
6+
"PyO3 Project and Contributors <https://github.com/PyO3>",
77
]
88
description = "PyO3-based Rust bindings of the NumPy C-API"
99
documentation = "https://docs.rs/numpy"
@@ -26,11 +26,22 @@ pyo3 = { version = "0.25.0", default-features = false, features = ["macros"] }
2626
rustc-hash = "2.0"
2727

2828
[dev-dependencies]
29-
pyo3 = { version = "0.25", default-features = false, features = ["auto-initialize"] }
30-
nalgebra = { version = ">=0.30, <0.34", default-features = false, features = ["std"] }
29+
pyo3 = { version = "0.25", default-features = false, features = [
30+
"auto-initialize",
31+
] }
32+
nalgebra = { version = ">=0.30, <0.34", default-features = false, features = [
33+
"std",
34+
] }
3135

3236
[build-dependencies]
3337
pyo3-build-config = { version = "0.25", features = ["resolve-config"] }
3438

3539
[package.metadata.docs.rs]
3640
all-features = true
41+
42+
[lints.rust]
43+
# We usually want to make the GIL lifetime explicit.
44+
elided-lifetimes-in-paths = "deny"
45+
46+
[lints.clippy]
47+
needless-lifetimes = "allow"

src/untyped_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub trait PyUntypedArrayMethods<'py>: Sealed {
241241

242242
/// Returns `true` if the there are no elements in the array.
243243
fn is_empty(&self) -> bool {
244-
self.shape().iter().any(|dim| *dim == 0)
244+
self.shape().contains(&0)
245245
}
246246
}
247247

x.py

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,7 @@ def gen_examples(manifest):
2929
yield dir_ / manifest
3030

3131

32-
LINT_CONFIG = (
33-
"--deny",
34-
"warnings",
35-
# We usually want to make the GIL lifetime explicit.
36-
"--deny",
37-
"elided-lifetimes-in-paths",
38-
"--allow",
39-
"clippy::needless-lifetimes",
40-
)
32+
DENY_WARNINGS = ("--deny", "warnings")
4133

4234

4335
def default(args):
@@ -51,40 +43,24 @@ def default(args):
5143
"--tests",
5244
"--benches",
5345
"--",
54-
*LINT_CONFIG,
46+
*DENY_WARNINGS,
5547
)
5648
else:
57-
run("cargo", "clippy", "--all-features", "--tests", "--", *LINT_CONFIG)
49+
run("cargo", "clippy", "--all-features", "--tests", "--", *DENY_WARNINGS)
5850

5951
for manifest in gen_examples("Cargo.toml"):
60-
run("cargo", "clippy", "--manifest-path", manifest, "--", *LINT_CONFIG)
52+
run("cargo", "clippy", "--manifest-path", manifest, "--", *DENY_WARNINGS)
6153

6254
run("cargo", "test", "--all-features", "--lib", "--tests")
6355

6456

6557
def check(args):
6658
run("cargo", "fmt", "--", "--check")
67-
68-
run(
69-
"cargo",
70-
"clippy",
71-
"--all-features",
72-
"--tests",
73-
"--",
74-
*LINT_CONFIG,
75-
)
59+
run("cargo", "clippy", "--all-features", "--tests", "--", *DENY_WARNINGS)
7660

7761
for manifest in gen_examples("Cargo.toml"):
7862
run("cargo", "fmt", "--manifest-path", manifest, "--", "--check")
79-
80-
run(
81-
"cargo",
82-
"clippy",
83-
"--manifest-path",
84-
manifest,
85-
"--",
86-
*LINT_CONFIG,
87-
)
63+
run("cargo", "clippy", "--manifest-path", manifest, "--", *DENY_WARNINGS)
8864

8965

9066
def doc(args):

0 commit comments

Comments
 (0)