◐ Shell
reader mode source ↗
Skip to content

More clippy rules#8127

Open
ShaharNaveh wants to merge 10 commits into
RustPython:mainfrom
ShaharNaveh:clippy-rules-4
Open

More clippy rules#8127
ShaharNaveh wants to merge 10 commits into
RustPython:mainfrom
ShaharNaveh:clippy-rules-4

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Summary by CodeRabbit

  • Chores
    • Updated build configuration linting rules.
    • Refactored internal code for improved performance and maintainability across compiler, runtime, and stdlib modules.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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: 107576e9-fb6f-4bad-b64d-891e10c6f37d

📥 Commits

Reviewing files that changed from the base of the PR and between 93fbe4f and 8c44746.

📒 Files selected for processing (20)
  • Cargo.toml
  • crates/codegen/src/compile.rs
  • crates/codegen/src/ir.rs
  • crates/common/src/format.rs
  • crates/host_env/src/crt_fd.rs
  • crates/host_env/src/fileutils.rs
  • crates/host_env/src/signal.rs
  • crates/stdlib/src/_asyncio.rs
  • crates/stdlib/src/binascii.rs
  • crates/vm/src/builtins/float.rs
  • crates/vm/src/builtins/type.rs
  • crates/vm/src/protocol/callable.rs
  • crates/vm/src/protocol/number.rs
  • crates/vm/src/protocol/sequence.rs
  • crates/vm/src/stdlib/_ast.rs
  • crates/vm/src/stdlib/_io.rs
  • crates/vm/src/stdlib/_signal.rs
  • crates/vm/src/types/slot.rs
  • crates/vm/src/vm/thread.rs
  • crates/vm/src/vm/vm_new.rs

📝 Walkthrough

Walkthrough

Eight new Clippy lints are enabled in the workspace Cargo.toml, and code across codegen, common, host_env, stdlib, and vm crates is updated to comply. Most changes convert &self/&T receivers and parameters to by-value for Copy types, elide redundant lifetime annotations, and consolidate generic bounds.

Changes

Clippy Lint Enablement and Compliance

Layer / File(s) Summary
Workspace Clippy lint configuration and float.rs suppression
Cargo.toml, crates/vm/src/builtins/float.rs
Adds eight new warn-level Clippy lints to the workspace; adds a targeted #[expect(clippy::trivially_copy_pass_by_ref)] in PyFloat where the signature is API-constrained.
codegen compile.rs: operators and CompileOpts by value
crates/codegen/src/compile.rs
Changes compile_addcompare, compile_augassign, compile_op, compile_bool_op, and emit_short_circuit_test to accept AST operator enums by value; updates all call sites. Changes split_doc_with_range and split_doc to accept CompileOpts by value with updated module/class call sites.
codegen ir.rs: AnyInstruction by value
crates/codegen/src/ir.rs
Changes is_swappable and is_conditional_jump_opcode to accept AnyInstruction by value; updates next_swappable_instruction and normalize_jumps_in_block accordingly.
FormatGrouping by-value conversion and host_env parameters
crates/common/src/format.rs, crates/host_env/src/crt_fd.rs, crates/host_env/src/fileutils.rs, crates/host_env/src/signal.rs
Adds From<FormatGrouping> for char and delegates the reference impl to it; updates validate_separator to accept FormatGrouping by value. Changes file_time_to_time_t_nsec to accept FILETIME by value. Changes sigset_contains to accept libc::sigset_t by value. Elides explicit lifetime parameters in Borrowed impls and changes OwnedInner::as_raw_fd to take self.
VM protocol, builtins, and slot by-value receivers
crates/vm/src/protocol/callable.rs, crates/vm/src/protocol/number.rs, crates/vm/src/protocol/sequence.rs, crates/vm/src/builtins/type.rs, crates/vm/src/types/slot.rs
Changes TraceEvent predicate methods to const fn (self); moves PyNumber::check to impl PyNumber<'_>; changes _ass_slice receiver to self; changes PointerSlot::borrow_static to self; changes SlotAccessor in update_one_slot to by-value; simplifies heap_default to Self::default().
stdlib and VM infrastructure by-value fixes
crates/stdlib/src/_asyncio.rs, crates/stdlib/src/binascii.rs, crates/vm/src/stdlib/_ast.rs, crates/vm/src/stdlib/_io.rs, crates/vm/src/stdlib/_signal.rs, crates/vm/src/vm/thread.rs, crates/vm/src/vm/vm_new.rs
Changes FutureState::as_str to const fn (self); changes uu_a2b_read to accept u8 by value; changes fold_number_binop to accept ast::Operator by value; changes Newlines::find_newline to take self; changes sigset_to_pyset to accept libc::sigset_t by value; changes handle_expected_token to accept TokenKind by value; consolidates start_thread generic bounds.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • RustPython/RustPython#7755: Updates the same [workspace.lints.clippy] section in Cargo.toml with lint additions and reorganization.
  • RustPython/RustPython#8122: Also modifies workspace Clippy lint configuration in Cargo.toml by adding/enabling additional lints in the same section.
  • RustPython/RustPython#8123: Directly touches the same lint keys (doc_link_with_quotes, single_char_pattern) that are reorganized in this PR.

Suggested reviewers

  • youknowone
  • bschoenmaeckers

🐇 A rabbit who loves tidy code,
Swapped refs for values down the road,
Copy types now travel light,
No borrowed &self in sight,
Clippy smiled — the lints are owed! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'More clippy rules' is vague and generic. It references implementing clippy rules but does not convey the specific nature or scope of the changes made throughout the codebase. Consider a more descriptive title that highlights the primary refactoring focus, such as 'Refactor pass-by-value patterns and apply clippy linting rules' or 'Optimize parameter passing and address clippy lint warnings'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant