Skip to content

fix: Enable clippy::arithmetic_side_effects lint#1119

Merged
szokeasaurusrex merged 1 commit into
masterfrom
szokeasaurusrex/checked-arithmetic
May 7, 2026
Merged

fix: Enable clippy::arithmetic_side_effects lint#1119
szokeasaurusrex merged 1 commit into
masterfrom
szokeasaurusrex/checked-arithmetic

Conversation

@szokeasaurusrex
Copy link
Copy Markdown
Member

This lint warns against using normal math operations, like +, -, etc. In Rust, these operators panic on overflow in debug builds and overflow in release builds. Enabling this lint forces us to handle potential overflow explicitly.

This change enables the lint and fixes the easy violations. Three follow up PRs will address the more complex cases.

Ref #1113
Ref RUST-211

[This lint](https://rust-lang.github.io/rust-clippy/master/index.html?search=clippy%3A%3Aarithmetic_side_effects#arithmetic_side_effects) warns against using normal math operations, like `+`, `-`, etc. In Rust, these operators panic on overflow in debug builds and overflow in release builds. Enabling this lint forces us to handle potential overflow explicitly.

This change enables the lint and fixes the easy violations. Three follow up PRs will address the more complex cases.

Ref #1113
Ref [RUST-211](https://linear.app/getsentry/issue/RUST-211/enforce-checked-arithmetic-in-the-sdk)
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 6, 2026

@szokeasaurusrex szokeasaurusrex merged commit d65272b into master May 7, 2026
27 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/checked-arithmetic branch May 7, 2026 11:49
szokeasaurusrex added a commit that referenced this pull request May 7, 2026
szokeasaurusrex added a commit that referenced this pull request May 11, 2026
Replace unchecked envelope parser offset arithmetic with checked
operations and document the invariants that make each addition safe.
This removes the file-level lint exception while keeping malformed
envelope handling explicit.

Stacked on #1119

Closes #1118
Closes
[RUST-214](https://linear.app/getsentry/issue/RUST-214/fix-checked-arithmetic-in-sentry-typessrcprotocolenvelopers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants