From ab3d759e7478af6915760edc847a9a1bf955acf4 Mon Sep 17 00:00:00 2001 From: Joshua Megnauth <48846352+joshuamegnauth54@users.noreply.github.com> Date: Thu, 1 Oct 2026 00:59:00 +0000 Subject: [PATCH] CI: Run clippy on more features (#8916) Clippy doesn't run on everything which is why I keep accidentally uncovering new lints to fix. I updated CI to run clippy on all features, except tk, as well as all binaries, examples, and tests. That should cover everything. Tk currently doesn't build (at least for me), so that feature is still disabled in CI. While here, fix some of the lints that are now raised. --- .github/workflows/ci.yaml | 3 ++- crates/vm/src/builtins/function/jit.rs | 12 ++++++------ crates/vm/src/types/slot.rs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8bdf57137..cd0b1349c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,6 +21,7 @@ concurrency: env: CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,doc CARGO_ARGS_NO_SSL: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,host_env,doc + CARGO_ARGS_MOST_FEATS: --features capi,encodings,jit,sqlite,threading # Crates excluded from workspace builds: # - rustpython_wasm: requires wasm target # - rustpython-venvlauncher: Windows-only @@ -685,7 +686,7 @@ jobs: continue-on-error: true - name: Clippy - run: cargo clippy --locked --keep-going ${{ env.CARGO_ARGS }} --workspace --all-targets ${{ env.WORKSPACE_EXCLUDES }} -- -Dwarnings + run: cargo clippy --locked --keep-going ${{ env.CARGO_ARGS_MOST_FEATS }} --workspace --all-targets --bins --examples --tests ${{ env.WORKSPACE_EXCLUDES }} -- -Dwarnings # macOS/Windows clippy uses the same OS-surface filter as cargo check. # Force with the run:cross-check label. Check names stay clippy (). diff --git a/crates/vm/src/builtins/function/jit.rs b/crates/vm/src/builtins/function/jit.rs index 90efb1031..dc49a4fba 100644 --- a/crates/vm/src/builtins/function/jit.rs +++ b/crates/vm/src/builtins/function/jit.rs @@ -31,9 +31,9 @@ pub(super) enum ArgsError { impl ToPyObject for AbiValue { fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef { match self { - AbiValue::Int(i) => i.to_pyobject(vm), - AbiValue::Float(f) => f.to_pyobject(vm), - AbiValue::Bool(b) => b.to_pyobject(vm), + Self::Int(i) => i.to_pyobject(vm), + Self::Float(f) => f.to_pyobject(vm), + Self::Bool(b) => b.to_pyobject(vm), _ => unimplemented!(), } } @@ -164,20 +164,20 @@ pub(crate) fn get_jit_args<'a>( vm: &VirtualMachine, ) -> Result, ArgsError> { let mut jit_args = jitted_code.args_builder(); - let nargs = func_args.args.len(); let code: &Py = &func.code; let arg_names = code.arg_names(); let arg_count = code.arg_count; let posonlyarg_count = code.posonlyarg_count; + let nargs = func_args.args.len(); if nargs > arg_count as usize || nargs < posonlyarg_count as usize { return Err(ArgsError::WrongNumberOfArgs); } // Add positional arguments - for i in 0..nargs { - jit_args.set(i, get_jit_value(vm, &func_args.args[i])?)?; + for (i, args) in func_args.args.iter().enumerate() { + jit_args.set(i, get_jit_value(vm, args)?)?; } // Handle keyword arguments diff --git a/crates/vm/src/types/slot.rs b/crates/vm/src/types/slot.rs index 65011572b..af5b20219 100644 --- a/crates/vm/src/types/slot.rs +++ b/crates/vm/src/types/slot.rs @@ -365,7 +365,7 @@ impl PyAtomicTypeFlags { pub fn replace_masked(&self, mask: PyTypeFlags, value: PyTypeFlags) { let mask_bits = mask.bits(); let value_bits = (value & mask).bits(); - let _ = self.0.fetch_update( + let _ = self.0.try_update( core::sync::atomic::Ordering::AcqRel, core::sync::atomic::Ordering::Acquire, |old| Some((old & !mask_bits) | value_bits),