GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — more clippy rules by ShaharNaveh · Pull Request #8050 · RustPython/RustPython

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jun 5, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Closes #xxxx
  • This PR follows our AI policy

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.

All reactions
ShaharNaveh added 9 commits June 5, 2026 11:26
@ShaharNaveh
checked_conversions
01d5c11
@ShaharNaveh
duration_suboptimal_units
579745f
@ShaharNaveh
inefficient_to_string
0ff06f5
@ShaharNaveh
iter_on_single_items
8eca638
@ShaharNaveh
needless_collect
410d35a
@ShaharNaveh
needless_for_each
0f2f180
@ShaharNaveh
ptr_offset_by_literal
908d1dc
@ShaharNaveh
return_self_not_must_use
3b462da
@ShaharNaveh
Simplify
465f4a3
@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

PR changed again? Review this PR in Change Stack to compare snapshots and stay oriented.

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: 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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ShaharNaveh added 2 commits June 5, 2026 13:48
@ShaharNaveh
simplify
946a86d
@ShaharNaveh
fix jit
0407f73
@ShaharNaveh
ShaharNaveh force-pushed the clippy-pedantic-rules-3 branch from 232d5df to 0407f73 Compare June 6, 2026 06:28
@ShaharNaveh
ShaharNaveh marked this pull request as ready for review June 6, 2026 08:42
bschoenmaeckers
bschoenmaeckers approved these changes Jun 6, 2026
View reviewed changes
@ShaharNaveh
Merge remote-tracking branch 'upstream/main' into clippy-pedantic-rul…
c882cff
…es-3
youknowone
youknowone approved these changes Jun 10, 2026
View reviewed changes
@youknowone
youknowone merged commit 28addda into RustPython:main Jun 10, 2026
49 of 50 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jun 14, 2026
Reduce number of string clones when compiling python source code #8103
Merged
clippy significant_drop_in_scrutinee & explicit_deref_methods #8104
Merged
clippy enum_glob_use #8121
Merged
More clippy rules #8123
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Jun 27, 2026
Add more clippy rules #8183
Merged
2 tasks
youknowone pushed a commit that referenced this pull request Sep 16, 2026
@ShaharNaveh
more clippy rules (#8050)
dc81e05
* `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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@youknowone youknowone youknowone approved these changes
+1 more reviewer
@bschoenmaeckers bschoenmaeckers bschoenmaeckers approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@ShaharNaveh @youknowone @bschoenmaeckers
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.