-
Notifications
You must be signed in to change notification settings - Fork 1.8k
stable clippy.toml: Create RFC #15630
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
base: master
Are you sure you want to change the base?
Conversation
|
|
d64c47e to
e5a9868
Compare
This PR creates a public 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
e5a9868 to
fb11b83
Compare
|
@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 The only thing needed apart from this would be stabilizing the configuration options themselves. Which, because of your usecase, the first ones will be |
|
Thanks for working on this!
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 (
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. |
The problem with this is passing complex values to the flag. That's why this RFC changes 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. |
|
Is there anything left? I'll nominate this and see if in today's meeting we can sort this out. @rustbot label +I-nominate |
|
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. |
This comment was marked as duplicate.
This comment was marked as duplicate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit late, but I finally got to reading this. Sorry for the long delay.
|
|
||
| Some Clippy lints can be tweaked via a configuration file commonly named `clippy.toml` or `.clippy.toml`. | ||
|
|
||
| Clippy looks for this file in the current directory and all parents up to the root of the workspace if there is one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| For crates in a workspace, the Clippy configuration files would be merged with the ones in their parent directories. | ||
| A Clippy configuration file will always overwrite one in a parent directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this contradicting? Or are you proposing different behavior between a workspace and non-workspace setups?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm proposing that for crates in a workspace, we merge clippy.tomls and for those without a workspace, we overwrite them. That could be a little confusing if not communicated well to the user, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too confusing. I would default to always overwrite or always merge and then provide a setting. I would follow the behavior of .cargo/config.toml and/or rustfmt.toml here.
clang-format has something similar with the InheritParentConfig option. By default it will overwrite, but with that set, it will be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I'll remove the logic part in the RFC and just say that we follow the .cargo/config.toml specification
| The list of available configurations along their default values is | ||
| [here](https://doc.rust-lang.org/nightly/clippy/lint_configuration.html). | ||
| You can enable unstable features via the `unstable-conf` configuration option. If this configuration is set to `true`, | ||
| Clippy will warn about unknown or renamed keys, and will allow the modification of unstable configuration options. One |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and will allow the modification of unstable configuration options
by this, do you mean that Clippy (the project) is allowed to change unstable config options? and will allow sounds like the Clippy will allow the user to modify these.
| a directory (in which it performs the known algorithm, looking for all parents up to `/`, merging them...). If | ||
| `CLIPPY_CONF_PATH` is a file, just read it as we'd do with `clippy.toml`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if a user specifies CLIPPY_CONF_PATH, that we should only search that directory and not also upwards. Not a strong opinion though.
|
|
||
| ## Stabilization process for keys | ||
|
|
||
| Each key needs to be independently stabilized, or it won't be active on configurations without `unstable-conf` enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Each key needs to be independently stabilized, or it won't be active on configurations without `unstable-conf` enabled. | |
| Each key needs to be independently stabilized, or it won't be active on configurations with `unstable-conf = false`. |
| # Drawbacks | ||
|
|
||
| - There isn't a good way to specify configuration values from the terminal, for the time being. | ||
| - In stable mode, typos and/or deprecated and/or renamed configuration keys being renamed cannot be warned against. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that not possible? 🤔
| in plain text. Here's an example. | ||
|
|
||
| ```toml | ||
| unstable-conf = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I missed it, but what's the default value for this? I agree with Manish, that it should be opt-out, so the default should be true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding CLI flags, we could copy
cargo --configand accept TOML key/value pairs under a--clippy-configor similarOutside 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
Copying @Alexendoo comment into a thread, so we don't cross-reply in the main convo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Good point! I think removal isn't really a problem. Uplifting might break something for our users. But I'd say that's something the person uplifting the lint has to take into account.
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.tomlBeing that Philipp is on vacation, I'm not sure who could review this, it's a team-wide thing anyways.
changelog:none
Rendered