Skip to content

clippy: make tests work in stage 1 #144027

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

Merged
merged 1 commit into from
Jul 21, 2025
Merged

clippy: make tests work in stage 1 #144027

merged 1 commit into from
Jul 21, 2025

Conversation

RalfJung
Copy link
Member

This finally fixes #78717 :)

Similar to what Miri already does, the clippy test step needs to carefully consider which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using cargo-miri for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but rust-lang/cargo#4423 makes this quite hard to do. See the long comment in src/tools/clippy/tests/compile-test.rs for details.

Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense.

Cc @flip1995 @Kobzol

@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team. labels Jul 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

// set `--sysroot`, so we need to use bootstrap's rustc wrapper. That wrapper
// however has some staging logic that is hurting us here, so to work around
// that we set both the "real" and "staging" rustc to TEST_RUSTC, including the
// associated library paths.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to use a different approach here... somehow, aux builds are working for clippy tests. It seems to be using clippy itself as the compiler for that, and that's somehow okay? So, we could try to do the same here, instead of all this TEST_RUSTC stuff. (That would also be closer to what Miri does.)

But TBH I found something that works so I am not overly inclined to debug a different approach. ;)

@Kobzol
Copy link
Member

Kobzol commented Jul 17, 2025

FWIW, I have a WIP branch (there are so many stacked changes to bootstrap that I'm doing rn that it takes a while to unload) where I refactor the building of tools, so that the correct compiler should always be chosen, and we don't need to do this careful dance for each tool and bootstrap Step separately. Essentially we'd invert the compiler "flow" in the tool, so that we pass it the build compiler instead of figuring it out from the tool, and also hopefully we'll be able to get rid of the implicit rmeta/rlib copy into the build compiler's sysroot and make that explicit.

Anyway, I'm fine with this specific fix if it helps the stage 1 Clippy tests in the meantime (it seems like there are some other blockers in the tests themselves, which can be resolved in parallel), just wanted to note that hopefully soonish this will all be unified away so that we always do The Right Thing™.

@Mark-Simulacrum
Copy link
Member

@bors r+ rollup=iffy

@bors
Copy link
Collaborator

bors commented Jul 19, 2025

📌 Commit a70171b has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 19, 2025
bors added a commit that referenced this pull request Jul 20, 2025
clippy: make tests work in stage 1

This finally fixes #78717 :)

Similar to what Miri already does, the clippy test step needs to carefully consider  which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using `cargo-miri` for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but rust-lang/cargo#4423 makes this quite hard to do. See the long comment in `src/tools/clippy/tests/compile-test.rs` for details.

Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense.

Cc `@flip1995` `@Kobzol`
@bors
Copy link
Collaborator

bors commented Jul 20, 2025

⌛ Testing commit a70171b with merge 6fc5806...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 20, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 20, 2025
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 21, 2025
@bors
Copy link
Collaborator

bors commented Jul 21, 2025

⌛ Testing commit 192efbb with merge 75de077...

bors added a commit that referenced this pull request Jul 21, 2025
clippy: make tests work in stage 1

This finally fixes #78717 :)

Similar to what Miri already does, the clippy test step needs to carefully consider  which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using `cargo-miri` for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but rust-lang/cargo#4423 makes this quite hard to do. See the long comment in `src/tools/clippy/tests/compile-test.rs` for details.

Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense.

Cc `@flip1995` `@Kobzol`
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
ecbb912e05ac: Pushed
3cc982388b71: Pushed
d0b5838df787: Pushed
d10530e137ac: Pushed
Put "https://ghcr.io/v2/rust-lang/rust-ci/manifests/4ef84ab3b8a59556ac09337f9862a9844bfdfe25dfeff8792afdf568f1697d3819e6cfc0ed7069216c6f4229b9812f4c5544fa54c7a6e6d57bef45de3f3e3a8f": net/http: TLS handshake timeout
##[error]Process completed with exit code 1.
Post job cleanup.

@bors
Copy link
Collaborator

bors commented Jul 21, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 21, 2025
@Kobzol
Copy link
Member

Kobzol commented Jul 21, 2025

@bors retry spurious network error

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 21, 2025
bors added a commit that referenced this pull request Jul 21, 2025
clippy: make tests work in stage 1

This finally fixes #78717 :)

Similar to what Miri already does, the clippy test step needs to carefully consider  which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using `cargo-miri` for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but rust-lang/cargo#4423 makes this quite hard to do. See the long comment in `src/tools/clippy/tests/compile-test.rs` for details.

Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense.

Cc `@flip1995` `@Kobzol`
@bors
Copy link
Collaborator

bors commented Jul 21, 2025

⌛ Testing commit 192efbb with merge c97633f...

@rust-log-analyzer
Copy link
Collaborator

The job test-various failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:

---- [ui] tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs stdout ----

thread '[ui] tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs' panicked at src/tools/compiletest/src/runtest.rs:1951:35:
failed to write /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rust-2018/removing-extern-crate/auxiliary/dummy-crate/dummy-crate.out: Os { code: 2, kind: NotFound, message: "No such file or directory" }


failures:
    [ui] tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs

@bors
Copy link
Collaborator

bors commented Jul 21, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 21, 2025
@RalfJung
Copy link
Member Author

@bors retry spurious compiletest aux build issue (#144237)

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 21, 2025
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Jul 21, 2025
clippy: make tests work in stage 1

This finally fixes rust-lang#78717 :)

Similar to what Miri already does, the clippy test step needs to carefully consider  which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using `cargo-miri` for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but rust-lang/cargo#4423 makes this quite hard to do. See the long comment in `src/tools/clippy/tests/compile-test.rs` for details.

Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense.

Cc `@flip1995` `@Kobzol`
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Jul 21, 2025
clippy: make tests work in stage 1

This finally fixes rust-lang#78717 :)

Similar to what Miri already does, the clippy test step needs to carefully consider  which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using `cargo-miri` for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but rust-lang/cargo#4423 makes this quite hard to do. See the long comment in `src/tools/clippy/tests/compile-test.rs` for details.

Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense.

Cc ``@flip1995`` ``@Kobzol``
bors added a commit that referenced this pull request Jul 21, 2025
Rollup of 15 pull requests

Successful merges:

 - #142097 (gpu offload host code generation)
 - #143430 (Lower extra lifetimes before normal generic params.)
 - #143672 (Fix Box allocator drop elaboration)
 - #143768 (Constify Try, From, TryFrom and relevant traits)
 - #143816 (Implement `check` for compiletest and RA using tool macro)
 - #143985 (rustc_public: de-StableMIR-ize)
 - #144027 (clippy: make tests work in stage 1)
 - #144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename)
 - #144176 (Add approval blocking labels for new bors)
 - #144187 (fix handling of base address for TypeId allocations)
 - #144212 (Remove the ptr_unique lang item)
 - #144243 (Subtree update of `rust-analyzer`)
 - #144246 (Don't use another main test file as auxiliary)
 - #144251 (rustc-dev-guide subtree update)
 - #144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 21, 2025
Rollup of 14 pull requests

Successful merges:

 - #142097 (gpu offload host code generation)
 - #143430 (Lower extra lifetimes before normal generic params.)
 - #143768 (Constify Try, From, TryFrom and relevant traits)
 - #143816 (Implement `check` for compiletest and RA using tool macro)
 - #143985 (rustc_public: de-StableMIR-ize)
 - #144027 (clippy: make tests work in stage 1)
 - #144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename)
 - #144176 (Add approval blocking labels for new bors)
 - #144187 (fix handling of base address for TypeId allocations)
 - #144212 (Remove the ptr_unique lang item)
 - #144243 (Subtree update of `rust-analyzer`)
 - #144246 (Don't use another main test file as auxiliary)
 - #144251 (rustc-dev-guide subtree update)
 - #144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a3ab807 into rust-lang:master Jul 21, 2025
12 of 13 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 21, 2025
@bors
Copy link
Collaborator

bors commented Jul 21, 2025

⌛ Testing commit 192efbb with merge 9748d87...

rust-timer added a commit that referenced this pull request Jul 21, 2025
Rollup merge of #144027 - RalfJung:clippy, r=Mark-Simulacrum

clippy: make tests work in stage 1

This finally fixes #78717 :)

Similar to what Miri already does, the clippy test step needs to carefully consider  which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using `cargo-miri` for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but rust-lang/cargo#4423 makes this quite hard to do. See the long comment in `src/tools/clippy/tests/compile-test.rs` for details.

Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense.

Cc ```@flip1995``` ```@Kobzol```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x.py test --stage 0 src/tools/clippy does not work
8 participants