From 30777ca7c15c731f02a284fbfddfd19b08ba0a48 Mon Sep 17 00:00:00 2001 From: Aliaksei Semianiuk Date: Thu, 25 Dec 2025 14:26:16 +0500 Subject: [PATCH] Introduce clippy --- Modules/cpython-sys/build.rs | 9 ++++----- Modules/cpython-sys/src/lib.rs | 1 + rust-toolchain.toml | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Modules/cpython-sys/build.rs b/Modules/cpython-sys/build.rs index 8256e2fc93cd03..c4eb39a741be0c 100644 --- a/Modules/cpython-sys/build.rs +++ b/Modules/cpython-sys/build.rs @@ -9,10 +9,10 @@ fn main() { .expect("expected Modules/cpython-sys to live under the source tree"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let builddir = env::var("PYTHON_BUILD_DIR").ok(); - if gil_disabled(&srcdir, builddir.as_deref()) { + if gil_disabled(srcdir, builddir.as_deref()) { println!("cargo:rustc-cfg=py_gil_disabled"); } - generate_c_api_bindings(srcdir, builddir.as_deref(), &out_path.as_path()); + generate_c_api_bindings(srcdir, builddir.as_deref(), out_path.as_path()); // TODO(emmatyping): generate bindings to the internal parser API // The parser includes things slightly differently, so we should generate // it's bindings independently @@ -27,11 +27,10 @@ fn gil_disabled(srcdir: &Path, builddir: Option<&str>) -> bool { candidates.push(srcdir.to_path_buf()); for base in candidates { let path = base.join("pyconfig.h"); - if let Ok(contents) = std::fs::read_to_string(&path) { - if contents.contains("Py_GIL_DISABLED 1") { + if let Ok(contents) = std::fs::read_to_string(&path) + && contents.contains("Py_GIL_DISABLED 1") { return true; } - } } false } diff --git a/Modules/cpython-sys/src/lib.rs b/Modules/cpython-sys/src/lib.rs index 27765abd4b7fe2..5180762fbef6bf 100644 --- a/Modules/cpython-sys/src/lib.rs +++ b/Modules/cpython-sys/src/lib.rs @@ -3,6 +3,7 @@ #![allow(non_snake_case)] #![allow(unsafe_op_in_unsafe_fn)] #![allow(unnecessary_transmutes)] +#![allow(clippy::approx_constant)] use std::ffi::{c_char, c_int, c_void}; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index da064b583d29e7..a831814c96809c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,3 @@ [toolchain] -channel = "1.91.1" \ No newline at end of file +channel = "1.91.1" +components = ["clippy"] \ No newline at end of file