Skip to content

Extend zst_offset lint to detect NonNull<T> offset calculations#16888

Open
Gri-ffin wants to merge 1 commit intorust-lang:masterfrom
Gri-ffin:fix-16887
Open

Extend zst_offset lint to detect NonNull<T> offset calculations#16888
Gri-ffin wants to merge 1 commit intorust-lang:masterfrom
Gri-ffin:fix-16887

Conversation

@Gri-ffin
Copy link
Copy Markdown

@Gri-ffin Gri-ffin commented Apr 19, 2026

Fixes #16887

The zst_offset lint previously only checked raw pointers (*mut T / *const T) for offset calculations on zero-sized types. NonNull<T> also provides add, sub, and offset methods that are equally no-ops on ZSTs, but were not flagged.

The PR extends the lint to also check NonNull<T> receivers.

changelog: [zst_offset]: detect zero-sized NonNull<T> offset calculations.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 19, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

r? @dswij

rustbot has assigned @dswij.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zst_offset not warning for NonNull

3 participants