Skip to content

Commit d69d34b

Browse files
committed
fix x clippy --stage 1
1 parent 56ec3c0 commit d69d34b

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/bootstrap/src/bin/rustc.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ fn main() {
4646
// determine the version of the compiler, the real compiler needs to be
4747
// used. Currently, these two states are differentiated based on whether
4848
// --target and -vV is/isn't passed.
49-
let (rustc, libdir) = if target.is_none() && version.is_none() {
49+
let is_build_script = target.is_none() && version.is_none();
50+
let (rustc, libdir) = if is_build_script {
5051
("RUSTC_SNAPSHOT", "RUSTC_SNAPSHOT_LIBDIR")
5152
} else {
5253
("RUSTC_REAL", "RUSTC_LIBDIR")
@@ -70,7 +71,15 @@ fn main() {
7071
.unwrap_or_else(|| env::var("CFG_COMPILER_HOST_TRIPLE").unwrap());
7172
let is_clippy = args[0].to_string_lossy().ends_with(&exe("clippy-driver", &target_name));
7273
let rustc_driver = if is_clippy {
73-
args.remove(0)
74+
if is_build_script {
75+
// Don't run clippy on build scripts (for one thing, we may not have libstd built with
76+
// the appropriate version yet, e.g. for stage 1 std).
77+
// Also remove the `clippy-driver` param in addition to the RUSTC param.
78+
args.drain(..2);
79+
rustc_real
80+
} else {
81+
args.remove(0)
82+
}
7483
} else {
7584
args.remove(0);
7685
rustc_real

src/bootstrap/src/core/builder.rs

-11
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,6 @@ impl<'a> Builder<'a> {
11811181
extra_features: vec![],
11821182
});
11831183
let mut dylib_path = dylib_path();
1184-
let run_compiler = self.compiler(build_compiler.stage + 1, self.build.build);
11851184
dylib_path.insert(0, self.sysroot(run_compiler).join("lib"));
11861185

11871186
let mut cmd = Command::new(cargo_clippy.unwrap());
@@ -1634,16 +1633,6 @@ impl<'a> Builder<'a> {
16341633
self.clear_if_dirty(&out_dir, &self.rustc(compiler));
16351634
}
16361635

1637-
// HACK: clippy will pass `--sysroot` to `RunCompiler` if and only if SYSROOT is set and
1638-
// `--sysroot is not already passed. Cargo doesn't pass `--sysroot` through RUSTFLAGS for
1639-
// build scripts and proc-macros, which is exactly when we want to use the beta sysroot
1640-
// instead of the in-tree libstd. Set SYSROOT so we use beta for stage 0 build
1641-
if cmd == "clippy" {
1642-
let build_script_sysroot =
1643-
if stage == 0 { self.rustc_snapshot_sysroot() } else { sysroot };
1644-
cargo.env("SYSROOT", build_script_sysroot);
1645-
}
1646-
16471636
// Customize the compiler we're running. Specify the compiler to cargo
16481637
// as our shim and then pass it some various options used to configure
16491638
// how the actual compiler itself is called.

0 commit comments

Comments
 (0)