Skip to content
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

Fix x.py clippy throwing error about clippy #95766

Closed
wants to merge 1 commit into from
Closed

Fix x.py clippy throwing error about clippy #95766

wants to merge 1 commit into from

Conversation

Milo123459
Copy link
Contributor

Previously, x.py clippy would throw an error about not having clippy installed for the current toolchain because it was invocating the wrong version of rustc. This changes it to use &self.initial_rustc instead of a hardcoded command.

Thank you to @jyn514 for helping!

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 7, 2022
@@ -1045,7 +1045,7 @@ impl<'a> Builder<'a> {
// Only run clippy on a very limited subset of crates (in particular, not build scripts).
cargo.arg("-Zunstable-options");
// Explicitly does *not* set `--cfg=bootstrap`, since we're using a nightly clippy.
let host_version = Command::new("rustc").arg("--version").output().map_err(|_| ());
let host_version = Command::new(&self.initial_rustc).arg("--version").output().map_err(|_| ());
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, so this fixes your immediate issue, but it surprises me that it works - it's going to just unconditionally use --cfg bootstrap now, even though it's still using the host clippy. Maybe it didn't come up because this is so soon after the beta bump?

I think ideally the fix would look something like:

  • Download clippy for the bootstrap toolchain in bootstrap.py (look for add_component)
  • Remove all this hacky code running rustc --version; treat it just the same as --cfg=bootstrap for build and check.
  • Either put a todo!() for stages other than 0, or build tool::Clippy in-tree before running them, rather than the host clippy.

@jyn514
Copy link
Member

jyn514 commented Apr 7, 2022

@rustbot label -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 7, 2022
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.debug-assertions := True
configure: rust.overflow-checks := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
skip untracked path cpu-usage.csv during rustfmt invocations
skip untracked path src/doc/book/ during rustfmt invocations
skip untracked path src/doc/rust-by-example/ during rustfmt invocations
skip untracked path src/llvm-project/ during rustfmt invocations
Diff in /checkout/src/bootstrap/builder.rs at line 1045:
                 // Only run clippy on a very limited subset of crates (in particular, not build scripts).
                 cargo.arg("-Zunstable-options");
                 // Explicitly does *not* set `--cfg=bootstrap`, since we're using a nightly clippy.
-                let host_version = Command::new(&self.initial_rustc).arg("--version").output().map_err(|_| ());
+                let host_version =
+                    Command::new(&self.initial_rustc).arg("--version").output().map_err(|_| ());
                 let output = host_version.and_then(|output| {
                     if output.status.success() {
                         Ok(output)
Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" "--config-path" "/checkout" "--edition" "2021" "--unstable-features" "--skip-children" "--check" "/checkout/src/bootstrap/builder.rs" "/checkout/src/bootstrap/builder/tests.rs" "/checkout/src/librustdoc/formats/item_type.rs" "/checkout/src/librustdoc/formats/renderer.rs" "/checkout/src/librustdoc/formats/cache.rs" "/checkout/src/librustdoc/formats/mod.rs" "/checkout/compiler/rustc_fs_util/src/lib.rs" "/checkout/src/librustdoc/theme/tests.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants