GeezerVison is showing github.com — more clippy rules by ShaharNaveh · Pull Request #8050 · RustPython/RustPython
Conversation
ShaharNaveh
commented
Jun 5, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Summary by CodeRabbit
-
Refactor
- Modernized internal code patterns and pointer arithmetic operations for improved efficiency.
- Simplified control flow in several utility methods.
-
Chores
- Extended Rust compiler lint configuration for enhanced code quality standards.
- Added compiler warnings to builder methods and utility functions to catch unused return values.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jun 5, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
PR changed again? Review this PR in Change Stack to compare snapshots and stay oriented.

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: 5e8c61b5-4d14-4150-a18e-457ba02954cd
📥 Commits
Reviewing files that changed from the base of the PR and between 51c97b9 and 0407f73.
📒 Files selected for processing (17)
Cargo.toml
crates/capi/src/traceback.rs
crates/common/src/boxvec.rs
crates/common/src/cformat.rs
crates/derive-impl/src/pyclass.rs
crates/jit/src/instructions.rs
crates/sre_engine/src/string.rs
crates/stdlib/src/_asyncio.rs
crates/vm/src/builtins/dict.rs
crates/vm/src/builtins/getset.rs
crates/vm/src/builtins/memory.rs
crates/vm/src/builtins/str.rs
crates/vm/src/bytes_inner.rs
crates/vm/src/frame.rs
crates/vm/src/stdlib/sys.rs
crates/vm/src/types/slot_defs.rs
crates/vm/src/vm/interpreter.rs
📝 Walkthrough
Walkthrough
This PR updates RustPython's code quality and build configuration by extending clippy lint rules, modernizing unsafe pointer arithmetic to use add/sub instead of offset, consolidating single-element iterator patterns, adding #[must_use] annotations to builder and constructor methods, and refactoring several control flow patterns for clarity.
Changes
Code Quality, Lint Configuration, and Pattern Modernization
| Layer / File(s) |
Summary |
Workspace clippy lint configuration Cargo.toml |
Workspace lint section expanded with new nursery lints (iter_on_empty_collections, iter_on_single_items, literal_string_with_formatting_args, needless_collect) and extended pedantic lints (checked_conversions, cloned_instead_of_copied, collapsible_else_if, comparison_chain, duration_suboptimal_units, and others). |
Unsafe pointer arithmetic modernization crates/common/src/boxvec.rs, crates/sre_engine/src/string.rs |
Replaced ptr::offset(±1) calls with explicit ptr::add(1) and ptr::sub(1) in BoxVec::try_insert, StringCursor::back_peek, and UTF-8 decoding routines (next_code_point, next_code_point_reverse) for clearer intent and alignment with modern Rust idioms. |
Iterator pattern and collection refactoring crates/capi/src/traceback.rs, crates/stdlib/src/_asyncio.rs, crates/vm/src/stdlib/sys.rs, crates/derive-impl/src/pyclass.rs, crates/vm/src/bytes_inner.rs, crates/vm/src/types/slot_defs.rs |
Consolidated single-element keyword argument construction to use core::iter::once() instead of array iterators; refactored capitalize to use explicit for loop; replaced collection+length pattern with direct count() in test assertions; updated pyslot attribute parsing to use if let pattern. |
Builder and return-value #[must_use] annotations crates/vm/src/builtins/getset.rs, crates/vm/src/builtins/memory.rs, crates/vm/src/vm/interpreter.rs, crates/vm/src/builtins/dict.rs, crates/common/src/cformat.rs |
Added #[must_use] to builder methods (PyGetSet::new, with_get, with_set; InterpreterBuilder::init_hook, add_frozen_modules), public constructors (PyMemoryView::new_view), and value-returning methods (FormatBuf::concat, dict.setdefault). |
Targeted control flow refactorings crates/vm/src/builtins/dict.rs, crates/vm/src/builtins/str.rs, crates/vm/src/frame.rs, crates/jit/src/instructions.rs |
Refactored dict.get to use unwrap_or_else for default fallback; updated char/CodePoint conversion to use u8::try_from().map_or_else() pattern; strengthened ForIterGen specialization guard with i16::try_from() bounds check; added clippy mut_mut expectation attributes to store_variable and get_or_create_block methods. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- RustPython/RustPython#7875: Both PRs modify
Cargo.toml's [workspace.lints.clippy] configuration by reorganizing/adding clippy "nursery" and "pedantic" warn lints.
- RustPython/RustPython#7764: Both PRs extend the same
Cargo.toml workspace Clippy lint configuration with expanded pedantic/warn lint rules, including cloned_instead_of_copied.
- RustPython/RustPython#7830: Both PRs modify
Cargo.toml's pedantic lint configuration, adding clippy rules like collapsible_else_if and comparison_chain.
Suggested reviewers
- youknowone
- fanninpm
- coolreader18
Poem
🐰 A rabbit hops through clippy's garden bright,
With safer pointers, add and sub take flight,
Builder patterns marked "don't ignore my way!"
Once() for single items—cleaner code today,
Modern Rust idioms, refactored with care. 🌟
🚥 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, using non-descriptive phrasing that doesn't convey meaningful information about the specific changes in the changeset. |
Consider a more descriptive title that specifies the main clippy rules being added or the primary refactoring effort (e.g., 'Add clippy pedantic and nursery lints to workspace' or 'Apply clippy suggestions across codebase'). |
✅ 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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jun 14, 2026
youknowone
pushed a commit
that referenced
this pull request
Sep 16, 2026
* `checked_conversions`
* duration_suboptimal_units
* inefficient_to_string
* iter_on_single_items
* needless_collect
* needless_for_each
* ptr_offset_by_literal
* return_self_not_must_use
Reviewers
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|