◐ Shell
clean mode source ↗

Enable some pedantic clippy lints by ShaharNaveh · Pull Request #7764 · RustPython/RustPython

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds many #[must_use] annotations across crates, updates workspace Clippy lint entries in Cargo.toml, replaces a few .cloned() with .copied(), and performs small behavior-preserving control-flow simplifications and explicit discards of returned values.

Changes

Workspace lint and global config

Layer / File(s) Summary
Lint Configuration
Cargo.toml
Updated [workspace.lints.clippy]: set correctness, suspicious, perf, style, complexity to warn with priority = -2; added pendantic lints cloned_instead_of_copied = "warn" and must_use_candidate = "warn".

Must-use annotations, iterator refinements, and small refactors

Layer / File(s) Summary
API annotation additions
crates/... (many files, e.g., crates/vm/..., crates/common/..., crates/compiler-core/..., crates/host_env/..., crates/codegen/..., crates/derive-impl/..., crates/sre_engine/..., crates/stdlib/...)
Hundreds of public functions/constructors/accessors were annotated with #[must_use] to enforce unused-result warnings (see per-file summaries).
Constness / signature adjustments
crates/common/src/boxvec.rs, crates/vm/src/builtins/module.rs, crates/vm/src/types/slot.rs
A few methods gained or clarified pub const fn and attribute changes alongside #[must_use] (e.g., BoxVec len/is_empty/capacity/is_full; PyModule::new/from_def const; PyTypeFlags::has_feature made unconditional).
Iterator element-copy refinements
crates/common/src/cformat.rs, crates/stdlib/src/faulthandler.rs, crates/vm/src/stdlib/_sre.rs, crates/vm/src/protocol/buffer.rs
Replaced .cloned() with .copied() for Copy element iteration (u8 and similar).
Control-flow simplifications (behavior-preserving)
crates/codegen/src/compile.rs, crates/derive-impl/src/*, crates/common/src/lock/thread_mutex.rs, crates/sre_engine/src/engine.rs, crates/stdlib/src/ssl/*, crates/stdlib/src/compression.rs
Removed/flattened small else blocks and restructured some error/return branches while preserving behavior (notable: TLS empty-input handling now distinguishes clean close vs EOF).
Explicit discard of returned values
crates/vm/src/stdlib/_ctypes.rs, crates/stdlib/src/select.rs, crates/vm/src/stdlib/builtins.rs
Replaced bare expression calls with let _ = ... where the returned value should be intentionally ignored.
Docs / examples
crates/vm/src/macros.rs
Minor doc-example import reformatting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • youknowone
  • coolreader18
  • fanninpm

Poem

🐇 I hopped through crates with tidy care,

"Use my return!" I squeaked in the air.
Lints set gently, clones swapped to copy,
Else branches trimmed — the changes are snappy.
Hop, compile, and nibble a carrot, merry and wary.

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