Skip to content

More clippy rules#8127

Merged
youknowone merged 11 commits into
RustPython:mainfrom
ShaharNaveh:clippy-rules-4
Jun 22, 2026
Merged

More clippy rules#8127
youknowone merged 11 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 workspace lint configuration to add and reorganize several Clippy checks for better static analysis coverage.
    • Refactored internal implementation details across compiler, VM, and stdlib (e.g., receiver/argument passing by value, minor constant/function signature adjustments, and small formatting cleanups), with no intended user-facing behavior changes.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: d73aa1f9-020c-4d67-a454-348b5fdbe69f

📥 Commits

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

📒 Files selected for processing (1)
  • crates/stdlib/src/ssl.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 lint configuration and targeted suppression
Cargo.toml, crates/vm/src/builtins/float.rs
Adds eight new warn-level Clippy lints to the workspace (collection_is_never_read, type_repetition_in_bounds, unnecessary_struct_initialization, copy_iterator, elidable_lifetime_names, large_types_passed_by_value, same_functions_in_if_condition, trivially_copy_pass_by_ref); 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 to dereference. Changes split_doc_with_range and split_doc to accept CompileOpts by value with updated module and class compilation paths.
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.
Common format and host_env: by-value type conversions
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 refactors reference impl to delegate; updates validate_separator to accept FormatGrouping by value. Updates file_time_to_time_t_nsec to accept FILETIME by value. Updates sigset_contains to accept libc::sigset_t by value. Elides explicit lifetime parameters in Borrowed trait and inherent impls; changes OwnedInner::as_raw_fd receiver to self.
VM protocol and type system: Copy receivers and impl refactoring
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
Updates TraceEvent predicate methods to const fn (self). Moves PyNumber::check to impl PyNumber<'_> (lifetime elision). Changes _ass_slice receiver to self. Changes PointerSlot::borrow_static receiver to self. Refactors update_one_slot to accept SlotAccessor by value with updated call sites. Simplifies heap_default to Self::default().
Standard library and VM infrastructure
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, crates/stdlib/src/ssl.rs
Updates FutureState::as_str to const fn (self). Refactors uu_a2b_read to accept u8 by value. Changes fold_number_binop to accept ast::Operator by value. Updates Newlines::find_newline receiver to self. Updates sigset_to_pyset to accept libc::sigset_t by value. Changes handle_expected_token to accept TokenKind by value. Consolidates start_thread generic bounds. Updates generate_session_id_from_metadata to accept SystemTime by value with related TLS call sites.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • RustPython/RustPython#7764: Updates the same [workspace.lints.clippy] section in Cargo.toml with overlapping lint additions and reorganization.
  • RustPython/RustPython#8123: Directly modifies workspace Clippy lint configuration in Cargo.toml with lint keys that are reorganized in this PR.
  • RustPython/RustPython#8058: Modifies crates/vm/src/protocol/callable.rs to update TraceEvent predicate helpers in the same by-value receiver pattern.

Suggested reviewers

  • youknowone

🐇 A rabbit hops through tidy code,
Where Copy types now travel light, unbowed,
No &self in sight, no borrowed load,
By-value parameters, the path well-trod,
Eight lints enabled—compliance 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, failing to specify which clippy rules are being addressed or what the main code changes accomplish. Consider a more descriptive title that identifies the specific clippy rules or the primary refactoring goal, such as 'Apply pass-by-value refactoring for Copy types to address clippy lints' or 'Enforce clippy rules for copy types and improve code style'.
✅ 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

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.

@youknowone youknowone merged commit a826600 into RustPython:main Jun 22, 2026
26 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 28, 2026
2 tasks
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.

2 participants