-
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
Implement framework so that lints can be enabled in nightly only #8211
Comments
My thoughts are that option 2 or 3 are preferable, I'm leaning towards option 3 as it sounds like fun to implement. However, it would require some more work in comparison to option 2. |
I don't like option 1, because I don't want users to do anything to get nightly lints, except for using the nightly toolchain. Best case would be, if we could just prevent registering the lints. But I'm not sure if or how that's possible. Maybe we could register it for a different Just not emitting a lint is probably the easiest option, but I'm not sure if this has an performance impact. |
I thought about not registering the
This depends on the option we choose. Option one would be costly, option two would be almost free as we use the normal suppression with the allow lint level. The third option would add one if check, which should almost be free as well. |
What is the difference semantically between an "unstable" lint and a "nursery" lint? |
I think the main difference is what they represent, nursery lints are lints which are currently under development or have some false positives which should get fixed. Unstable or nightly lints should already be in the correct category with the correct lint level on nightly. The idea is that they are ready as far as we know, but might have some false positives. We also allow users to use |
Makes sense! How about on stable the lint is just not registered with any lint group. |
That would be the second suggestion and definitely the easiest 🙃 |
Option 1 looks unusable if I understand it correctly. It requires a code change in the crate being linted (which prevents it from compiling on stable) just to be able to test nightly lints. That's basically not going to happen in practice. Option 3 matches how other nightly things work, but option 2 is probably good enough for all practical purposes. There's already no guarantee lint detection won't change from version to version (either adding or removing cases), so nightly lints changing isn't an issue. If a nightly lint is explicitly enabled then you get exactly what you asked for if the lint runs on stable. Basically option 2 unless you want to put in the effort for option 3 (though it looks like it will be fairly simple). |
Alright, thank you for the feedback so far! I'm currently working on a prototype for option 3. and I'll create an implementation for 2. as well. Option 3 appears to be more hacky than I hoped, but we'll see how my mockup turns out. It might take some time until I post an update 🙃 |
So the benefit of option 3 is to disallow the lints completely on stable? Can we get the right behavior by just not registering the lints or by using |
Another option is to add something like |
For option 2 would setting |
I would like to avoid using
I'm currently trying to implement a kind of automatic mechanism to have this, but I have to figure out a nice way to handle test and so on. Otherwise, this is something which should be avoided.
Clippy stable, beta and nightly are being compiled in the rust repo without cargo. But that's the basic plan for option two. I'm also more in favor of it, the more I work on my idea for a custom suppression mechanism. |
That is fine and I agree that is probably what we want. But FWIW I think this is different from nightly features: `#![feature]` may not be used on the stable release channel If we want to allow unstable lints in the stable channel, then Option 2 seems perfect.
I don't think so because someone could |
If the lint pass was never registered the detection code would never run as rustc doesn't know anything about it. I think the intent is to not call
So pass |
That was an idea I had in case a lint implementation contains some ICEs. However, that is not super important. There might also be ways to still implement something like this. For now, I'll focus on changing the lint level and group membership 🙃 |
I think that |
This topic has been discussed in our meeting today on Zulip. I will take a bit until I can create a PR for this, as I'm currently writing my bachelor thesis. I'll still claim this issue until then 🙃 @rustbot claim |
In several discussions, we determined that this feature should be implemented in rustc directly. @Jarcho created a PR to implement this in rustc: rust-lang/rust#109063. The compiler team requested us to create a MCP first. That's the latest status I'm aware. I'll close this issue, as it was directed towards implementing this in Clippy. |
Hey, I'd like to take a stab at the second point in issue #6623: "Implement framework so that lints can be enabled in nightly only". I have three ideas how this can be implemented, with advantages and drawbacks. Here, I'm hoping to get some early feedback and maybe a few suggestions.
First some background:
CFG_RELEASE_CHANNEL
environment value. IfCFG_RELEASE_CHANNEL
is not set, Clippy is most liekly being compiled with Cargo in our respository. Therefore, nightly lints should be enabled. Additionally, we could useUnstableFeatures
to determine if unstable features are enabled at runtime.#[clippy::version]
attribute or an additional argument in thedeclare_clippy_lint
macro to indicate is a lint should only be enabled on nightly.allow
,warn
anddeny
to ensure that they don't trigger theunknown_lints
lint when they reference nightly lints while running Clippy stable. This is optional but would be ideal as we otherwise force users to always use nightly.Now these are the implementation suggestions I have:
Feature
to rustc that has to be enabled using a#![feature]
attribute to the crate. The nightly lints are only added to the lint store if the feature is enabled, the suppression will be a bit more complicated but should be possible by first checking if the lint is registered.allow
,warn
anddeny
attributes with confidence that every user has a nightly Clippy version, since features can only be enabled on nightly versionsspan_lint*
methods or later on inspan_clippy_lint
once Migrate tospan_clippy_lint
#7797 is implemented.This list might have missed some options, advantages or disadvantages, feel free to comment on this. I can create mockup implementations for one or two options to compare them 🙃
What are your thought's on this @rust-lang/clippy. Also cc: @Jarcho in case you're interested in this as well 🙃
The text was updated successfully, but these errors were encountered: