Enable more lints - #24066
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #24066 +/- ##
==========================================
- Coverage 81.04% 81.04% -0.01%
==========================================
Files 1105 1105
Lines 380163 380152 -11
Branches 380163 380152 -11
==========================================
- Hits 308111 308101 -10
- Misses 53834 53839 +5
+ Partials 18218 18212 -6 ☔ 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? - Part of apache#18467 - Broken out of apache#24066 - Sibling PR: apache/arrow-rs#10533 ## Rationale for this change The workspace already has a `[workspace.lints]` table, but it was missing from three crates ## What changes are included in this PR? Inheriting the workspace lints in all crates, and fixing the resulting violations ## Are these changes tested? Yes, by existing tests and CI ## Are there any user-facing changes? No --------- 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>
c159311 to
d3e857a
Compare
|
The first two commits have been merged to main, so I have rebased this PR now! |
2010YOUY01
left a comment
There was a problem hiding this comment.
I have went over the extra rule list, and find most of them useful.
I suggest to:
- Remove one rule (see below)
- Remove non-Clippy lint changes (see comments)
Reference: https://rust-lang.github.io/rust-clippy/master/
Suggest not to enforce
unnecessary_safety_comment: now we informally use// safety: xxxcomment for internal methods that require extra cares, this clippy rule forbids such convention and only allow such comment in Rustunsafes, I think this is not necessary.
…lints * Drop lints that clippy already enables by default (`char_lit_as_u8`, `empty_line_after_outer_attr`, `if_let_mutex`, `manual_ok_or`, `missing_enforced_import_renames`, `suspicious_command_arg_space`, `useless_transmute`). * Drop `unnecessary_safety_comment`: it conflicts with the existing convention of using `// SAFETY:` comments on safe-but-delicate internal methods. * Move the `[workspace.lints.rust]` and `[workspace.lints.rustdoc]` sets out to follow-up PRs to keep this one reviewable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
New code from `main` trips `clippy::pathbuf_init_then_push`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thanks again, I have manually check the key changes, and let Codex checked code changes to ensure they're all related and safe. I think we also need to remove
After that this PR should be good to go |
Which issue does this PR close?
Clippychecks in CI #18467Rationale for this change
There are a lot of lints we can enable to, which different abilities to:
What changes are included in this PR?
One commit per new lint (maybe easiest to review commit by commit!).
I hope to add even more lints in later PRsq
Are these changes tested?
Covered by existing tests plus the clippy CI job.
Are there any user-facing changes?
No.