Rust Lints

For Rust version 1.67.0. References:

Allow by default lints

LintVerdictComment
absolute_paths_not_starting_with_cratewarn
box_pointersdefault
elided_lifetimes_in_pathsdefault
explicit_outlives_requirementswarn
ffi_unwind_callsdefault
fuzzy_provenance_castswarnUnstable
keyword_identsdefault
let_underscore_dropwarn
lossy_provenance_castswarnUnstable
macro_use_extern_cratewarn
meta_variable_misusewarn
missing_abiwarn
missing_copy_implementationsdefault
missing_debug_implementationsdefault
missing_docswarn
must_not_suspendwarnUnstable
non_ascii_identsdefault
non_exhaustive_omitted_patternswarnUnstable
noop_method_callwarn
pointer_structural_matchwarn
rust_2021_incompatible_closure_capturesdefault
rust_2021_incompatible_or_patternsdefault
rust_2021_prefixes_incompatible_syntaxdefault
rust_2021_prelude_collisionsdefault
single_use_lifetimeswarnHas false positives.
trivial_castswarn
trivial_numeric_castswarn
unreachable_pubdefaultSee clippy::redundant_pub_crate.
unsafe_codewarn
unsafe_op_in_unsafe_fnwarn
unstable_featuresdefault
unused_crate_dependencieswarn
unused_extern_crateswarn
unused_import_braceswarn
unused_lifetimeswarn
unused_macro_ruleswarn
unused_qualificationswarn
unused_resultsdefault
unused_tuple_struct_fieldswarn
variant_size_differenceswarn
clippy::alloc_instead_of_corewarn
clippy::allow_attributes_without_reasonwarn
clippy::arithmetic_side_effectsdefault
clippy::as_conversionsdefault
clippy::as_ptr_cast_mutwarn
clippy::as_underscoredefault
clippy::assertions_on_result_statesdefault
clippy::branches_sharing_codewarn
clippy::cargo_common_metadatawarn
clippy::clone_on_ref_ptrwarn
clippy::cognitive_complexitywarn
clippy::create_dirwarn
clippy::dbg_macrowarn
clippy::debug_assert_with_mut_callwarn
clippy::decimal_literal_representationwarn
clippy::default_numeric_fallbackdefault
clippy::default_union_representationdefault
clippy::deref_by_slicingwarn
clippy::derive_partial_eq_without_eqwarn
clippy::disallowed_script_identsdefault
clippy::else_if_without_elsedefault
clippy::empty_dropwarn
clippy::empty_line_after_outer_attrwarn
clippy::empty_structs_with_bracketswarn
clippy::equatable_if_letwarn
clippy::exhaustive_enumsdefault
clippy::exhaustive_structsdefault
clippy::exitdefault
clippy::expect_useddefault
clippy::fallible_impl_fromwarn
clippy::filetype_is_filewarn
clippy::float_arithmeticdefault
clippy::float_cmp_constwarn
clippy::fn_to_numeric_cast_anydefault
clippy::format_push_stringwarn
clippy::future_not_senddefault
clippy::get_unwrapwarn
clippy::if_then_some_else_nonewarn
clippy::implicit_returndefault
clippy::imprecise_flopswarn
clippy::indexing_slicingdefault
clippy::inline_asm_x86_att_syntaxdefault
clippy::inline_asm_x86_intel_syntaxdefault
clippy::integer_arithmeticdefault
clippy::integer_divisiondefault
clippy::iter_on_empty_collectionswarn
clippy::iter_on_single_itemswarn
clippy::iter_with_drainwarn
clippy::large_include_filewarn
clippy::let_underscore_must_usewarn
clippy::lossy_float_literalwarn
clippy::manual_clampwarn
clippy::map_err_ignorewarn
clippy::mem_forgetdefault
clippy::missing_const_for_fndefault
clippy::missing_docs_in_private_itemsdefault
clippy::missing_enforced_import_renamesdefault
clippy::missing_inline_in_public_itemsdefault
clippy::missing_trait_methodsdefault
clippy::mixed_read_write_in_expressionwarn
clippy::mod_module_filesdefault
clippy::modulo_arithmeticdefault
clippy::multiple_crate_versionsdefault
clippy::multiple_inherent_implwarn
clippy::multiple_unsafe_ops_per_blockdefault
clippy::mutex_atomicwarn
clippy::mutex_integerwarn
clippy::needless_collectwarn
clippy::negative_feature_nameswarn
clippy::non_ascii_literaldefault
clippy::non_send_fields_in_send_tywarn
clippy::nonstandard_macro_braceswarn
clippy::option_if_let_elsewarn
clippy::or_fun_callwarn
clippy::panicwarn
clippy::panic_in_result_fnwarn
clippy::partial_pub_fieldswarn
clippy::path_buf_push_overwritewarn
clippy::pattern_type_mismatchdefault
clippy::pedanticwarn
clippy::print_stderrwarn
clippy::print_stdoutwarn
clippy::pub_usedefault
clippy::rc_bufferwarn
clippy::rc_mutexwarn
clippy::redundant_feature_nameswarn
clippy::redundant_pub_cratewarnSee unreachable_pub.
clippy::rest_pat_in_fully_bound_structswarn
clippy::same_name_methodwarn
clippy::self_named_module_fileswarn
clippy::semicolon_inside_blockdefault
clippy::semicolon_outside_blockdefault
clippy::separated_literal_suffixdefault
clippy::shadow_reusedefault
clippy::shadow_samedefault
clippy::shadow_unrelateddefault
clippy::significant_drop_in_scrutineewarn
clippy::single_char_lifetime_namesdefault
clippy::std_instead_of_allocdefault
clippy::std_instead_of_coredefault
clippy::str_to_stringdefaultTo pair with [T]::to_vec().
clippy::string_adddefault
clippy::string_lit_as_byteswarn
clippy::string_slicedefault
clippy::string_to_stringwarn
clippy::suboptimal_flopswarn
clippy::suspicious_operation_groupingswarn
clippy::suspicious_xor_used_as_powdefault
clippy::todowarn
clippy::trailing_empty_arraywarn
clippy::trait_duplication_in_boundswarn
clippy::transmute_undefined_reprwarn
clippy::trivial_regexwarn
clippy::try_errwarn
clippy::type_repetition_in_boundswarn
clippy::undocumented_unsafe_blockswarn
clippy::unimplementedwarn
clippy::unnecessary_safety_commentwarn
clippy::unnecessary_safety_docwarn
clippy::unnecessary_self_importswarn
clippy::unneeded_field_patternwarn
clippy::unreachabledefault
clippy::unseparated_literal_suffixdefault
clippy::unused_peekablewarn
clippy::unused_roundingwarn
clippy::unwrap_in_resultdefault
clippy::unwrap_useddefault
clippy::use_debugwarn
clippy::use_selfwarn
clippy::useless_let_if_seqwarn
clippy::verbose_file_readswarn
clippy::wildcard_dependencieswarn
clippy::wildcard_enum_match_armdefault

Exceptions:

LintVerdictComment

Summary

Add the following configuration to .cargo/config.toml:

[target.'cfg(feature = "cargo-clippy")']
rustflags = [
  "-Wabsolute_paths_not_starting_with_crate",
  "-Wexplicit_outlives_requirements",
  "-Wlet_underscore_drop",
  "-Wmacro_use_extern_crate",
  "-Wmeta_variable_misuse",
  "-Wmissing_abi",
  "-Wmissing_docs",
  "-Wnoop_method_call",
  "-Wpointer_structural_match",
  "-Wsingle_use_lifetimes",
  "-Wtrivial_casts",
  "-Wtrivial_numeric_casts",
  "-Wunsafe_code",
  "-Wunsafe_op_in_unsafe_fn",
  "-Wunused_crate_dependencies",
  "-Wunused_extern_crates",
  "-Wunused_import_braces",
  "-Wunused_lifetimes",
  "-Wunused_macro_rules",
  "-Wunused_qualifications",
  "-Wunused_tuple_struct_fields",
  "-Wvariant_size_differences",
  "-Wclippy::alloc_instead_of_core",
  "-Wclippy::allow_attributes_without_reason",
  "-Wclippy::as_ptr_cast_mut",
  "-Wclippy::branches_sharing_code",
  "-Wclippy::cargo_common_metadata",
  "-Wclippy::clone_on_ref_ptr",
  "-Wclippy::cognitive_complexity",
  "-Wclippy::create_dir",
  "-Wclippy::dbg_macro",
  "-Wclippy::debug_assert_with_mut_call",
  "-Wclippy::decimal_literal_representation",
  "-Wclippy::deref_by_slicing",
  "-Wclippy::derive_partial_eq_without_eq",
  "-Wclippy::empty_drop",
  "-Wclippy::empty_line_after_outer_attr",
  "-Wclippy::empty_structs_with_brackets",
  "-Wclippy::equatable_if_let",
  "-Wclippy::fallible_impl_from",
  "-Wclippy::filetype_is_file",
  "-Wclippy::float_cmp_const",
  "-Wclippy::format_push_string",
  "-Wclippy::get_unwrap",
  "-Wclippy::if_then_some_else_none",
  "-Wclippy::imprecise_flops",
  "-Wclippy::iter_on_empty_collections",
  "-Wclippy::iter_on_single_items",
  "-Wclippy::iter_with_drain",
  "-Wclippy::large_include_file",
  "-Wclippy::let_underscore_must_use",
  "-Wclippy::lossy_float_literal",
  "-Wclippy::manual_clamp",
  "-Wclippy::map_err_ignore",
  "-Wclippy::mixed_read_write_in_expression",
  "-Wclippy::multiple_inherent_impl",
  "-Wclippy::mutex_atomic",
  "-Wclippy::mutex_integer",
  "-Wclippy::needless_collect",
  "-Wclippy::negative_feature_names",
  "-Wclippy::non_send_fields_in_send_ty",
  "-Wclippy::nonstandard_macro_braces",
  "-Wclippy::option_if_let_else",
  "-Wclippy::or_fun_call",
  "-Wclippy::panic",
  "-Wclippy::panic_in_result_fn",
  "-Wclippy::partial_pub_fields",
  "-Wclippy::path_buf_push_overwrite",
  "-Wclippy::pedantic",
  "-Wclippy::print_stderr",
  "-Wclippy::print_stdout",
  "-Wclippy::rc_buffer",
  "-Wclippy::rc_mutex",
  "-Wclippy::redundant_feature_names",
  "-Wclippy::redundant_pub_crate",
  "-Wclippy::rest_pat_in_fully_bound_structs",
  "-Wclippy::same_name_method",
  "-Wclippy::self_named_module_files",
  "-Wclippy::significant_drop_in_scrutinee",
  "-Wclippy::string_lit_as_bytes",
  "-Wclippy::string_to_string",
  "-Wclippy::suboptimal_flops",
  "-Wclippy::suspicious_operation_groupings",
  "-Wclippy::todo",
  "-Wclippy::trailing_empty_array",
  "-Wclippy::trait_duplication_in_bounds",
  "-Wclippy::transmute_undefined_repr",
  "-Wclippy::trivial_regex",
  "-Wclippy::try_err",
  "-Wclippy::type_repetition_in_bounds",
  "-Wclippy::undocumented_unsafe_blocks",
  "-Wclippy::unimplemented",
  "-Wclippy::unnecessary_safety_comment",
  "-Wclippy::unnecessary_safety_doc",
  "-Wclippy::unnecessary_self_imports",
  "-Wclippy::unneeded_field_pattern",
  "-Wclippy::unused_peekable",
  "-Wclippy::unused_rounding",
  "-Wclippy::use_debug",
  "-Wclippy::use_self",
  "-Wclippy::useless_let_if_seq",
  "-Wclippy::verbose_file_reads",
  "-Wclippy::wildcard_dependencies",
]

Or add the following code to the top of lib.rs or main.rs:

#![warn(
    absolute_paths_not_starting_with_crate,
    explicit_outlives_requirements,
    let_underscore_drop,
    macro_use_extern_crate,
    meta_variable_misuse,
    missing_abi,
    missing_docs,
    noop_method_call,
    pointer_structural_match,
    single_use_lifetimes,
    trivial_casts,
    trivial_numeric_casts,
    unsafe_code,
    unsafe_op_in_unsafe_fn,
    unused_crate_dependencies,
    unused_extern_crates,
    unused_import_braces,
    unused_lifetimes,
    unused_macro_rules,
    unused_qualifications,
    unused_tuple_struct_fields,
    variant_size_differences,
    clippy::alloc_instead_of_core,
    clippy::allow_attributes_without_reason,
    clippy::as_ptr_cast_mut,
    clippy::branches_sharing_code,
    clippy::cargo_common_metadata,
    clippy::clone_on_ref_ptr,
    clippy::cognitive_complexity,
    clippy::create_dir,
    clippy::dbg_macro,
    clippy::debug_assert_with_mut_call,
    clippy::decimal_literal_representation,
    clippy::deref_by_slicing,
    clippy::derive_partial_eq_without_eq,
    clippy::empty_drop,
    clippy::empty_line_after_outer_attr,
    clippy::empty_structs_with_brackets,
    clippy::equatable_if_let,
    clippy::fallible_impl_from,
    clippy::filetype_is_file,
    clippy::float_cmp_const,
    clippy::format_push_string,
    clippy::get_unwrap,
    clippy::if_then_some_else_none,
    clippy::imprecise_flops,
    clippy::iter_on_empty_collections,
    clippy::iter_on_single_items,
    clippy::iter_with_drain,
    clippy::large_include_file,
    clippy::let_underscore_must_use,
    clippy::lossy_float_literal,
    clippy::manual_clamp,
    clippy::map_err_ignore,
    clippy::mixed_read_write_in_expression,
    clippy::multiple_inherent_impl,
    clippy::mutex_atomic,
    clippy::mutex_integer,
    clippy::needless_collect,
    clippy::negative_feature_names,
    clippy::non_send_fields_in_send_ty,
    clippy::nonstandard_macro_braces,
    clippy::option_if_let_else,
    clippy::or_fun_call,
    clippy::panic,
    clippy::panic_in_result_fn,
    clippy::partial_pub_fields,
    clippy::path_buf_push_overwrite,
    clippy::pedantic,
    clippy::print_stderr,
    clippy::print_stdout,
    clippy::rc_buffer,
    clippy::rc_mutex,
    clippy::redundant_feature_names,
    clippy::redundant_pub_crate,
    clippy::rest_pat_in_fully_bound_structs,
    clippy::same_name_method,
    clippy::self_named_module_files,
    clippy::significant_drop_in_scrutinee,
    clippy::string_lit_as_bytes,
    clippy::string_to_string,
    clippy::suboptimal_flops,
    clippy::suspicious_operation_groupings,
    clippy::todo,
    clippy::trailing_empty_array,
    clippy::trait_duplication_in_bounds,
    clippy::transmute_undefined_repr,
    clippy::trivial_regex,
    clippy::try_err,
    clippy::type_repetition_in_bounds,
    clippy::undocumented_unsafe_blocks,
    clippy::unimplemented,
    clippy::unnecessary_safety_comment,
    clippy::unnecessary_safety_doc,
    clippy::unnecessary_self_imports,
    clippy::unneeded_field_pattern,
    clippy::unused_peekable,
    clippy::unused_rounding,
    clippy::use_debug,
    clippy::use_self,
    clippy::useless_let_if_seq,
    clippy::verbose_file_reads,
    clippy::wildcard_dependencies,
)]

.clippy.toml Configuration

avoid-breaking-exported-api = false
warn-on-all-wildcard-imports = true