Skip to content

Conversation

@stuuupidcat
Copy link
Collaborator

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replicates the Clippy lint ptr_offset_with_cast to detect usage of the offset pointer method with a usize value casted to an isize. The lint suggests using the add method instead to avoid the numeric cast when always increasing the pointer address.

Key changes:

  • Added new pattern detection for ptr_offset_with_cast in both offset and wrapping_offset variants
  • Registered the new pattern in the default patterns list
  • Updated existing test expectations to include the new lint warnings

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/patterns-pest/clippy/ptr-offset-with-cast.rpl New pattern file defining the MIR patterns for detecting usize-to-isize casts in pointer offset operations and corresponding diagnostic messages
crates/rpl_meta/src/cli.rs Registers the new ptr-offset-with-cast pattern in alphabetical order in the default patterns list
tests/ui/clippy/ptr_offset_with_cast.rs New test file verifying the lint detects offset/wrapping_offset with usize casts and correctly ignores non-usize casts and non-pointer types
tests/ui/clippy/ptr_offset_with_cast.stderr Expected error output for the new test, showing 8 errors (4 ptr_offset_with_cast, 4 unchecked_pointer_offset)
tests/ui/cve/cve_2021_25905/minimal.rs Updated test annotations to expect ptr_offset_with_cast errors for inline revision; removed check-pass directive
tests/ui/cve/cve_2021_25905/minimal.inline.stderr New expected output file showing 4 ptr_offset_with_cast errors for the inline revision
tests/ui/cve/cve_2021_25905/minimal.regular.stderr Updated line numbers to reflect changes in the source file
tests/ui/cve/cve_2020_35892_3/cve_2020_35892_3.rs Added test annotations for ptr_offset_with_cast at 4 offset call sites
tests/ui/cve/cve_2020_35892_3/cve_2020_35892_3.stderr Updated expected output to include 4 new ptr_offset_with_cast errors and adjusted line numbers
tests/ui/clippy/size_of_in_element_count/functions.rs Added test annotation for ptr_offset_with_cast on the offset call
tests/ui/clippy/size_of_in_element_count/functions.stderr Updated expected output to include new ptr_offset_with_cast error and adjusted line numbers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stuuupidcat stuuupidcat merged commit 5291228 into master Jan 7, 2026
8 checks passed
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