-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Minimal nightly-only lints #9325
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
Conversation
Hey 👋, the default lint level of a lint is set by This was the blocker I had when implementing it in Clippy. The default lint level has to be static for rustc. And there is no good way to statically check for nightly. |
Well that ruins my idea. Edit: Looks like |
That's one option to determine the channel. Though members of the release team advised against using it if I remember correctly. Could we maybe use a build script to check the nightly flag? |
I think there was also the issue that with removing lints at build time, But what I remember is that to implement nightly lints properly, we need 1st class support in rustc for nightly lints. r? @xFrednet since your a bit more in the picture here. (also correct me if I remembered something wrong) |
Attempt number two. This adds a build script which reads What was the argument against |
affdb06
to
e101222
Compare
From #8444
I suggest reading the linked zulip thread. It explains what I meant with "but the actual intended and clean way would be to use". Also #8444 and #8435 might also be interesting for you.
IDK, but rustfmt can in theory just use is_nightly_build since the config values and validation don't need to be known at compile time.
Could you maybe access is_nightly_build from the build script? That sounds like a kind of stable way :) |
Isn't |
I really don't know that 😅 Maybe ask in t-infra about that 🤔 |
One other idea would be to set the lint levels in |
Latest commit adds the changes to Changes to everywhere else still need to be done, but this gets the basic idea across. |
Latest version should be working. Nightly lints are now always set to This also has an additional Only downside I can see is the lint warning will state that the lint was enabled from the command line. This could be a confusing message to people as they never actually passed the argument. |
Hmm... I don't really like that this requires driver changes and complex lint definition macros. I thought we already came up with a plan on how to implement this in rustc to avoid all of this hackery. I'm sure this that also technically works, but I would really prefer a clean rustc solution, even if it will take a little longer to get there. |
I haven't looked at the changes, but also believe that it would be simpler to implement in rustc. The implementation itself should be pretty simple, it could be suppressed in The actual work with this implementation is finding a way that's also okay for the compiler maintainers. They mentioned in the linked Zulip that they want to avoid different behavior between nightly and beta/stable builds (especially related to tests). One option might be to just have nightly lints as allow by default on stable/beta and have an additional check that every test file in Clippy has |
The easiest way to make sure the tests work would be to have to have compile-test allow all the lints by default. I don't know how easy that would be though. The lack of lint group registration would be annoying. Allowing all style lints and then all of a sudden getting warning for one does not make for a great experience. |
The lint level is evaluated with the
The lint group registration could be adjusted on startup. This would mean on nightly, the lint is added as usual but not on stable/beta. This should be fine, since they're allow by default on stable/beta. In such a case, we should avoid Does this help, or did I misunderstand you? 🙃 |
I was talking specifically about the behaviour differences for our tests between nightly and stable builds. If compile test did the equivalent of passing
Ok. That's what I have right now. For some reason I interpreted your comment as saying avoid doing any stable/nightly differences on clippy's side. Re-reading it doesn't give me the same interpretation. |
Ahh, that's true, but I feel like we don't want to generally pass |
I don't think I've seen that happen where the solution wasn't just to add yet another allowed lint to a test. It's possible it's caught something before though. |
I've seen it a few rare times. |
It happened before multiple times. For examples, look at the rust-clippy/clippy_lints/src/methods/mod.rs Lines 2702 to 2706 in 868dba9
Those structures exist, because the lint overlapping happened. We definitely want to continue test for this for all non-allow lints. |
Hey @Jarcho, I'm closing this PR, as it seems like you're starting to focus on these changes in rustc (And I want to triage my PRs). Feel free to reopen it, if you ever want to continue this branch :) |
This uses is_nightly_build to determine if nightly-only lints should be added to their category, but makes no other changes. This means nightly-only lints are still registered and running, but they will no longer be enabled by default on beta and stable, nor will they be effected by their group name (e.g.
#![warn(clippy::pedantic)]
).This accomplishes the main goal of preventing high false-positive rates from leaking out of the nightly release while still allowing the lints to be well tested there. Changes outside clippy are also not required to make this work, which I think any other approach requires.
Any nightly-only lint can still be run on stable, and any ICE's from them will still leak through. I don't think the first one is a problem as the lint has to be specifically named. The latter is an unfortunate problem, but I don't think that's avoidable without a much larger code change.
r? @flip1995