-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Create lint passes using Conf
#13088
Conversation
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 dependence on the config being a static reference is also added
Wasn't that that case already anyway, as the register_lints
function already took the Conf
as a 'static
reference?
I really like those changes, thank you! Only one small comment.
pub fn new(conf: &'static Conf) -> Self { | ||
Self { | ||
too_large_for_stack: conf.too_large_for_stack, | ||
msrv: conf.msrv.clone(), |
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 MSRV cloned, while everything else that is not Copy
is referenced?
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 assume it's because MSRV is sometimes mutated during linting when visiting #[clippy::msrv]
, while other configurations are not
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.
Might be a nice use case for Cow<'static, Msrv>
since it'll avoid clones if code never uses #[clippy::msrv]
but not sure if that's overdoing it
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 was taken as 'static
, but it wasn't needed.
The config type should really be Option<RustcVersion>
. I don't really know why Msrv
exists as a type at all.
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.
If you mean we should always be using Option<RustcVersion>
instead of Msrv
(a stack of RustcVersion
s), then I don't see how nested #[clippy::msrv]
could work (or even a single #[clippy::msrv]
with a clippy.toml that also defines an msrv).
If a lint pass updates and overwrites its Option<RustcVersion>
because of a #[clippy::msrv]
then surely it loses the previous, enclosing msrv?
(unless you're implying that it's weird to have nested msrvs to begin with)
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.
The type stored in the config should be Option<...>
. The Msrv
should just be Vec<...>
rather than it's own type.
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.
Ah, I see. Yeah, having Msrv
in the config doesn't make much sense. The type exists, because there are some convenience functions implemented on it. I thought this was nicer back then. Not married to it though, if you want to change this.
But let's not block this PR on this.
@bors r+ |
Create lint passes using `Conf` This slightly reduces the amount of code changes needed to add a config to a lint and makes things makes things more consistent between passes. A dependence on the config being a static reference is also added. This would only ever be a problem if multiple crates end up compiled in a single process. Other changes include: * Removing useless `#[derive(..)]`s * Removing `#[must_use]` on lint pass constructors. * Unified the parsing of the `DisallowedPath` struct in lint passes. * Update `disallowed_types` and `await_holding_invalid` messages to be consistent with other disallowed lints. * Remove the `(from clippy.toml)` message. I plan on having all the configured lints point to point to a span in `clippy.toml` which will be more useful. changelog: none
💔 Test failed - checks-action_test |
Please run |
* Construct lint passes by taking `Conf` by reference. * Use `HashSet` configs in less places * Move some `check_crate` code into the pass constructor when possible.
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This slightly reduces the amount of code changes needed to add a config to a lint and makes things makes things more consistent between passes. A dependence on the config being a static reference is also added. This would only ever be a problem if multiple crates end up compiled in a single process.
Other changes include:
#[derive(..)]
s#[must_use]
on lint pass constructors.DisallowedPath
struct in lint passes.disallowed_types
andawait_holding_invalid
messages to be consistent with other disallowed lints.(from clippy.toml)
message. I plan on having all the configured lints point to point to a span inclippy.toml
which will be more useful.changelog: none