Clippy Configuration
Configuration for Clippy, the Rust linter.
| Type | object |
|---|---|
| File match |
clippy.toml
**/clippy.toml
.clippy.toml
**/.clippy.toml
|
| Schema URL | https://catalog.lintel.tools/schemas/rust/clippy/latest.json |
Validate with Lintel
npx @lintel/lintel check
Configuration file for Clippy, the Rust linter.
Overview
Clippy can be configured using a clippy.toml or .clippy.toml file at the project root. The configuration file is searched for in this order:
- The directory specified by
CLIPPY_CONF_DIR - The directory specified by
CARGO_MANIFEST_DIR - The current directory
Configuration uses simple variable = value mapping:
avoid-breaking-exported-api = false
disallowed-names = ["toto", "tata", "titi"]
msrv = "1.70.0"
For array options with defaults, use ".." to extend the default list rather than replacing it:
# default of disallowed-names is ["foo", "baz", "quux"]
disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"]
See the Clippy Configuration guide for full details on configuring Clippy.
All lint configuration options listed here are sourced from the Lint Configuration reference. This schema will be updated as that source page is updated.
Properties
Which crates to allow absolute paths from.
Affected lints: absolute_paths
[]
The maximum number of segments a path can have before being linted.
Affected lints: absolute_paths
Whether to accept a safety comment above the attributes for an unsafe block.
Affected lints: undocumented_unsafe_blocks
Whether to accept a safety comment above the statement containing an unsafe block.
Affected lints: undocumented_unsafe_blocks
Don't lint when comparing the result of a modulo operation to zero.
Affected lints: modulo_arithmetic
Whether dbg! should be allowed in test functions or #[cfg(test)] code.
Affected lints: dbg_macro
Whether to allow items with the same name as the containing module.
Affected lints: module_name_repetitions
Whether expect should be allowed within const blocks evaluated at compile time.
Affected lints: expect_used
Whether expect should be allowed in test functions or #[cfg(test)] code.
Affected lints: expect_used
Whether indexing and slicing should be allowed in test functions or #[cfg(test)] code.
Affected lints: indexing_slicing
Whether to allow mixed uninlined format args, e.g. format!("{} {x}", x.y).
Affected lints: uninlined_format_args
Whether to allow r#""# when r"" can be used.
Affected lints: needless_raw_string_hashes
Whether panic should be allowed in test functions or #[cfg(test)] code.
Affected lints: panic
Whether print macros (e.g. println!) should be allowed in test functions or #[cfg(test)] code.
Affected lints: print_stderr, print_stdout
Whether to allow module inception if the module is not public.
Affected lints: module_inception
List of trait paths for which renamed parameter names are allowed. Supports the ".." element to extend the default list.
Affected lints: renamed_function_params
[
"core::convert::From",
"core::convert::TryFrom",
"core::str::FromStr"
]
Whether unwrap should be allowed within const blocks evaluated at compile time.
Affected lints: unwrap_used
Whether unwrap should be allowed in test functions or #[cfg(test)] code.
Affected lints: unwrap_used
Whether useless_vec should be ignored in test functions or #[cfg(test)] code.
Affected lints: useless_vec
Additional dotfiles (files or directories starting with a dot) to allow.
Affected lints: path_ends_with_ext
[]
A list of crate names that are allowed to have multiple versions in the dependency tree.
Affected lints: multiple_crate_versions
[]
Identifiers that are allowed to be shorter than min-ident-chars-threshold. Supports the ".." element to extend the default list.
Affected lints: min_ident_chars
[
"i",
"j",
"x",
"y",
"z",
"w",
"n"
]
List of prefixes to allow when checking for module name repetitions. Supports the ".." element to extend the default list.
Affected lints: module_name_repetitions
[
"to",
"as",
"into",
"from",
"try_into",
"try_from"
]
The list of Unicode scripts allowed in identifiers. Supports the ".." element to extend the default list.
Affected lints: disallowed_script_idents
[
"Latin"
]
List of path segments allowed to have wildcard imports (e.g. prelude).
Affected lints: wildcard_imports
[]
Types to allow arithmetic operations on without linting. Supports the ".." element to extend the default list.
Affected lints: arithmetic_side_effects
[]
Pairs of types [left, right] for which binary arithmetic operations are allowed. Use "*" as a wildcard to match any type.
Affected lints: arithmetic_side_effects
[]
Types for which unary arithmetic operations (negation, !) are allowed.
Affected lints: arithmetic_side_effects
[]
The maximum allowed size (in bytes) for arrays on the stack.
Affected lints: large_const_arrays, large_stack_arrays
Suppress lints whenever the suggested fix would cause breakage for other crates.
Affected lints: box_collection, enum_variant_names, large_types_passed_by_value, linkedlist, needless_pass_by_ref_mut, option_option, owned_cow, rc_buffer, rc_mutex, redundant_allocation, ref_option, single_call_fn, trivially_copy_pass_by_ref, unnecessary_box_returns, unnecessary_wraps, unused_self, upper_case_acronyms, vec_box, wrong_self_convention
Types that may not be held across .await points.
Affected lints: await_holding_invalid_type
[]
For internal testing only. Whether to ignore the publish field in Cargo.toml.
Affected lints: cargo_common_metadata
Whether to also check MSRV compatibility in test code.
Affected lints: incompatible_msrv
Whether to suggest reordering constructor fields when some have shorthand initializers.
Affected lints: inconsistent_struct_constructor
Whether to also run the applicable lint on private items.
Affected lints: missing_errors_doc, missing_panics_doc, missing_safety_doc, unnecessary_safety_doc
The maximum cognitive complexity a function can have.
Affected lints: cognitive_complexity
Minimum number of digits in a float literal in a const context before linting.
Affected lints: excessive_precision
List of macros that are not allowed to be used. Each entry can be a path string or an object with additional metadata.
Affected lints: disallowed_macros
[]
List of methods that are not allowed to be used. Each entry can be a path string or an object with additional metadata.
Affected lints: disallowed_methods
[]
List of disallowed variable names (e.g. placeholder names). Supports the ".." element to extend the default list.
Affected lints: disallowed_names
[
"foo",
"baz",
"quux"
]
List of types that are not allowed to be used. Each entry can be a path string or an object with additional metadata.
Affected lints: disallowed_types
[]
List of identifiers that are valid in documentation without backtick quoting. Supports the ".." element to extend the default list.
Affected lints: doc_markdown
[
"KiB",
"MiB",
"GiB",
"TiB",
"PiB",
"EiB",
"MHz",
"GHz",
"THz",
"AccessKit",
"CoAP",
"CoreFoundation",
"CoreGraphics",
"CoreText",
"DevOps",
"Direct2D",
"Direct3D",
"DirectWrite",
"DirectX",
"ECMAScript",
"GPLv2",
"GPLv3",
"GitHub",
"GitLab",
"IPv4",
"IPv6",
"InfiniBand",
"RoCE",
"ClojureScript",
"CoffeeScript",
"JavaScript",
"PostScript",
"PureScript",
"TypeScript",
"PowerPC",
"WebAssembly",
"NaN",
"NaNs",
"OAuth",
"GraphQL",
"OCaml",
"OpenAL",
"OpenDNS",
"OpenGL",
"OpenMP",
"OpenSSH",
"OpenSSL",
"OpenStreetMap",
"OpenTelemetry",
"OpenType",
"WebGL",
"WebGL2",
"WebGPU",
"WebRTC",
"WebSocket",
"WebTransport",
"WebP",
"OpenExr",
"YCbCr",
"sRGB",
"TensorFlow",
"TrueType",
"iOS",
"macOS",
"FreeBSD",
"NetBSD",
"OpenBSD",
"NixOS",
"TeX",
"LaTeX",
"BibTeX",
"BibLaTeX",
"MinGW",
"CamelCase"
]
Whether to apply the raw pointer heuristic to determine if a type is Send.
Affected lints: non_send_fields_in_send_ty
Whether to recommend using implicit into_iter() for reborrowed values in for loops.
Affected lints: explicit_iter_loop
List of imports that must always be renamed. Each entry specifies a path and its required rename.
Affected lints: missing_enforced_import_renames
[]
The minimum number of enum variants for the enum variant name lints to trigger.
Affected lints: enum_variant_names
The maximum size (in bytes) of an enum variant before suggesting boxing.
Affected lints: large_enum_variant
The maximum block nesting depth allowed before linting.
Affected lints: excessive_nesting
The maximum byte size of a Future before linting.
Affected lints: large_futures
Types to treat as if they have no interior mutability. Supports the ".." element to extend the default list.
Affected lints: borrow_interior_mutable_const, declare_interior_mutable_const, ifs_same_cond, mutable_key_type
[
"bytes::Bytes"
]
The scope for checking duplicate inherent implementations.
Affected lints: multiple_inherent_impl
Error types to ignore for the result_large_err lint.
Affected lints: result_large_err
[]
The maximum size (in bytes) of the Err variant in a Result type.
Affected lints: result_large_err
Whether to lint collapsible if/else chains that contain comments between them.
Affected lints: collapsible_else_if, collapsible_if
The lower bound for linting decimal literals that are not human-readable.
Affected lints: decimal_literal_representation
Which kind of match arms to consider when linting manual_let_else.
Affected lints: manual_let_else
The maximum number of boolean parameters a function can have.
Affected lints: fn_params_excessive_bools
The maximum size (in bytes) of a file included via include_bytes! or include_str!.
Affected lints: large_include_file
The maximum number of boolean fields a struct can have.
Affected lints: struct_excessive_bools
The maximum number of elements in a suggested slice pattern.
Affected lints: index_refutable_slice
The maximum number of trait bounds before suggesting a trait alias.
Affected lints: type_repetition_in_bounds
Minimum number of characters an identifier must have. Identifiers shorter than this are linted.
Affected lints: min_ident_chars
Whether to allow underscore-prefixed fields to skip documentation.
Affected lints: missing_docs_in_private_items
Whether to only check items visible within the current crate for missing documentation.
Affected lints: missing_docs_in_private_items
Named groupings of source item kinds for the arbitrary_source_item_ordering lint. Each entry defines a group name and the item kinds it contains.
Affected lints: arbitrary_source_item_ordering
[
{
"name": "modules",
"items": [
"extern_crate",
"mod",
"foreign_mod"
]
},
{
"name": "use",
"items": [
"use"
]
},
{
"name": "macros",
"items": [
"macro"
]
},
{
"name": "global_asm",
"items": [
"global_asm"
]
},
{
"name": "UPPER_SNAKE_CASE",
"items": [
"static",
"const"
]
},
{
"name": "PascalCase",
"items": [
"ty_alias",
"enum",
"struct",
"union",
"trait",
"trait_alias",
"impl"
]
},
{
"name": "lower_snake_case",
"items": [
"fn"
]
}
]
Whether items within groupings must be ordered alphabetically. Can be "none", "all", or a specific grouping name.
Affected lints: arbitrary_source_item_ordering
The minimum supported Rust version. Clippy will take this into account when suggesting alternatives that require a newer version. Use a version string like "1.70.0". You can also omit the patch version: "1.70" equals "1.70.0".
Affected lints: allow_attributes, allow_attributes_without_reason, almost_complete_range, approx_constant, assigning_clones, borrow_as_ptr, cast_abs_to_unsigned, checked_conversions, cloned_instead_of_copied, collapsible_match, collapsible_str_replace, deprecated_cfg_attr, derivable_impls, err_expect, filter_map_next, from_over_into, if_then_some_else_none, index_refutable_slice, inefficient_to_string, io_other_error, iter_kv_map, legacy_numeric_constants, len_zero, lines_filter_map_ok, manual_abs_diff, manual_bits, manual_c_str_literals, manual_clamp, manual_div_ceil, manual_flatten, manual_hash_one, manual_is_ascii_check, manual_is_power_of_two, manual_let_else, manual_midpoint, manual_non_exhaustive, manual_option_as_slice, manual_pattern_char_comparison, manual_range_contains, manual_rem_euclid, manual_repeat_n, manual_retain, manual_slice_fill, manual_slice_size_calculation, manual_split_once, manual_str_repeat, manual_strip, manual_try_fold, map_clone, map_unwrap_or, map_with_unused_argument_over_ranges, match_like_matches_macro, mem_replace_option_with_some, mem_replace_with_default, missing_const_for_fn, needless_borrow, non_std_lazy_statics, option_as_ref_deref, or_fun_call, ptr_as_ptr, question_mark, redundant_field_names, redundant_static_lifetimes, repeat_vec_with_capacity, same_item_push, seek_from_current, to_digit_is_some, transmute_ptr_to_ref, tuple_array_conversions, type_repetition_in_bounds, unchecked_time_subtraction, uninlined_format_args, unnecessary_lazy_evaluations, unnecessary_unwrap, unnested_or_patterns, unused_trait_names, use_self, zero_ptr
Minimum size (in bytes) for a type to be passed by reference instead of by value.
Affected lints: large_types_passed_by_value
Lint behavior for pub fields with underscore-prefixed names.
Affected lints: pub_underscore_fields
Whether to suggest replacing recursive type references with Self.
Affected lints: use_self
Whether to only lint multiline blocks for semicolons inside blocks.
Affected lints: semicolon_inside_block
Whether to only lint single-line blocks for semicolons outside blocks.
Affected lints: semicolon_outside_block
The maximum number of single-character bindings a scope can have.
Affected lints: many_single_char_names
Which source item kinds to check for ordering within modules.
Affected lints: arbitrary_source_item_ordering
[
"enum",
"impl",
"module",
"struct",
"trait"
]
The maximum stack size (in bytes) a function is allowed to use.
Affected lints: large_stack_frames
Enforce specific brace styles for macro invocations. Each entry specifies a macro name and the brace character to enforce.
Affected lints: nonstandard_macro_braces
[]
The minimum number of struct fields for the struct field name lints to trigger.
Affected lints: struct_field_names
Whether to suppress restriction lints in constant code.
Affected lints: indexing_slicing
The maximum object size (in bytes) on the stack before suggesting boxing.
Affected lints: boxed_local, useless_vec
The maximum number of parameters a function can have.
Affected lints: too_many_arguments
The maximum number of lines a function body can have.
Affected lints: too_many_lines
The preferred ordering of associated items in a trait definition.
Affected lints: arbitrary_source_item_ordering
[
"const",
"type",
"fn"
]
The maximum size (in bytes) of a Copy type that can be passed by value. Defaults to target_pointer_width * 2 when unset.
Affected lints: trivially_copy_pass_by_ref
The maximum complexity score a type can have before being linted.
Affected lints: type_complexity
The byte size below which Box<T> is unnecessary and the value should be unboxed.
Affected lints: unnecessary_box_returns
Whether to lint the decimal fraction part of float literals for readability.
Affected lints: unreadable_literal
Whether to enable verbose/aggressive mode for upper-case acronym checking.
Affected lints: upper_case_acronyms
The maximum size (in bytes) of a boxed type in a Vec before suggesting Vec<T> instead.
Affected lints: vec_box
The maximum bit mask size before suggesting .trailing_zeros().
Affected lints: verbose_bit_mask
Whether to warn on all wildcard imports, including those from prelude modules.
Affected lints: wildcard_imports
Whether to warn about unsafe metavariable expansions in private macro_rules! macros.
Affected lints: macro_metavars_in_unsafe
Definitions
A disallowed item (macro, method, or type) with optional reason and replacement.
Fully qualified path of the disallowed item (e.g. std::vec::Vec::leak).
Explanation for why this item is disallowed. Shown in the lint message.
Suggested replacement to use instead. Shown in the lint message.
If true, suppress the warning when the path cannot be resolved. Useful for conditionally compiled code.
A disallowed type path with optional reason.
Fully qualified type path.
Explanation for why this type is disallowed.
An import that must be renamed when used.
Fully qualified path of the import (e.g. std::process::exit).
The required rename for this import.
Enforced brace style for a specific macro.
Macro name, either simple (e.g. vec) or fully qualified (e.g. std::vec).
The brace character to enforce for this macro.
A named grouping of source item kinds for ordering within modules.
Display name for this grouping (e.g. "modules", "PascalCase").
List of source item kinds in this group.