Skip to content

Allow all lints to be configured via clippy.toml #15128

@amab8901

Description

@amab8901

Description

I have a long list of lints in Cargo.toml. But moving them to clippy.toml deactivates them. Would be nice to have it moved into clippy.toml which I place inside .cargo folder (along with other configs like deny.toml, audit.toml, rustfmt.toml) to keep the Cargo.toml file clean and focused on dependencies.

Here is my clippy config in Cargo.toml:

[lints.clippy]
let_and_return = "allow"
similar_names = "allow"
too_many_arguments = "allow"
missing_errors_doc = "allow"
pub_with_shorthand = "allow"
missing_docs_in_private_items = "allow"
field_scoped_visibility_modifiers = "allow"
arbitrary_source_item_ordering = "warn"
self_named_module_files = "allow"
single_char_lifetime_names = "allow"
single_call_fn = "allow"
allow_attributes_without_reason = "allow"
unused_trait_names = "allow"
blanket_clippy_restriction_lints = "allow"
allow_attributes = "allow"
decimal_literal_representation = "allow"
implicit_return = "allow"
question_mark_used = "allow"
multiple_inherent_impl = "allow"
needless_pass_by_ref_mut = "warn"
shadow_reuse = "warn"
shadow_unrelated = "allow"
pattern_type_mismatch = "allow"
clone_on_ref_ptr = "allow"
print_stdout = "allow"
std_instead_of_core = "allow"
std_instead_of_alloc = "allow"
missing_inline_in_public_items = "allow"
integer_division_remainder_used = "allow"
absolute_paths = "allow"
exit = "allow"
arithmetic_side_effects = "allow"
string_to_string = "warn"
infinite_loop = "allow"
wildcard_enum_match_arm = "allow"
str_to_string = "warn"
let_underscore_must_use = "warn"
unwrap_used = "allow"
as_conversions = "warn"
default_numeric_fallback = "allow"
else_if_without_else = "allow"
min_ident_chars = "warn"
separated_literal_suffix = "allow"
unseparated_literal_suffix = "warn"
verbose_file_reads = "allow"
needless_raw_strings = "warn"
missing_trait_methods = "allow"
integer_division = "allow"
empty_structs_with_brackets = "warn"
unneeded_field_pattern = "warn"
renamed_function_params = "allow"
indexing_slicing = "warn"
print_stderr = "allow"
use_debug = "allow"
let_underscore_untyped = "warn"
unreachable = "warn"
string_add = "allow"
big_endian_bytes = "allow"
float_arithmetic = "allow"
semicolon_outside_block = "allow"
panic_in_result_fn = "warn"
map_with_unused_argument_over_ranges = "warn"
iter_over_hash_type = "allow"
redundant_type_annotations = "warn"
shadow_same = "warn"
get_unwrap = "warn"
non_ascii_literal = "allow"
if_then_some_else_none = "warn"
undocumented_unsafe_blocks = "allow"
panic = "allow"
pathbuf_init_then_push = "warn"
modulo_arithmetic = "allow"
string_slice = "allow"
redundant_pub_crate = "allow"
option_if_let_else = "allow"
use_self = "warn"
missing_const_for_fn = "warn"
significant_drop_tightening = "warn"
iter_on_single_items = "allow"
or_fun_call = "warn"
redundant_clone = "warn"
branches_sharing_code = "warn"
tuple_array_conversions = "allow"
literal_string_with_formatting_args = "warn"
case_sensitive_file_extension_comparisons = "allow"

pedantic = { level = "warn", priority = -1 }
restriction = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }

Version

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1

Additional Labels

No response

Activity

added
A-uiArea: Clippy interface, usage and configuration
on Jun 25, 2025
odysa

odysa commented on Jun 26, 2025

@odysa
Contributor

Can I work on this?

  • Read configs from clippy.toml, merge with configs in cargo.toml
  • Add documentation
odysa

odysa commented on Jun 26, 2025

@odysa
Contributor
Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`, which is searched for in:
1. The directory specified by the `CLIPPY_CONF_DIR` environment variable, or
2. The directory specified by the
[CARGO_MANIFEST_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html) environment variable, or
3. The current directory.

I checked the doc, we just need to search .cargo/?

added a commit that references this issue on Jun 27, 2025
736f652
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-uiArea: Clippy interface, usage and configuration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @samueltardieu@odysa@amab8901

      Issue actions

        Allow all lints to be configured via `clippy.toml` · Issue #15128 · rust-lang/rust-clippy