Skip to content

fix arithmetic side effects false positive#17011

Merged
Jarcho merged 1 commit into
rust-lang:masterfrom
pocopepe:fix-17005
May 15, 2026
Merged

fix arithmetic side effects false positive#17011
Jarcho merged 1 commit into
rust-lang:masterfrom
pocopepe:fix-17005

Conversation

@pocopepe
Copy link
Copy Markdown
Contributor

@pocopepe pocopepe commented May 14, 2026

fixes #17005

changelog: [arithmetic_side_effects]: don't lint when one operand is an as cast from a smaller integer type

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

rustbot commented May 14, 2026

r? @Jarcho

rustbot has assigned @Jarcho.
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, llogiq, samueltardieu

@github-actions
Copy link
Copy Markdown

Lintcheck changes for a5244cc

Lint Added Removed Changed
clippy::arithmetic_side_effects 0 39 3

This comment will be updated if you push new changes

Copy link
Copy Markdown
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

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

@Jarcho Jarcho added this pull request to the merge queue May 15, 2026
Merged via the queue into rust-lang:master with commit 8be2258 May 15, 2026
11 of 13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 15, 2026
@simonsso
Copy link
Copy Markdown

@pocopepe does it handle the corner case when adding 0xffff_0001 + id_u16() which still could wrap ?

@pocopepe
Copy link
Copy Markdown
Contributor Author

yes it does, considering the check computes const + u16::MAX and only suppresses if the result fits in u32, so 0xffff_0001 + 65535 still warns as expected :)

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.

clippy::arithmetic-side-effects false positive when extending an u16

4 participants