Skip to content

chore: introduce a broader set of workspace clippy lints - #24066

Draft
emilk wants to merge 16 commits into
apache:mainfrom
emilk:emilk/workspace-lints
Draft

chore: introduce a broader set of workspace clippy lints#24066
emilk wants to merge 16 commits into
apache:mainfrom
emilk:emilk/workspace-lints

Conversation

@emilk

@emilk emilk commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

The workspace already has a [workspace.lints] table, but it was missing from three crates and only enabled a handful of lints. This grows that set slightly, saving bigger changes for future PRs.

What changes are included in this PR?

One commit per step, each of which leaves cargo clippy -D warnings green:

  1. Sort the existing [workspace.lints.clippy] list (no lint added/removed).
  2. Add [lints] workspace = true to datafusion-proto, -proto-common and -proto-models
  3. Enable a batch of non-default clippy lints that are already violation-free.

CI already runs cargo clippy ... -- -D warnings via ci/scripts/rust_clippy.sh,
so no CI change was needed.

Are these changes tested?

Covered by existing tests plus the clippy CI job.

Are there any user-facing changes?

No.

emilk and others added 6 commits August 3, 2026 21:30
Pure reordering, no lint is added or removed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`datafusion/proto`, `datafusion/proto-common` and `datafusion/proto-models`
were the only workspace members without `[lints] workspace = true`, so the
workspace lint configuration silently did not apply to them.

Enabling it surfaces a handful of violations, fixed here:

* `unused_qualifications`: redundant path prefixes (mostly `cargo fix`ed)
* `clippy::or_fun_call`: `unwrap_or(HashMap::new())` -> `unwrap_or_default()`
* `clippy::needless_pass_by_value`: one `#[expect]` on a public API, plus a
  crate-level exemption for the integration tests matching what the other
  DataFusion crates already do for their unit tests

The generated protobuf modules opt out of `unused_qualifications` alongside
the `clippy::all` opt-out they already had.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
All of these are already violation-free across the workspace, so this is
pure future-proofing: they only fire on newly written code.

They are a subset of the lint set used by https://github.com/emilk/egui,
picked because they trigger no (or almost no) violations in DataFusion today.

The single existing violation is a deliberate `mem::forget` in an FFI test
helper, now marked with `#[expect]`.

Part of apache#18467

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added proto Related to proto crate functions Changes to functions implementation datasource Changes to the datasource crate ffi Changes to the ffi crate physical-plan Changes to the physical-plan crate labels Aug 3, 2026
`HashTable::find_entry` takes `&mut self`; `find` does the same lookup
through `&self`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@emilk
emilk marked this pull request as ready for review August 3, 2026 19:59
emilk and others added 3 commits August 3, 2026 21:59
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates core Core DataFusion crate common Related to common crate labels Aug 3, 2026
emilk and others added 4 commits August 3, 2026 22:08
Gating the `include_str!` docs on `cfg(doc)` means touching the included
markdown no longer forces a rebuild of the crate for non-doc builds.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`SAFETY:` comments should sit next to the `unsafe` block they justify. The
existing ones either documented safe code (reworded) or were attached to the
enclosing `if` rather than the `unsafe` block (moved).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Enables the rustc lint groups and individual lints from
https://github.com/emilk/egui/blob/main/Cargo.toml that DataFusion violates
at most 10 times today:

* `future_incompatible`, `nonstandard_style`, `rust_2018_idioms` (groups)
* `rust_2021_prelude_collisions`, `semicolon_in_expressions_from_macros`,
  `unsafe_op_in_unsafe_fn`, `unused_extern_crates`, `unused_import_braces`,
  `unused_lifetimes`

`elided_lifetimes_in_paths` is part of `rust_2018_idioms` but has ~800
violations, so it is explicitly allowed for now. `trivial_numeric_casts` (31
violations) and `unsafe_code` are left out entirely.

The violations fixed here are vestigial `extern crate` items, redundant import
braces, and two `rstest` helpers whose lifetime is unused after macro expansion.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Enables the `rustdoc::all` group. Two of its lints have more than 10
violations today and are explicitly allowed for now:
`missing_crate_level_docs` (18) and `unescaped_backticks` (28).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added optimizer Optimizer rules spark labels Aug 3, 2026
emilk and others added 2 commits August 3, 2026 22:37
Removing it made `libc` an unused dependency (`cargo machete` CI failure): the
crate has no path references, it is only linked so the `fesetround`/`fegetround`
symbols declared in this module resolve.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Keep the `LogicalPlanType::` prefix on the `CustomScan` match arm so it
  matches its sibling arms; drop the variant import instead.
* Restore a `SAFETY:` comment on the second `unsafe` block in `cursor.rs`.
* Drop `rustdoc::broken_intra_doc_links`, already covered by `rustdoc::all`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.88%. Comparing base (62650ef) to head (c159311).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/proto-common/src/to_proto/mod.rs 64.28% 3 Missing and 2 partials ⚠️
datafusion/datasource-arrow/src/source.rs 50.00% 0 Missing and 4 partials ⚠️
datafusion/functions-nested/src/range.rs 50.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #24066   +/-   ##
=======================================
  Coverage   80.87%   80.88%           
=======================================
  Files        1101     1102    +1     
  Lines      375765   375789   +24     
  Branches   375765   375789   +24     
=======================================
+ Hits       303915   303939   +24     
- Misses      53747    53748    +1     
+ Partials    18103    18102    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2010YOUY01

Copy link
Copy Markdown
Contributor

Thank you. I suggest including only the first two commits in this PR to make it easier to verify.

For any additional rules, I think we should first confirm that they are useful, so it would be better to add them in separate PRs.

@emilk

emilk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

I can do that - but I've tested out all these lints (and more) myself over the last couple of years in both https://github.com/rerun-io/rerun and https://github.com/emilk/egui and can vouch for their usefulness

@emilk

emilk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Just the two first commits:

@emilk
emilk marked this pull request as draft August 4, 2026 07:31
@2010YOUY01

Copy link
Copy Markdown
Contributor

I can do that - but I've tested out all these lints (and more) myself over the last couple of years in both https://github.com/rerun-io/rerun and https://github.com/emilk/egui and can vouch for their usefulness

Splitting them into separate PRs can make them easier to review. I suggest to do the following steps

  1. chore: apply workspace lints to all crates #24076 LGTM, I'll merge it shortly
  2. Open a separate PR for commit feat: enable a batch of non-default clippy lints workspace-wide
  3. I will review the extra lint rule list later (that list is really helpful!), if there is no issue, we could do that in another PR.

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

Labels

common Related to common crate core Core DataFusion crate datasource Changes to the datasource crate ffi Changes to the ffi crate functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate proto Related to proto crate spark

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants