Skip to content

Commit 8875668

Browse files
committed
Remove useless conditions about Clippy
We should always just use `Kind::Check` for the check steps, as Clippy now has an entirely separate set of steps.
1 parent b47d36d commit 8875668

File tree

2 files changed

+11
-42
lines changed

2 files changed

+11
-42
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ pub struct Std {
2121
///
2222
/// [`compile::Rustc`]: crate::core::build_steps::compile::Rustc
2323
crates: Vec<String>,
24-
/// Override `Builder::kind` on cargo invocations.
25-
///
26-
/// By default, `Builder::kind` is propagated as the subcommand to the cargo invocations.
27-
/// However, there are cases when this is not desirable. For example, when running `x clippy $tool_name`,
28-
/// passing `Builder::kind` to cargo invocations would run clippy on the entire compiler and library,
29-
/// which is not useful if we only want to lint a few crates with specific rules.
30-
override_build_kind: Option<Kind>,
3124
/// Never use this from outside calls. It is intended for internal use only within `check::Std::make_run`
3225
/// and `check::Std::run`.
3326
custom_stage: Option<u32>,
@@ -37,12 +30,7 @@ impl Std {
3730
const CRATE_OR_DEPS: &[&str] = &["sysroot", "coretests", "alloctests"];
3831

3932
pub fn new(target: TargetSelection) -> Self {
40-
Self { target, crates: vec![], override_build_kind: None, custom_stage: None }
41-
}
42-
43-
pub fn build_kind(mut self, kind: Option<Kind>) -> Self {
44-
self.override_build_kind = kind;
45-
self
33+
Self { target, crates: vec![], custom_stage: None }
4634
}
4735
}
4836

@@ -68,12 +56,7 @@ impl Step for Std {
6856
1
6957
};
7058

71-
run.builder.ensure(Std {
72-
target: run.target,
73-
crates,
74-
override_build_kind: None,
75-
custom_stage: Some(stage),
76-
});
59+
run.builder.ensure(Std { target: run.target, crates, custom_stage: Some(stage) });
7760
}
7861

7962
fn run(self, builder: &Builder<'_>) {
@@ -116,7 +99,7 @@ impl Step for Std {
11699
Mode::Std,
117100
SourceType::InTree,
118101
target,
119-
self.override_build_kind.unwrap_or(builder.kind),
102+
Kind::Check,
120103
);
121104

122105
std_cargo(builder, target, compiler.stage, &mut cargo);
@@ -147,9 +130,8 @@ impl Step for Std {
147130
}
148131
drop(_guard);
149132

150-
// don't run on std twice with x.py clippy
151133
// don't check test dependencies if we haven't built libtest
152-
if builder.kind == Kind::Clippy || !self.crates.iter().any(|krate| krate == "test") {
134+
if !self.crates.iter().any(|krate| krate == "test") {
153135
return;
154136
}
155137

@@ -165,7 +147,7 @@ impl Step for Std {
165147
Mode::Std,
166148
SourceType::InTree,
167149
target,
168-
self.override_build_kind.unwrap_or(builder.kind),
150+
Kind::Check,
169151
);
170152

171153
// If we're not in stage 0, tests and examples will fail to compile
@@ -382,14 +364,9 @@ impl Step for RustAnalyzer {
382364

383365
cargo.allow_features(crate::core::build_steps::tool::RustAnalyzer::ALLOW_FEATURES);
384366

385-
// For ./x.py clippy, don't check those targets because
386-
// linting tests and benchmarks can produce very noisy results
387-
if builder.kind != Kind::Clippy {
388-
// can't use `--all-targets` because `--examples` doesn't work well
389-
cargo.arg("--bins");
390-
cargo.arg("--tests");
391-
cargo.arg("--benches");
392-
}
367+
cargo.arg("--bins");
368+
cargo.arg("--tests");
369+
cargo.arg("--benches");
393370

394371
// Cargo's output path in a given stage, compiled by a particular
395372
// compiler for the specified target.
@@ -450,11 +427,7 @@ impl Step for Compiletest {
450427

451428
cargo.allow_features(COMPILETEST_ALLOW_FEATURES);
452429

453-
// For ./x.py clippy, don't run with --all-targets because
454-
// linting tests and benchmarks can produce very noisy results
455-
if builder.kind != Kind::Clippy {
456-
cargo.arg("--all-targets");
457-
}
430+
cargo.arg("--all-targets");
458431

459432
let stamp = BuildStamp::new(&builder.cargo_out(compiler, mode, self.target))
460433
.with_prefix("compiletest-check");
@@ -528,11 +501,7 @@ fn run_tool_check_step(
528501
&[],
529502
);
530503

531-
// For ./x.py clippy, don't run with --all-targets because
532-
// linting tests and benchmarks can produce very noisy results
533-
if builder.kind != Kind::Clippy {
534-
cargo.arg("--all-targets");
535-
}
504+
cargo.arg("--all-targets");
536505

537506
let stamp = BuildStamp::new(&builder.cargo_out(compiler, Mode::ToolRustc, target))
538507
.with_prefix(&format!("{}-check", step_type_name.to_lowercase()));

src/bootstrap/src/core/build_steps/clippy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl Step for Rustc {
217217
builder.ensure(compile::Std::new(compiler, compiler.host));
218218
builder.ensure(compile::Std::new(compiler, target));
219219
} else {
220-
builder.ensure(check::Std::new(target).build_kind(Some(Kind::Check)));
220+
builder.ensure(check::Std::new(target));
221221
}
222222
}
223223

0 commit comments

Comments
 (0)