◐ Shell
clean mode source ↗

Add more pedantic clippy rules by ShaharNaveh · Pull Request #7830 · RustPython/RustPython

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: f2748a38-31a7-4500-918b-e7b3a0d07d65

📥 Commits

Reviewing files that changed from the base of the PR and between 0d5bf96 and d09a5ae.

📒 Files selected for processing (10)
  • Cargo.toml
  • crates/codegen/src/compile.rs
  • crates/codegen/src/ir.rs
  • crates/stdlib/src/faulthandler.rs
  • crates/vm/src/builtins/template.rs
  • crates/vm/src/builtins/type.rs
  • crates/vm/src/frame.rs
  • crates/vm/src/stdlib/_ctypes/base.rs
  • crates/vm/src/stdlib/_io.rs
  • crates/vm/src/stdlib/_typing.rs
✅ Files skipped from review due to trivial changes (8)
  • crates/vm/src/builtins/template.rs
  • crates/vm/src/stdlib/_typing.rs
  • crates/vm/src/stdlib/_ctypes/base.rs
  • crates/vm/src/frame.rs
  • crates/vm/src/stdlib/_io.rs
  • crates/stdlib/src/faulthandler.rs
  • crates/vm/src/builtins/type.rs
  • crates/codegen/src/ir.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • Cargo.toml
  • crates/codegen/src/compile.rs

📝 Walkthrough

Walkthrough

Enable new workspace Clippy lints in Cargo.toml, then replace explicit iterator method calls across the codebase with direct or borrowed for-loop iteration (for x in &collection / for x in collection).

Changes

Clippy Iterator Pattern Compliance

Layer / File(s) Summary
Lint Configuration
Cargo.toml
Workspace Clippy configuration now enables collapsible_else_if, comparison_chain, explicit_into_iter_loop, explicit_iter_loop, filter_map_next, flat_map_option, and inconsistent_struct_constructor at "warn".
Codegen compilation loops
crates/codegen/src/compile.rs
Local loops over elts and tstring_value changed to iterate directly (for ... in ...) instead of .iter().
IR passes & stack-depth fixups
crates/codegen/src/ir.rs
finalize_code and max_stackdepth loops switched to for block in &mut blocks / for block in &mut self.blocks.
Compiler-core loops
crates/compiler-core/src/bytecode.rs, crates/compiler-core/src/marshal.rs
Adaptive counters and code serialization loops now iterate by reference (&self.adaptive_counters, &code.varnames, &code.freevars).
Stdlib: faulthandler & ssl
crates/stdlib/src/faulthandler.rs, crates/stdlib/src/ssl/cert.rs
FAULTHANDLER_HANDLERS and CRL/CA certificate loops updated to borrowed iteration forms.
Stdlib: marshal, atexit, gc, nt, I/O
crates/vm/src/stdlib/*, crates/stdlib/src/faulthandler.rs
PyDict, Vec/env, atexit callbacks, gc stats, and I/O __setstate__ loops changed from consuming iterators to non-consuming or borrowed iteration.
VM builtins & core runtime
crates/vm/src/builtins/*, crates/vm/src/frame.rs, crates/vm/src/gc_state.rs, crates/vm/src/object/core.rs
Namespace initializer, Template.__new__, MRO traversal, SLOT_DEFS loop, exception-group tuple handling, cellvar syncing, GC finalization, slot clearing, and typing tuple formatting use borrowed/direct iteration.
ctypes: fields, init, structure/union
crates/vm/src/stdlib/_ctypes*.rs
Field traversal, anonymous-field promotion, structure/union size calc, and initializer kwargs/args traversal switched to for ... in &... patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • youknowone
  • coolreader18

Poem

🐇 I hopped through loops with steady paw,

Replaced .iter() with borrows, hurrah!
No ownership tug, no move to dread,
Clippy nods while I munch my bread.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: enabling additional Clippy lint rules in Cargo.toml, with all subsequent code changes being automated refactorings to comply with these new rules.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.