rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

stable clippy.toml: Create RFC

Open blyxyas opened this issue 4 months ago • 8 comments

This PR creates an RFC for how clippy.toml should be handled. I made some improvements to some parts of the system. These are better to get fixed today than to wait until someone has a problem with them and then have to make a breaking change.

Based on Philipp's RFC. This would be the first stage of 3 to completely stabilize clippy.toml

Being that Philipp is on vacation, I'm not sure who could review this, it's a team-wide thing anyways.

changelog:none

Rendered

blyxyas avatar Sep 07 '25 16:09 blyxyas

flip1995 is not on the review rotation at the moment. They may take a while to respond.

rustbot avatar Sep 07 '25 16:09 rustbot

r? @flip1995

rustbot has assigned @flip1995. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Sep 07 '25 16:09 rustbot

@ojeda Is this more or less what you need?

The RFC stabilizes the existence of the Clippy configuration file, the algorithm to find it, the existence of CLIPPY_CONF_DIR and its behaviour, the existence of a new CLIPPY_CONF_PATH (which will be the preferred way to pass configuration into Clippy, but CLIPPY_CONF_DIR will not be removed anytime soon), and the format of the configuration itself as a subset of TOML.

The only thing needed apart from this would be stabilizing the configuration options themselves. Which, because of your usecase, the first ones will be msrv, check-private-items, disallowed-macros and doc-valid-idents.

blyxyas avatar Sep 07 '25 18:09 blyxyas

Thanks for working on this!

The only thing needed apart from this would be stabilizing the configuration options themselves. Which, because of your usecase, the first ones will be msrv, check-private-items, disallowed-macros and doc-valid-idents.

That would be great.

It may be good to mention in the RFC what would be the "stable mode" -- IIUC it would fail on unknown keys (like Clippy today), but it would not allow to use unstable keys (unlike Clippy today). Is that correct?

If so, then does that mean that unless all those options (msrv etc.) are stabilized before the default behavior changes, we would need to have 2 files to be able to make it work with old and new Clippy?

There isn't a good way to specify configuration values from the terminal, for the time being.

If Clippy plans to support that eventually, then an alternative would be to not stabilize the file and go for flags directly -- for us it would make it easier to pass flags to Clippy depending e.g. on the version.

But, of course, that would open again the questions about how to pass all what the TOML allows for non-trivial keys. IIRC we discussed it in Zulip a while ago.

ojeda avatar Sep 07 '25 21:09 ojeda

If Clippy plans to support that eventually, then an alternative would be to not stabilize the file and go for flags directly -- for us it would make it easier to pass flags to Clippy depending e.g. on the version.

The problem with this is passing complex values to the flag. That's why this RFC changes CLIPPY_CONF_DIR into CLIPPY_CONF_PATH, allowing for having several configuration files depending on version or whatever metric you want to use.

I can see that this approach has some ergonomic issues, but it's not that different than having to maintain different CLI flags depending on version.

blyxyas avatar Sep 21 '25 15:09 blyxyas

Is there anything left? I'll nominate this and see if in today's meeting we can sort this out.

@rustbot label +I-nominate

blyxyas avatar Nov 24 '25 23:11 blyxyas

Error: Unknown labels: I-nominate

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

rustbot avatar Nov 24 '25 23:11 rustbot

Regarding CLI flags, we could copy cargo --config and accept TOML key/value pairs under a --clippy-config or similar

Outside of that, what exactly are we promising here by making a configuration value stable? If it can never be removed that is quite a commitment, it's possible the lint it applies to is removed from clippy in a future change for example e.g. by an uplift into rustc


Moderator note: please reply in thread: https://github.com/rust-lang/rust-clippy/pull/15630#discussion_r2577968743

Alexendoo avatar Nov 27 '25 21:11 Alexendoo