The following list shows each configuration option, along with a description, its default value, an example and lints affected.
absolute-paths-allowed-cratesWhich crates to allow absolute paths from
Default Value: []
Affected lints:
absolute-paths-max-segmentsThe maximum number of segments a path can have before being linted, anything above this will be linted.
Default Value: 2
Affected lints:
accept-comment-above-attributesWhether to accept a safety comment to be placed above the attributes for the unsafe block
Default Value: true
Affected lints:
accept-comment-above-statementWhether to accept a safety comment to be placed above the statement containing the unsafe block
Default Value: true
Affected lints:
allow-comparison-to-zeroDon't lint when comparing the result of a modulo operation to zero.
Default Value: true
Affected lints:
allow-dbg-in-testsWhether dbg! should be allowed in test functions or #[cfg(test)]
Default Value: false
Affected lints:
allow-exact-repetitionsWhether an item should be allowed to have the same name as its containing module
Default Value: true
Affected lints:
allow-expect-in-constsWhether expect should be allowed in code always evaluated at compile time
Default Value: true
Affected lints:
allow-expect-in-testsWhether expect should be allowed in test functions or #[cfg(test)]
Default Value: false
Affected lints:
allow-indexing-slicing-in-testsWhether indexing_slicing should be allowed in test functions or #[cfg(test)]
Default Value: false
Affected lints:
allow-mixed-uninlined-format-argsWhether to allow mixed uninlined format args, e.g. format!("{} {}", a, foo.bar)
Default Value: true
Affected lints:
allow-one-hash-in-raw-stringsWhether to allow r#""# when r"" can be used
Default Value: false
Affected lints:
allow-panic-in-testsWhether panic should be allowed in test functions or #[cfg(test)]
Default Value: false
Affected lints:
allow-print-in-testsWhether print macros (ex. println!) should be allowed in test functions or #[cfg(test)]
Default Value: false
Affected lints:
allow-private-module-inceptionWhether to allow module inception if it's not public.
Default Value: false
Affected lints:
allow-renamed-params-forList of trait paths to ignore when checking renamed function parameters.
allow-renamed-params-for = [ "std::convert::From" ]
From, TryFrom, FromStr".." can be used as part of the list to indicate that the configured values should be appended to the default configuration of Clippy. By default, any configuration will replace the default value.Default Value: ["core::convert::From", "core::convert::TryFrom", "core::str::FromStr"]
Affected lints:
allow-unwrap-in-constsWhether unwrap should be allowed in code always evaluated at compile time
Default Value: true
Affected lints:
allow-unwrap-in-testsWhether unwrap should be allowed in test functions or #[cfg(test)]
Default Value: false
Affected lints:
allow-useless-vec-in-testsWhether useless_vec should ignore test functions or #[cfg(test)]
Default Value: false
Affected lints:
allowed-dotfilesAdditional dotfiles (files or directories starting with a dot) to allow
Default Value: []
Affected lints:
allowed-duplicate-cratesA list of crate names to allow duplicates of
Default Value: []
Affected lints:
allowed-idents-below-min-charsAllowed names below the minimum allowed characters. The value ".." can be used as part of the list to indicate, that the configured values should be appended to the default configuration of Clippy. By default, any configuration will replace the default value.
Default Value: ["i", "j", "x", "y", "z", "w", "n"]
Affected lints:
allowed-prefixesList of prefixes to allow when determining whether an item‘s name ends with the module’s name. If the rest of an item‘s name is an allowed prefix (e.g. item ToFoo or to_foo in module foo), then don’t emit a warning.
allowed-prefixes = [ "to", "from" ]
to, as, into, from, try_into and try_fromtry_into is included, TryInto will also be included)".." as part of the list to indicate that the configured values should be appended to the default configuration of Clippy. By default, any configuration will replace the default valueDefault Value: ["to", "as", "into", "from", "try_into", "try_from"]
Affected lints:
allowed-scriptsThe list of unicode scripts allowed to be used in the scope.
Default Value: ["Latin"]
Affected lints:
allowed-wildcard-importsList of path segments allowed to have wildcard imports.
allowed-wildcard-imports = [ "utils", "common" ]
warn_on_all_wildcard_imports = true.Default Value: []
Affected lints:
arithmetic-side-effects-allowedSuppress checking of the passed type names in all types of operations.
If a specific operation is desired, consider using arithmetic_side_effects_allowed_binary or arithmetic_side_effects_allowed_unary instead.
arithmetic-side-effects-allowed = ["SomeType", "AnotherType"]
A type, say SomeType, listed in this configuration has the same behavior of ["SomeType" , "*"], ["*", "SomeType"] in arithmetic_side_effects_allowed_binary.
Default Value: []
Affected lints:
arithmetic-side-effects-allowed-binarySuppress checking of the passed type pair names in binary operations like addition or multiplication.
Supports the “*” wildcard to indicate that a certain type won't trigger the lint regardless of the involved counterpart. For example, ["SomeType", "*"] or ["*", "AnotherType"].
Pairs are asymmetric, which means that ["SomeType", "AnotherType"] is not the same as ["AnotherType", "SomeType"].
arithmetic-side-effects-allowed-binary = [["SomeType" , "f32"], ["AnotherType", "*"]]
Default Value: []
Affected lints:
arithmetic-side-effects-allowed-unarySuppress checking of the passed type names in unary operations like “negation” (-).
arithmetic-side-effects-allowed-unary = ["SomeType", "AnotherType"]
Default Value: []
Affected lints:
array-size-thresholdThe maximum allowed size for arrays on the stack
Default Value: 16384
Affected lints:
avoid-breaking-exported-apiSuppress lints whenever the suggested change would cause breakage for other crates.
Default Value: true
Affected lints:
box_collectionenum_variant_nameslarge_types_passed_by_valuelinkedlistneedless_pass_by_ref_mutoption_optionowned_cowrc_bufferrc_mutexredundant_allocationref_optionsingle_call_fntrivially_copy_pass_by_refunnecessary_box_returnsunnecessary_wrapsunused_selfupper_case_acronymsvec_boxwrong_self_conventionawait-holding-invalid-typesThe list of types which may not be held across an await point.
Default Value: []
Affected lints:
cargo-ignore-publishFor internal testing only, ignores the current publish settings in the Cargo manifest.
Default Value: false
Affected lints:
check-incompatible-msrv-in-testsWhether to check MSRV compatibility in #[test] and #[cfg(test)] code.
Default Value: false
Affected lints:
check-inconsistent-struct-field-initializersWhether to suggest reordering constructor fields when initializers are present.
Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the suggested code would compile, it can change semantics if the initializer expressions have side effects. The following example from rust-clippy#11846 shows how the suggestion can run into borrow check errors:
struct MyStruct { vector: Vec<u32>, length: usize } fn main() { let vector = vec![1,2,3]; MyStruct { length: vector.len(), vector}; }
Default Value: false
Affected lints:
check-private-itemsWhether to also run the listed lints on private items.
Default Value: false
Affected lints:
cognitive-complexity-thresholdThe maximum cognitive complexity a function can have
Default Value: 25
Affected lints:
const-literal-digits-thresholdThe minimum digits a const float literal must have to supress the excessive_precicion lint
Default Value: 30
Affected lints:
disallowed-macrosThe list of disallowed macros, written as fully qualified paths.
Fields:
path (required): the fully qualified path to the macro that should be disallowedreason (optional): explanation why this macro is disallowedreplacement (optional): suggested alternative macroallow-invalid (optional, false by default): when set to true, it will ignore this entry if the path doesn't exist, instead of emitting an errorDefault Value: []
Affected lints:
disallowed-methodsThe list of disallowed methods, written as fully qualified paths.
Fields:
path (required): the fully qualified path to the method that should be disallowedreason (optional): explanation why this method is disallowedreplacement (optional): suggested alternative methodallow-invalid (optional, false by default): when set to true, it will ignore this entry if the path doesn't exist, instead of emitting an errorDefault Value: []
Affected lints:
disallowed-namesThe list of disallowed names to lint about. NB: bar is not here since it has legitimate uses. The value ".." can be used as part of the list to indicate that the configured values should be appended to the default configuration of Clippy. By default, any configuration will replace the default value.
Default Value: ["foo", "baz", "quux"]
Affected lints:
disallowed-typesThe list of disallowed types, written as fully qualified paths.
Fields:
path (required): the fully qualified path to the type that should be disallowedreason (optional): explanation why this type is disallowedreplacement (optional): suggested alternative typeallow-invalid (optional, false by default): when set to true, it will ignore this entry if the path doesn't exist, instead of emitting an errorDefault Value: []
Affected lints:
doc-valid-identsThe list of words this lint should not consider as identifiers needing ticks. The value ".." can be used as part of the list to indicate, that the configured values should be appended to the default configuration of Clippy. By default, any configuration will replace the default value. For example:
doc-valid-idents = ["ClipPy"] would replace the default list with ["ClipPy"].doc-valid-idents = ["ClipPy", ".."] would append ClipPy to the default list.Default Value: ["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"]
Affected lints:
enable-raw-pointer-heuristic-for-sendWhether to apply the raw pointer heuristic to determine if a type is Send.
Default Value: true
Affected lints:
enforce-iter-loop-reborrowWhether to recommend using implicit into iter for reborrowed values.
let mut vec = vec![1, 2, 3]; let rmvec = &mut vec; for _ in rmvec.iter() {} for _ in rmvec.iter_mut() {}
Use instead:
let mut vec = vec![1, 2, 3]; let rmvec = &mut vec; for _ in &*rmvec {} for _ in &mut *rmvec {}
Default Value: false
Affected lints:
enforced-import-renamesThe list of imports to always rename, a fully qualified path followed by the rename.
Default Value: []
Affected lints:
enum-variant-name-thresholdThe minimum number of enum variants for the lints about variant names to trigger
Default Value: 3
Affected lints:
enum-variant-size-thresholdThe maximum size of an enum's variant to avoid box suggestion
Default Value: 200
Affected lints:
excessive-nesting-thresholdThe maximum amount of nesting a block can reside in
Default Value: 0
Affected lints:
future-size-thresholdThe maximum byte size a Future can have, before it triggers the clippy::large_futures lint
Default Value: 16384
Affected lints:
ignore-interior-mutabilityA list of paths to types that should be treated as if they do not contain interior mutability
Default Value: ["bytes::Bytes"]
Affected lints:
inherent-impl-lint-scopeSets the scope (“crate”, “file”, or “module”) in which duplicate inherent impl blocks for the same type are linted.
Default Value: "crate"
Affected lints:
large-error-ignoredA list of paths to types that should be ignored as overly large Err-variants in a Result returned from a function
Default Value: []
Affected lints:
large-error-thresholdThe maximum size of the Err-variant in a Result returned from a function
Default Value: 128
Affected lints:
lint-commented-codeWhether collapsible if and else if chains are linted if they contain comments inside the parts that would be collapsed.
Default Value: false
Affected lints:
literal-representation-thresholdThe lower bound for linting decimal literals
Default Value: 16384
Affected lints:
matches-for-let-elseWhether the matches should be considered by the lint, and whether there should be filtering for common types.
Default Value: "WellKnownTypes"
Affected lints:
max-fn-params-boolsThe maximum number of bool parameters a function can have
Default Value: 3
Affected lints:
max-include-file-sizeThe maximum size of a file included via include_bytes!() or include_str!(), in bytes
Default Value: 1000000
Affected lints:
max-struct-boolsThe maximum number of bool fields a struct can have
Default Value: 3
Affected lints:
max-suggested-slice-pattern-lengthWhen Clippy suggests using a slice pattern, this is the maximum number of elements allowed in the slice pattern that is suggested. If more elements are necessary, the lint is suppressed. For example, [_, _, _, e, ..] is a slice pattern with 4 elements.
Default Value: 3
Affected lints:
max-trait-boundsThe maximum number of bounds a trait can have to be linted
Default Value: 3
Affected lints:
min-ident-chars-thresholdMinimum chars an ident can have, anything below or equal to this will be linted.
Default Value: 1
Affected lints:
missing-docs-allow-unusedWhether to allow fields starting with an underscore to skip documentation requirements
Default Value: false
Affected lints:
missing-docs-in-crate-itemsWhether to only check for missing documentation in items visible within the current crate. For example, pub(crate) items.
Default Value: false
Affected lints:
module-item-order-groupingsThe named groupings of different source item kinds within modules.
Default Value: [["modules", ["extern_crate", "mod", "foreign_mod"]], ["use", ["use"]], ["macros", ["macro"]], ["global_asm", ["global_asm"]], ["UPPER_SNAKE_CASE", ["static", "const"]], ["PascalCase", ["ty_alias", "enum", "struct", "union", "trait", "trait_alias", "impl"]], ["lower_snake_case", ["fn"]]]
Affected lints:
module-items-ordered-within-groupingsWhether the items within module groups should be ordered alphabetically or not.
This option can be configured to “all”, “none”, or a list of specific grouping names that should be checked (e.g. only “enums”).
Default Value: "none"
Affected lints:
msrvThe minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml
Default Value: current version
Affected lints:
allow_attributesallow_attributes_without_reasonalmost_complete_rangeapprox_constantassigning_clonesborrow_as_ptrcast_abs_to_unsignedchecked_conversionscloned_instead_of_copiedcollapsible_matchcollapsible_str_replacedeprecated_cfg_attrderivable_implserr_expectfilter_map_nextfrom_over_intoif_then_some_else_noneindex_refutable_sliceinefficient_to_stringio_other_erroriter_kv_maplegacy_numeric_constantslen_zerolines_filter_map_okmanual_abs_diffmanual_bitsmanual_c_str_literalsmanual_clampmanual_div_ceilmanual_flattenmanual_hash_onemanual_is_ascii_checkmanual_is_power_of_twomanual_let_elsemanual_midpointmanual_non_exhaustivemanual_option_as_slicemanual_pattern_char_comparisonmanual_range_containsmanual_rem_euclidmanual_repeat_nmanual_retainmanual_slice_fillmanual_slice_size_calculationmanual_split_oncemanual_str_repeatmanual_stripmanual_try_foldmap_clonemap_unwrap_ormap_with_unused_argument_over_rangesmatch_like_matches_macromem_replace_option_with_somemem_replace_with_defaultmissing_const_for_fnneedless_borrownon_std_lazy_staticsoption_as_ref_derefor_fun_callptr_as_ptrquestion_markredundant_field_namesredundant_static_lifetimesrepeat_vec_with_capacitysame_item_pushseek_from_currentto_digit_is_sometransmute_ptr_to_reftuple_array_conversionstype_repetition_in_boundsunchecked_time_subtractionuninlined_format_argsunnecessary_lazy_evaluationsunnecessary_unwrapunnested_or_patternsunused_trait_namesuse_selfzero_ptrpass-by-value-size-limitThe minimum size (in bytes) to consider a type for passing by reference instead of by value.
Default Value: 256
Affected lints:
pub-underscore-fields-behaviorLint “public” fields in a struct that are prefixed with an underscore based on their exported visibility, or whether they are marked as “pub”.
Default Value: "PubliclyExported"
Affected lints:
recursive-self-in-type-definitionsWhether the type itself in a struct or enum should be replaced with Self when encountering recursive types.
Default Value: true
Affected lints:
semicolon-inside-block-ignore-singlelineWhether to lint only if it's multiline.
Default Value: false
Affected lints:
semicolon-outside-block-ignore-multilineWhether to lint only if it's singleline.
Default Value: false
Affected lints:
single-char-binding-names-thresholdThe maximum number of single char bindings a scope may have
Default Value: 4
Affected lints:
source-item-orderingWhich kind of elements should be ordered internally, possible values being enum, impl, module, struct, trait.
Default Value: ["enum", "impl", "module", "struct", "trait"]
Affected lints:
stack-size-thresholdThe maximum allowed stack size for functions in bytes
Default Value: 512000
Affected lints:
standard-macro-bracesEnforce the named macros always use the braces specified.
A MacroMatcher can be added like so { name = "macro_name", brace = "(" }. If the macro could be used with a full path two MacroMatchers have to be added one with the full path crate_name::macro_name and one with just the macro name.
Default Value: []
Affected lints:
struct-field-name-thresholdThe minimum number of struct fields for the lints about field names to trigger
Default Value: 3
Affected lints:
suppress-restriction-lint-in-constWhether to suppress a restriction lint in constant code. In same cases the restructured operation might not be unavoidable, as the suggested counterparts are unavailable in constant code. This configuration will cause restriction lints to trigger even if no suggestion can be made.
Default Value: false
Affected lints:
too-large-for-stackThe maximum size of objects (in bytes) that will be linted. Larger objects are ok on the heap
Default Value: 200
Affected lints:
too-many-arguments-thresholdThe maximum number of argument a function or method can have
Default Value: 7
Affected lints:
too-many-lines-thresholdThe maximum number of lines a function or method can have
Default Value: 100
Affected lints:
trait-assoc-item-kinds-orderThe order of associated items in traits.
Default Value: ["const", "type", "fn"]
Affected lints:
trivial-copy-size-limitThe maximum size (in bytes) to consider a Copy type for passing by value instead of by reference.
Default Value: target_pointer_width
Affected lints:
type-complexity-thresholdThe maximum complexity a type can have
Default Value: 250
Affected lints:
unnecessary-box-sizeThe byte size a T in Box<T> can have, below which it triggers the clippy::unnecessary_box lint
Default Value: 128
Affected lints:
unreadable-literal-lint-fractionsShould the fraction of a decimal be linted to include separators.
Default Value: true
Affected lints:
upper-case-acronyms-aggressiveEnables verbose mode. Triggers if there is more than one uppercase char next to each other
Default Value: false
Affected lints:
vec-box-size-thresholdThe size of the boxed type in bytes, where boxing in a Vec is allowed
Default Value: 4096
Affected lints:
verbose-bit-mask-thresholdThe maximum allowed size of a bit mask before suggesting to use ‘trailing_zeros’
Default Value: 1
Affected lints:
warn-on-all-wildcard-importsWhether to emit warnings on all wildcard imports, including those from prelude, from super in tests, or for pub use reexports.
Default Value: false
Affected lints:
warn-unsafe-macro-metavars-in-private-macrosWhether to also emit warnings for unsafe blocks with metavariable expansions in private macros.
Default Value: false
Affected lints: