Skip to content

Enable five more clippy lints - #10935

Merged
Jefffrey merged 5 commits into
apache:mainfrom
emilk:emilk/high-value-clippy-lints
Sep 1, 2026
Merged

Enable five more clippy lints#10935
Jefffrey merged 5 commits into
apache:mainfrom
emilk:emilk/high-value-clippy-lints

Conversation

@emilk

@emilk emilk commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

No issue in particular

Rationale for this change

#10742 left the pedantic lints we violate as allow, with a violation count each. These five are the ones worth paying for: two guard raw pointers, one guards bindings that claim to be unused, and two improve readability and test output.

What changes are included in this PR?

One commit per new lint (easiest to review commit by commit!):

Let me know if you disagree with any of them.

Are these changes tested?

Covered by existing tests plus the clippy CI job.

Are there any user-facing changes?

No.

emilk and others added 5 commits September 1, 2026 14:17
An `else` after a block that always diverges only adds a level of
indentation. Removing it keeps the happy path at the outer level.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`assert_eq!`/`assert_ne!` print both operands on failure, while
`assert!(a == b)` only prints the source text.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`&mut x as *mut _` creates a real `&mut` first, which asserts unique
access. In the FFI stream code the callee gets a pointer to the same
stream, so `&raw mut x` is the right way to build these pointers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A leading underscore says a binding is unused; reading it anyway makes
the name lie. The two conditionally-used parameters keep their names and
get a feature-gated expect.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Casting a byte pointer to a wider type is UB unless the access is
unaligned or the buffer alignment is known. The five existing casts all
hold, and now say why.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@emilk
emilk force-pushed the emilk/high-value-clippy-lints branch from ec0023c to 191998c Compare September 1, 2026 12:17
@emilk
emilk marked this pull request as ready for review September 1, 2026 12:25

@Rich-T-kid Rich-T-kid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thank you for splitting this up into one lint per commits. It makes it very easy to review in focused chunks.

This looks good to me except for the cast_ptr_alignment lint which unlike the others I dont think it improves the code.

Comment thread Cargo.toml
cast_possible_truncation = "allow" # ~890 violations in ~190 files
cast_possible_wrap = "allow" # ~570 violations in ~120 files
cast_precision_loss = "allow" # ~130 violations in ~33 files
cast_ptr_alignment = "allow" # ~3 violations in ~3 files

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Im not sure about this lint. we just added expect() blocks for each site instead of changing anything.

I don't see much difference between the current state of this commit and the current saftey comments that already exist

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It didn't fix anything in the current code no, but it will help protect us against future mis-alignment bugs 🤷

See https://rust-lang.github.io/rust-clippy/master/index.html#cast_ptr_alignment for more

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sounds reasonable 👍

@Jefffrey Jefffrey added the development-process Related to development process of arrow-rs label Sep 1, 2026
@Jefffrey
Jefffrey merged commit 000a7fd into apache:main Sep 1, 2026
50 checks passed
@Jefffrey

Jefffrey commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

thanks @emilk & @Rich-T-kid

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

Labels

arrow Changes to the arrow crate arrow-array arrow-avro arrow-avro crate arrow-buffer arrow-data arrow-integration-test arrow-ipc arrow-select development-process Related to development process of arrow-rs parquet Changes to the parquet crate parquet-geospatial parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants