Enable more clippy lints - #10673
Open
emilk wants to merge 16 commits into
Open
Conversation
None of these fire on the current code base, so this is purely a guard against future regressions: * `coerce_container_to_any` - catches `Box<Rc<dyn Any>>` upcasts that can never match * `decimal_bitwise_operands` - catches bitwise operators on decimal literals * `doc_broken_link` - catches malformed links in docs * `duration_suboptimal_units` - prefer the clearest `Duration` constructor * `empty_enums` - suggests a never type instead * `ip_constant` - prefer the named IP address constants * `manual_ilog2` - prefer `ilog2` over a hand-rolled version * `needless_type_cast` - catches casts to the same type * `self_only_used_in_recursion` - catches parameters that do nothing but get passed along * `unchecked_time_subtraction` - catches `Instant` subtraction that can panic
emilk
force-pushed
the
emilk/more-clippy-lints
branch
from
August 13, 2026 09:34
50a1bf4 to
94c7560
Compare
emilk
commented
Aug 13, 2026
emilk
force-pushed
the
emilk/more-clippy-lints
branch
from
August 13, 2026 11:39
94c7560 to
fc7228e
Compare
emilk
commented
Aug 13, 2026
emilk
commented
Aug 13, 2026
emilk
commented
Aug 13, 2026
Hoists the code that every branch of an `if`/`else` shares out of the branches, which removes seven copy-pasted blocks.
Types with an `iter` method should also implement `IntoIterator` for their reference type, so that `for x in &collection` works. Adds the missing impls for `FixedSizeListArray`, `GenericListArray`, `GenericListViewArray`, `MapArray`, `BitChunks`, `UnalignedBitChunk` and `VariantArray`.
`&Option<T>` in an argument position forces the caller to have an owned `Option`; `Option<&T>` does not, and it is one less indirection to read through. All ten sites were private or `pub(crate)`, so no public API changed.
Makes the fallback of `unwrap_or`/`or`/`ok_or`/`map_or` lazy, so that the eleven sites that built an error, a `String` or a cursor only do that work when the fallback is actually taken.
`std::ptr::from_ref`/`from_mut` says what the code means and cannot silently change the pointee type, unlike a chain of `as` casts. The generated flatbuffers modules in `arrow-ipc/src/gen` are now exempt from `clippy::pedantic` as well as `clippy::all`: they say "do not modify" at the top, so no pedantic lint can ever be fixed there.
Removes 25 `continue` statements that were the last thing in their loop body, so they only restated what the loop already does. Two of them, in `arrow-ord::comparison`, become `break`: once a matching list element is found there is nothing left to look for.
Drops 25 type annotations that only repeated the type of the expression on the right hand side.
Building a one-element array only to iterate it allocates a temporary and hides how many items there are. Twelve `HashMap` cases become `HashMap::from([..])`; the rest become `std::iter::once`.
Removes trailing commas after the last macro argument, mostly in `panic!` and `assert_eq!` messages, where they look like a forgotten argument.
`to_string`/`to_vec`/`to_owned` on a type that is already owned goes through `Deref` and clones anyway, just less obviously. Four of the sites turned out to be clones nothing needed, so they are now gone entirely.
`copied` says the element is `Copy`, so the reader does not have to wonder whether the iterator is cloning something expensive. `UnalignedBitChunkIterator` changes from `Cloned<..>` to `Copied<..>` accordingly.
An `&mut` that is never used mutably asks callers for more than the function needs, which can stop them from sharing the value at all. Most of the sites are the stateless Avro encoders, which only read their array. The `#[cfg(not(feature = "encryption"))]` stubs keep their `&mut self` and get an `#[expect]` with a reason: their signatures mirror the encryption-enabled versions so callers need no `cfg` of their own.
A `_` arm that covers exactly one variant silently swallows every variant added later. Naming the variant makes the compiler point at the match when the enum grows. `get_encoder` keeps `Encoding::BIT_PACKED` explicit and gets an `#[expect(deprecated)]`: rejecting that encoding is the whole point of the arm.
`pointer::cast` cannot silently change constness the way `as` can, and it makes the target type explicit at the call site. This matters here: nearly every site feeds a `from_raw_parts` in unsafe code.
`for x in &collection` is the shorter spelling of `for x in collection.iter()`, and it makes the borrow visible at a glance.
emilk
force-pushed
the
emilk/more-clippy-lints
branch
from
August 13, 2026 11:49
8542fd6 to
8469269
Compare
emilk
commented
Aug 13, 2026
| if list.is_valid(j) && (left.value(i) == list.value(j)) { | ||
| bit_util::set_bit(bool_slice, i); | ||
| continue; | ||
| break; |
Contributor
Author
There was a problem hiding this comment.
small perf win: we only need to mark bit i once.
emilk
commented
Aug 13, 2026
| if list.is_valid(j) && (left.value(i) == list.value(j)) { | ||
| bit_util::set_bit(bool_slice, i); | ||
| continue; | ||
| break; |
emilk
marked this pull request as ready for review
August 13, 2026 11:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
No issue in particular
[workspace.lints.clippy]#10552[workspace.lints.rust]#10551Rationale for this change
More lints hand-picked from egui's
Cargo.toml, to simplify the code, catch bugs, and write more efficient code.What changes are included in this PR?
One commit per new lint (maybe easiest to review commit by commit!), except for ten lints with zero violations, which share one commit.
Let me know if you disagree with any of them.
I hope to add even more lints in later PRs.
Are these changes tested?
Covered by existing tests plus the clippy CI job.
Are there any user-facing changes?
Two additive ones:
IntoIteratoris now implemented for references toFixedSizeListArray,GenericListArray,GenericListViewArray,MapArray,BitChunks,UnalignedBitChunkandVariantArray, and theUnalignedBitChunkIteratoralias now namesCopiedinstead ofCloned.