-
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
Add ignore-msrv-check-for
option to incompatible_msrv
lint
#14328
Conversation
This option prevents the lint from triggering on entities that may have been feature gated by the user and thus don't need to be warned about.
bb8fb44
to
a3099d6
Compare
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.
Code looks good, but the reasoning feels a bit frail IMO... I see how this is an issue but globally allowing certain paths feels like the wrong solution to me.
1: An alternative is to just ignore anything inside a feature gate, it would surely be easy, but I'm not sure about this. It's definitely a "FP" but it is hard for me to say we should treat it as one as just ignoring them might do more harm than good. (FNs, of course)
2: It is hard for the linter to know this additional info (that the MSRV is increased with a feature gate). I feel like another thought is that it is totally reasonable to suggest adding a clippy::msrv
value alongside the cfg(feature)
if we find one, or add this info somewhere alongside the original msrv
attribute, but that might just be noise in 90% of cases or something.
Consider these two options, if they're less desirable than this then this looks ok.
|
||
#[clippy::msrv = "1.46"] | ||
fn main() { | ||
if let Some((a, b)) = "foo:bar".split_once(":") { |
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.
This should definitely include a cfg(feature)
IMO so as to show the intent of this config option. Not ignoring the check when there's zero cfg(feature)
attributes is an option too.
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 #14425 there is a case for ignoring the MSRV check without having a crate-local feature enabled.
I will think more about your suggestions, but this one seems a bit problematic to me. If I understand correctly, you are proposing to increase the MSRV used by Clippy when the feature is activated, using for example a |
That's fair for the case where we add it at the crate-level, but not if added alongside where Also I think it would make sense to special case this usage to only apply under |
This can be done already indeed without this option. The goal of this option was to avoid having to disable the One thing we could do is merge #14216 first, then wait and see if someone requests such a flag, in which case we could look again at the current PR or to alternative solutions. What do you think? I was going to reroll the dice on #14216 since it has not been reviewed after a few weeks, I'll assign it to you, feel free to reroll if you don't want to. |
I find disabling a lint and explicitly adding more info to be a different, but it would be similarly annoying. Note I still do believe the second idea (adding the |
Mind if I nominate this for the meeting tomorrow? The option is also fine but I'm still on edge if it's the only way to do this. |
Good idea! |
To be reworked, implementing ideas from today's meeting. |
Superseded by #14433 |
This option prevents the lint from triggering on entities that may have been feature gated by the user and thus don't need to be warned about.
Another use case would be when a user has enabled an unstable feature and wants to ignore the MSRV check for a given path. Such a false positive MSRV lint in Rust for Linux has been described in #14425. While we could maintain a list of every path created by unstable features, it looks easier to ignore the MSRV check for the specific functions that are used. Most of the time, users of unstable features will use a nightly compiler without specifying a MSRV, so this would not be needed.
This is particularly interesting when #14216 is merged, as its lintcheck output shows that hits are for feature-gated entities. This option will allow the crate authors not to disable the whole lint, or to
#[expect]
everywhere a feature-gated MSRV-incompatible entity is used.changelog: [
incompatible_msrv
]: add newignore-msrv-check-for
option