-
Notifications
You must be signed in to change notification settings - Fork 477
Description
Please see as well #350 (i.e. some lints may make sense in Clippy, some in rustdoc).
Features that we would like to see
Required (we almost certainly want them)
-
Lint to require
// PANIC: ...comments.- Issue:
// PANICcomment on panic-able calls rust-lang/rust-clippy#15861. - Issue (duplicate with more context): Lint to require
// PANIC: ...comments rust-lang/rust-clippy#15895. - Cc: @blyxyas @hcbarker.
- Issue:
-
Lint to detect unneeded
// PANIC: ...comments.- Issue: Lint to detect unneeded
// PANIC: ...comments rust-lang/rust-clippy#15896. - The dual to the one that requires it (see above).
- Cc: @blyxyas @hcbarker.
- Issue: Lint to detect unneeded
-
Lint to require
// CAST: ...comments forascasts. -
Lint to require
// CAST: ...comments for pointer casts. -
Lint to detect unneeded
// CAST: ...comments.- Issue: Lint to detect unneeded
// CAST: ...comments rust-lang/rust-clippy#15964. - The dual to the one(s) that require it (see above), i.e.
ascasts and pointer casts. - Cc: @blyxyas @hcbarker.
- Issue: Lint to detect unneeded
-
Lint to catch
#[no_mangle]on non-repr(C)pub statics. -
Support custom
dbg!s in thedbg_macrolint.- We started using it in Rust 1.60, but it stopped working in 1.61 (but it may be intended).
- Issue: Custom
dbg!macros fordbg_macrolint rust-lang/rust-clippy#11303.
-
Lint to catch non-absolute paths in macros, e.g.
core::...instead of::core::....- Issue: New lint:
relative_path_in_macro_definitionrust-lang/rust-clippy#14472. - PR: Add relative_path_in_macro_definition lint (#14472) #14645 rust-lang/rust-clippy#14648.
- PR: Add relative_path_in_macro_definition lint (#14472) rust-lang/rust-clippy#14645.
- Lore: https://lore.kernel.org/rust-for-linux/D8PDWRH06U1X.3JGHP1311BPPY@proton.me/.
- Issue: New lint:
-
Lint to catch unnecessary generics like
Result<()>. -
Support custom
assert*!s for lints likeeq_op.
Nice to have (not critical, we could workaround if needed, etc.)
-
Improved shadowing lints.
- We currently do not enable any of the
shadow_*lints. In particular,shadow_reusewould lint on many things that are OK for us, especially "top-level"let ... =s. Please see the details in Lint dangerous uses of shadowing rust-lang/rust-clippy#3433 (comment). - It would have already prevented one kernel bug: https://lore.kernel.org/rust-for-linux/20241123-rust-fix-arraylayout-v1-1-197e64c95bd4@asahilina.net/.
- Issue: Lint dangerous uses of shadowing rust-lang/rust-clippy#3433.
- Issue: Lint request: warn when variable declared in match pattern shadows other variable rust-lang/rust-clippy#2890.
- We currently do not enable any of the
-
Lints that generalize
exit,todo,mem_forget, etc. -
disallowed_namessupport for identifiers. -
Per-path lint levels for
DisallowedPath-related lints. -
Have a lint against usize-to-u64 casts (or, against all integer casts).
-
Make
unnecessary_castcover somecore::ffi::c_*cases. -
unnecessary_castdoes not trigger with a local but it does with a parameter. -
Ignoring lints added after a given Rust version.
- Issue: Ignoring lints added after a given Rust version rust-lang/rust-clippy#11227.
- Related: New lints are not backwards compatible rust-lang/cargo#12495 (about ignoring unknown lints, explicitly passed, when compiling with an older compiler, rather than a new compiler introducing new lints).
- If we had something like this, then we could consider using
-Dfor some lint groups or leaving Clippy's default for some lints inclippy::all.
-
Unsafe attributes support.
-
Avoid inherent methods on generic smart pointers.
-
Split
needless_lifetimes.- One "major addition" to the lint added in 1.86.
- Currently it is the only
clippy::alllint that weallow. - Issue: Consider splitting
needless_lifetimesinto cases that do and do not require'_rust-lang/rust-clippy#13514. - Lore: https://lore.kernel.org/rust-for-linux/20241012231300.397010-1-ojeda@kernel.org/.
- Lore: https://lore.kernel.org/rust-for-linux/20241116181538.369355-1-ojeda@kernel.org/.
-
Support for
--fixwithout Cargo (e.g. insideclippy-driver).- Using
cargo(the binary) would be fine if needed, but not if it requires a Cargo-based structure.
- Using
-
unsafe externsupport. -
Unneeded
rustas language inrustdoc's documentation examples. -
manual_div_ceilsuggests change that could alter behaviour. -
Lint to catch docs using
///instead of//!.- Issue: Documentation mistakenly using
///instead of//!rust-lang/rust-clippy#14402. - Example: 8d9b095 ("samples: rust_misc_device: Provide an example C program to exercise functionality").
- Issue: Documentation mistakenly using
-
Support
msrvwith a list of unstable features to assume (or perhaps a list of lints that ignore themsrvfield). -
Lint to catch links in normal comments (i.e.
//) that are not formatted as Markdown autolinks (i.e.<https://...>).- Should lints like these be part of
rustdocin general, like the wish for intra-doc links there? - Rust for Linux example issue to clean instances of these: Use Markdown autolinks in normal comments #1153.
- Should lints like these be part of
-
Lint to detect unindented triple backquotes in the end of examples.
-
Lint to detect code block contents without "base indentation" in docs.
-
Lint to detect extra "base indentation" in Rust code blocks.
-
Lint to detect inconsistent "style" for safety-related docs/comments.
- Issue: Detect inconsistent "style" for safety-related docs/comments rust-lang/rust-clippy#15033.
- Related:
unnecessary_safety_commentinconsistency with wrong-style safety section rust-lang/rust-clippy#15034. - Example: https://lore.kernel.org/rust-for-linux/4823a58093c6dfa20df62b5c18da613621b9716e.1749554599.git.viresh.kumar@linaro.org/.
-
Lint to detect
//within///(only when the empty comment is empty). -
Lint to disallow imports of certain items (to force users to write e.g.
ordering::Any).- Issue: Lint to disallow imports of certain items rust-lang/rust-clippy#15244.
- Lore: "[PATCH v6 3/9] rust: sync: atomic: Add ordering annotation types".
-
wildcard_imports'sallowed-wildcard-importswith several path segments. -
manual_is_multiple_ofsuggests change that could alter behaviour. -
Providing information about integer type aliases with multiple sizes.
Low priority (we will likely not use them in the end)
-
Conditional compilation for
clippy.toml?- No concrete use cases from our side yet; and if needed, we could always handle it on our side generating
.clippy.tomlon the fly (and usingCLIPPY_CONF_DIRto find it in theobjtreeinstead of thesrctree). - Issue: Conditional compilation for configuration file? rust-lang/rust-clippy#11433.
- No concrete use cases from our side yet; and if needed, we could always handle it on our side generating
-
Fine-grained
check-private-items(https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items).- So far, we have
check-private-itemsenabled, but we do not have all the lints covered enabled, and in the future we might want to enable them, thuscheck-private-itemsmay make it harder to start. - Issue: Separate
check-private-itemsconfiguration for different lints rust-lang/rust-clippy#13074.
- So far, we have
Done (stabilized, fixed, not needed anymore, etc.)
-
Overindented lines lint (similar to
doc_lazy_continuation). -
Support/document running Clippy as a
rustcwrapper. -
Configuring lint levels when using
clippy-driver. -
Normalize semicolon inside/outside blocks for
()returning expressions (semicolon_outside_blockandsemicolon_inside_block, 1.68.0). -
Lint to warn about missing
// SAFETY:explanations (undocumented_unsafe_blocks, 1.58.0). -
Lint to warn about unexpected
# Safetycontracts (i.e. the reverse of themissing_safety_doclint) (unnecessary_safety_doc, 1.67.0). -
Lint to warn about unexpected
// SAFETY:comments (i.e. the reverse of theundocumented_unsafe_blockslint) (unnecessary_safety_comment, 1.67.0).- Issue: New lint (
unnecessary_safety_comment): reverse ofundocumented_unsafe_blocksrust-lang/rust-clippy#7954. - PR: Lint unnecessary safety comments rust-lang/rust-clippy#9851.
- Unclear if we will use
// SAFETY:comments also for explaining why safe code makes other unsafe code sound, though.
- Issue: New lint (
-
Lint to catch
#[no_mangle]but non-extern "C"(no_mangle_with_rust_abi, 1.69.0). -
Lint to catch printing/formatting pointers (including
:pand:?).- In Linux, ideally, there would be a way to customize all pointer printing, i.e. including
:pand:?, so that we can get them hashed as expected, and thus at that point we wouldn't need to lint for it. Meanwhile, this lint can be useful (and may be for other projects that do not want any printing whatsoever, too). - PR: new restriction lint: pointer_format rust-lang/rust-clippy#14792 (1.89).
- Zulip: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Clippy.20lint.20for.20detecting.20pointer.20printing/near/517813625.
- In Linux, ideally, there would be a way to customize all pointer printing, i.e. including
-
Macros wrapping expressions in
unsafeblocks when usingunsafe_op_in_unsafe_fn.- This was eventually handled by
clippy::macro_metavars_in_unsafe, which is insuspiciousalready, so we are already using it and e.g. writing a "bad"container_of!(and using it) does lint for us. - Issue: Macros wrapping expressions in
unsafeblocks when usingunsafe_op_in_unsafe_fnrust-lang/rust-clippy#7323. - Unfinished PR: Add new lint
macros_hiding_unsafe_coderust-lang/rust-clippy#7469. - PR: new lint:
macro_metavars_in_unsaferust-lang/rust-clippy#12107 (1.80).
- This was eventually handled by
-
Lint to suggest
cast_signedandcast_unsigned(added suggestion tocast_possible_wrapandcast_sign_loss).- Stable since Rust 1.87, unstable since 1.80 (i.e. we would need to wait until we bump the minimum).
- Issue: Suggest
cast_signedandcast_unsignedinstead ofasrust-lang/rust-clippy#14974. - PR: Add suggestion to
cast_sign_lossandcast_possible_wrapusing thecast_{un,}signed()methods rust-lang/rust-clippy#15384 (1.92).
Bugs that we would like to see fixed
Required (we almost certainly want them)
-
disallowed_macrosfalse negatives.- For
dbg_macroemulation purposes. - Issue:
disallowed_macrosfalse negatives rust-lang/rust-clippy#11431. - PR (for the
$t + $tcase): Check binary operators and attributes in disallowed_macros rust-lang/rust-clippy#11439 (1.74).
- For
-
cast_losslessfalse negative onchar as u32.
Nice to have (probably not critical, we could workaround if needed, etc.)
-
unnecessary_safety_commentdoes not lint for "orphan" comments. -
unnecessary_safety_commentinconsistency with wrong-style safety section. -
Feedback on
needless_continuein Rust 1.86.0 (which we will probably disable globally).
Low priority (we will likely not use them in the end)
Done (stabilized, fixed, or not needed anymore, etc.)
-
README: document that Clippy may change codegen. -
new_ret_no_selffalse positive when returningimpl Trait<Self>. -
macro_metavars_in_unsafefalse negative without statement. -
single_matchdifference in 1.85.0 -- is it intended?- We cannot use
expectin https://lore.kernel.org/rust-for-linux/20250122054719.595878-1-dirk.behme@de.bosch.com/. - Issue:
clippy::single_matchdoes not report if a comment is on top of an arm rust-lang/rust-clippy#14418. - PR: Reinstate
single_match/single_match_elselints with comments rust-lang/rust-clippy#14420 (1.87?).
- We cannot use
-
Diagnostic for unexpected paths in configuration file.
- For instance, for
disallowed_macros's paths. - Issue: Diagnostic for unexpected paths in configuration file rust-lang/rust-clippy#11432.
- PR: Validate paths in
disallowed_*configurations rust-lang/rust-clippy#14397 (1.87?).
- For instance, for
-
Reduce or split
ptr_eq.- One "major addition" to the lint (linting all pointer comparisons) added in 1.87.
- We may need to
allowit globally otherwise, likeneedless_continue. - Issue: Feedback on
needless_continuein Rust 1.86 rust-lang/rust-clippy#14536. - Issue: clippy beta 1.87 lints all pointer comparisons, possibly too much? rust-lang/rust-clippy#14525.
- PR: Restrict the cases where
ptr_eqtriggers rust-lang/rust-clippy#14526. - Backport PR (for Rust 1.87): [beta] Clippy beta backport rust-lang/rust#140810, [stable] Prepare the 1.87.0 release rust-lang/rust#140859.
- Patch that
allowed a few of them (when applied): https://lore.kernel.org/rust-for-linux/20250502140237.1659624-3-ojeda@kernel.org/.
-
undocumented_unsafe_blocksfalse positives around attributes.- Workaround: moving the attribute on top always fixes it.
- Workaround: where it makes sense, moving the comment inside the expression, also works.
- Issue:
undocumented_unsafe_blocksfalse positives around attributes rust-lang/rust-clippy#13189. - PR: Propagate
accept-comment-above-attributesto statements rust-lang/rust-clippy#15213 (1.90).
-
Fix false positives around
undocumented_unsafe_blocks'saccept-comment-above-statement.- i.e. that trigger when long statements are split into several lines by e.g.
rustfmt. - Originally Clippy didn't support the config option, but eventually it was implemented and then made the default later on. However, there have been false positives around it.
- When we introduced the lint in Linux (commit db4f72c ("rust: enable
clippy::undocumented_unsafe_blockslint")), we just put the// SAFETYcomment on the previous line, even if it is in the middle of the statement, to workaround it, e.g. seedo_unlockedin the commit. - Starting with Rust 1.87.0, false positives like those we triggered in the kernel seem to be fixed, e.g. https://lore.kernel.org/rust-for-linux/87msbw1s9e.fsf@kernel.org/ and https://lore.kernel.org/rust-for-linux/DBG25OQZJ18V.1W13FEOPX8MOH@kernel.org/.
- Issue:
undocumented_unsafe_blockscan be broken byrustfmtrust-lang/rust-clippy#13024. - PR: fix:
undocumented_unsafe_blocksFP on trait/impl items rust-lang/rust-clippy#13888 (1.87).
- i.e. that trigger when long statements are split into several lines by e.g.
-
unnecessary_safety_commentdoes not lint for the first line. -
unnecessary_safety_commentdoes not lint the first item of a module without a body.- Issue:
unnecessary_safety_commentdoes not lint the first item of a module without a body rust-lang/rust-clippy#14554. - PR: Fix
unnecessary_safety_commentdoes not lint for the first line rust-lang/rust-clippy#15354 (1.91). - Lore: https://lore.kernel.org/rust-for-linux/20250405060154.1550858-3-andrewjballance@gmail.com/.
- Issue:
-
unnecessary_safety_commentdoes not lint for adoc(hidden)item.