Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read clippy configuration normally found in clippy.toml from Cargo.toml #10890

Open
lopopolo opened this issue Jun 4, 2023 · 5 comments
Open
Labels
C-question Category: Questions

Comments

@lopopolo
Copy link

lopopolo commented Jun 4, 2023

Description

Cross-posting from:

I love seeing config converging into Cargo.toml. This will help to address some papercuts when working in workspaces with many crates.

I know it is out of scope for this tracking issue, but mentioning it here since it seems relevant to the general idea. Other first party Rust tools have lots of configuration files of their own. I'd love rustup, rustfmt, and clippy to look in Cargo.toml for the configuration that today is found in rust-toolchain.toml, rustfmt.toml, and clippy.toml.

Originally posted by @lopopolo in rust-lang/cargo#12115 (comment)

I would like to reduce the proliferation of configuration files in the root of my repositories as much as possible. Would it be possible and/or an accepted feature to read the config normally found in clippy.toml (like doc-valid-idents) from Cargo.toml?

I don't believe this requires dedicated support from the Cargo team and could be done today with tool-specific metadata, like this example for configuring docs.rs:

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

Version

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-apple-darwin
release: 1.70.0
LLVM version: 16.0.2

Additional Labels

@rustbot label +C-question

@rustbot rustbot added the C-question Category: Questions label Jun 4, 2023
@blyxyas
Copy link
Member

blyxyas commented Jun 5, 2023

Pretty interesting idea! RFC 3389 also talks about Clippy, so I see implementing this [lints.clippy] table in the future (Very possibly if/when the feature gets stabilized)

Currently, unless you hack on Clippy's source or create a script to parse [lints.clippy] and move it to the terminal / clippy.toml, we don't have any options to do this.

@jwodder
Copy link

jwodder commented Nov 16, 2023

[lints.clippy] has now been stabilized in Rust 1.74. Supporting clippy.toml config in Cargo.toml would be good for 1.75....

@aksh1618
Copy link

I went through the discussions in rust-lang/rfcs#3389, and to me it seems like the [lints.clippy] table won't be a suitable place for clippy's configuration, and I think @flip1995 says it best in one of the comments:

There is no lint configuration, only tool configuration.

Given this, should using something like tool specific metadata be considered separately from the Cargo lints support?

I would also like to only have clippy's configuration be in Cargo.toml, as:

  1. The configuration that affects lints will be closer to the lints
  2. It'll make it easier to copy over a set of linting related configuration across projects: Just copying some sections of Cargo.toml instead of having to copy over the clippy.toml file as well

@flip1995
Copy link
Member

For 2025H1 there's a project goal to stabilize the clippy.toml file to a certain extend. After that is done, we could maybe also enable Clippy configuration through [package.metadata.clippy].

@aksh1618
Copy link

(Adding link to the project goal for reference)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-question Category: Questions
Projects
None yet
Development

No branches or pull requests

6 participants