chore: introduce a broader set of workspace clippy lints - #24066
Conversation
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>
`HashTable::find_entry` takes `&mut self`; `find` does the same lookup through `&self`. 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>
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>
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 Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
|
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. |
|
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 |
|
Just the two first commits: |
Splitting them into separate PRs can make them easier to review. I suggest to do the following steps
|
Which issue does this PR close?
Clippychecks in CI #18467.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 warningsgreen:[workspace.lints.clippy]list (no lint added/removed).[lints] workspace = truetodatafusion-proto,-proto-commonand-proto-modelsCI already runs
cargo clippy ... -- -D warningsviaci/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.