-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[wip] Fix x test clippy --stage 0
#96798
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
64422f6
to
7342286
Compare
This comment has been minimized.
This comment has been minimized.
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.
Thanks for working on this.
- Keeping those toml files in sync shouldn't be too much of a hassle during the sync.
- That's fine.
Some NIT picking about PR body wording:
- Don't require
clippy_lints
to be present when running tests in rust-lang/rust. That crate is only used for dogfood lints, which aren't even run in-tree.
Should be:
- Don't require
clippy_lints
clippy_utils
to be present when running tests in rust-lang/rust. That crate is only used fordogfood lintsinternal UI tests, which aren't even run in-tree.
However, I would really like to run them in rustc to avoid major sync headaches.
@@ -39,6 +39,7 @@ filetime = "0.2" | |||
rustc-workspace-hack = "1.0" | |||
|
|||
# UI test dependencies | |||
ui-test-dependencies = { path = "ui-test-dependencies" } | |||
clippy_utils = { path = "clippy_utils" } |
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.
Does Clippy still need all of those dependencies in the top level Cargo.toml or is it enough to have them all in ui-test-dependencies
?
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.
Good callout :) I think it's enough to only have them in ui-test-dependencies? but there's a comment in compiletest that makes me wary:
// Test dependencies may need an `extern crate` here to ensure that they show up
// in the depinfo file (otherwise cargo thinks they are unused)
#[allow(unused_extern_crates)]
extern crate derive_new;
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 just tested it and with binary-dep-info
they indeed need to stay in the top-level Cargo.toml
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
# clippy_utils = { path = "../clippy_utils" } |
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 crate is required if Clippy internal lints should be tested in the Rust repo. Those are just UI tests as well and unrelated to dogfood.
Those internal UI tests are currently not run, because the internal
feature has to be enabled during testing. I have a patch to do this, because this caused headaches during the sync multiple times in the past.
That being said, I think being able to test Clippy with --stage 0
is more important for now.
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.
Got it. I don't think we can run those lints without building the compiler twice, but we could add some way to opt-in to the internal tests so that they still run in CI (maybe something with --test-args
?).
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.
Worth looking into. But nothing to deal with in this PR.
This comment has been minimized.
This comment has been minimized.
This is coming from trying to uplift stage3 compiler artifacts. I had a feeling the stage numbering for clippy was weird - I think the proper fix is to make cc #92538, https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Idea.20for.20explaining.20stages.20better/near/212230695 |
☔ The latest upstream changes (presumably #96824) made this pull request unmergeable. Please resolve the merge conflicts. |
0fa8c83
to
f90eb62
Compare
This makes a lot of changes. The basic idea is that clippy cannot depend on the sysroot it is *built* with to be the same as the sysroot it is *run* with. This assumption is hard-coded in lots of places throughout clippy, which is why the changes are so extensive. - Change clippy to use the sysroot of the run compiler (stage1, not stage0-sysroot) when running tests. This fixes an issue where clippy would try to load libraries from the beta compiler, then complain about a version mismatch. - Change clippy to be able to find host macros. Previously it assumed macros and dependencies were stored in the same target directory, which is not true for stage 0 (macros are in `release`, but other dependencies are in `release/x86_64-unknown-linux-gnu`). - Don't build rustc twice. The naive way to get dependencies into the stage1/ sysroot is to just compile everything we were doing before with a later compiler, but that takes a very long while to run. Instead: - Add a new crate in the clippy repo that has only the dependencies needed for UI tests. That allows compiling those crates without also compiling clippy and the whole compiler. - Don't require `clippy_lints` to be present when running tests in rust-lang/rust. That crate is only used for dogfood lints, which aren't even run in-tree. - Change various tests to remove usage of `rustc_*` crates. In all cases they were not testing the rustc crates themselves, they just happened to be conveniently in the sysroot. This currently breaks `--bless` because clippy_dev requires `rustc_lexer`. I hope to fix this shortly when the "build a single crate" PR lands; this PR is a WIP until then.
f90eb62
to
8dcc51c
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
☔ The latest upstream changes (presumably #98242) made this pull request unmergeable. Please resolve the merge conflicts. |
I'd say it is perfectly consistent with this image -- "stage N clippy" depends on the rustc crate and hence is using "stage N compiler artifacts". |
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this. @rustbot label: +S-inactive |
yeah that sounds good, this is blocked on #110854 anyway |
This makes a lot of changes to bootstrap, and introduces some new requirements for clippy. The basic idea is that clippy cannot depend on the sysroot it is
built with to be the same as the sysroot it is run with. This assumption is hard-coded in lots
of places throughout clippy, which is why the changes are so extensive.
release
, but other dependencies are inrelease/x86_64-unknown-linux-gnu
).clippy_utils
to be present when running tests in rust-lang/rust. That crate is only used for dogfood lints, which aren't even run in-tree.rustc_*
crates. In all cases they were not testing the rustc crates themselves, they just happened to be conveniently in the sysroot.This currently breaks
--bless
because clippy_dev requiresrustc_lexer
.I hope to fix this shortly when the "build a single crate" PR lands (#95503); this PR is a WIP until then.
I'm opening this early to get feedback, particularly from the clippy team. This introduces two new maintenance burdens on clippy:
ui-test-dependencies/Cargo.toml
has to be kept up to date. Right now this is only enforced in rust-lang/rust, but I can investigate enforcing it in rust-clippy if you think it will be a burden to only see errors on syncs.regex
,alloc
, etc) or they need to be disabled by switching onoption_env!("RUSTC_TEST_SUITE").is_some()
.Fixes #78717. Helps with #76495. Blocked on #95503 and #90244.
@rustbot label +A-rustbuild +A-clippy +S-blocked -S-waiting-on-review