For my kernel and its libk library I've turned on various lints; specifically, the following:
For the binary:
#![forbid(
absolute_paths_not_starting_with_crate,
anonymous_parameters,
deprecated_in_future,
explicit_outlives_requirements,
indirect_structural_match,
keyword_idents,
macro_use_extern_crate,
meta_variable_misuse,
missing_abi,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
noop_method_call,
pointer_structural_match,
private_doc_tests,
rust_2021_incompatible_closure_captures,
rust_2021_incompatible_or_patterns,
rust_2021_prefixes_incompatible_syntax,
rust_2021_prelude_collisions,
semicolon_in_expressions_from_macros,
single_use_lifetimes,
trivial_casts,
trivial_numeric_casts,
unaligned_references,
unreachable_pub,
unsafe_op_in_unsafe_fn,
unused_crate_dependencies,
unused_import_braces,
unused_lifetimes,
unused_qualifications,
variant_size_differences,
warnings,
box_pointers
)]
#![forbid(clippy::all)]
And for the library:
#![forbid(
absolute_paths_not_starting_with_crate,
anonymous_parameters,
deprecated_in_future,
explicit_outlives_requirements,
indirect_structural_match,
keyword_idents,
macro_use_extern_crate,
meta_variable_misuse,
missing_abi,
missing_docs,
non_ascii_idents,
noop_method_call,
pointer_structural_match,
private_doc_tests,
rust_2021_incompatible_closure_captures,
rust_2021_incompatible_or_patterns,
rust_2021_prefixes_incompatible_syntax,
rust_2021_prelude_collisions,
semicolon_in_expressions_from_macros,
single_use_lifetimes,
trivial_numeric_casts,
unaligned_references,
unused_crate_dependencies,
unused_extern_crates,
unused_import_braces,
unused_lifetimes,
variant_size_differences,
warnings,
trivial_casts
)]
#![deny(
missing_copy_implementations,
missing_debug_implementations,
)]
#![forbid(clippy::all)]
I was going to add unreachable_pub
but that threw errors and was wanting me to make a ton of things pub(crate)
that were originally pub
, and I was going to add unsafe_op_in_unsafe_fn
but that was a bit of an antithetical lint because it wanted me to add unsafe
blocks in unsafe
functions (which didn't make sense and would've raised more errors). So my questions are:
- Is it a good idea to enable these lints?
- Is a better description for each lint provided somewhere else? The
rustc
help doesn't really elaborate on what the lints do. An example is theunused_qualifications
lint -- in the past that simply printed a useless error message of "error: unused qualification". Its a bit more helpful now but the output ofrustc -W help
is pretty useless for some of these. - Why do some of these lints exist? What are good situations that they would apply to?
- Could these lints be more of a problem than a help?
- Why aren't some of these lints (e.g.
unused_crate_dependencies
) enabled by default? Some of them seem like no-brainers to me.