Skip to content

Commit e6a675c

Browse files
committed
allow running clippy on most of the in-tree tools
Signed-off-by: onur-ozkan <[email protected]>
1 parent 006354c commit e6a675c

File tree

4 files changed

+62
-13
lines changed

4 files changed

+62
-13
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use std::path::{Path, PathBuf};
1313

1414
pub fn cargo_subcommand(kind: Kind) -> &'static str {
1515
match kind {
16-
Kind::Check | Kind::Clippy => "check",
16+
Kind::Check
17+
// We ensure check steps for both std and rustc from build_steps/clippy, so handle `Kind::Clippy` as well.
18+
| Kind::Clippy => "check",
1719
Kind::Fix => "fix",
1820
_ => unreachable!(),
1921
}

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

+38-9
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,17 @@ impl Step for Rustc {
185185
let compiler = builder.compiler(builder.top_stage, builder.config.build);
186186
let target = self.target;
187187

188-
builder.ensure(compile::Std::new(compiler, compiler.host));
189-
builder.ensure(compile::Std::new(compiler, target));
188+
if compiler.stage != 0 {
189+
// If we're not in stage 0, then we won't have a std from the beta
190+
// compiler around. That means we need to make sure there's one in
191+
// the sysroot for the compiler to find. Otherwise, we're going to
192+
// fail when building crates that need to generate code (e.g., build
193+
// scripts and their dependencies).
194+
builder.ensure(compile::Std::new(compiler, compiler.host));
195+
builder.ensure(compile::Std::new(compiler, target));
196+
} else {
197+
builder.ensure(check::Std::new(target));
198+
}
190199

191200
let mut cargo = builder::Cargo::new(
192201
builder,
@@ -224,9 +233,7 @@ impl Step for Rustc {
224233
macro_rules! lint_any {
225234
($(
226235
$name:ident, $path:expr, $readable_name:expr
227-
$(,is_external_tool = $external:expr)*
228-
$(,is_unstable_tool = $unstable:expr)*
229-
$(,allow_features = $allow_features:expr)?
236+
$(,lint_by_default = $lint_by_default:expr)*
230237
;
231238
)+) => {
232239
$(
@@ -238,6 +245,7 @@ macro_rules! lint_any {
238245

239246
impl Step for $name {
240247
type Output = ();
248+
const DEFAULT: bool = if false $(|| $lint_by_default)* { true } else { false };
241249

242250
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
243251
run.path($path)
@@ -275,11 +283,15 @@ macro_rules! lint_any {
275283
&target,
276284
);
277285

286+
let stamp = builder
287+
.cargo_out(compiler, Mode::ToolRustc, target)
288+
.join(format!(".{}-check.stamp", stringify!($name).to_lowercase()));
289+
278290
run_cargo(
279291
builder,
280292
cargo,
281293
lint_args(builder, &[]),
282-
&libstd_stamp(builder, compiler, target),
294+
&stamp,
283295
vec![],
284296
true,
285297
false,
@@ -293,9 +305,26 @@ macro_rules! lint_any {
293305
lint_any!(
294306
Bootstrap, "src/bootstrap", "bootstrap";
295307
BuildHelper, "src/tools/build_helper", "build_helper";
296-
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
297-
Tidy, "src/tools/tidy", "tidy";
308+
BuildManifest, "src/tools/build-manifest", "build-manifest";
309+
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri";
310+
Clippy, "src/tools/clippy", "clippy";
311+
CollectLicenseMetadata, "src/tools/collect-license-metadata", "collect-license-metadata";
298312
Compiletest, "src/tools/compiletest", "compiletest";
299-
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
313+
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
314+
Jsondocck, "src/tools/jsondocck", "jsondocck";
315+
Jsondoclint, "src/tools/jsondoclint", "jsondoclint";
316+
LintDocs, "src/tools/lint-docs", "lint-docs";
317+
LlvmBitcodeLinker, "src/tools/llvm-bitcode-linker", "llvm-bitcode-linker";
318+
Miri, "src/tools/miri", "miri";
319+
MiroptTestTools, "src/tools/miropt-test-tools", "miropt-test-tools";
320+
OptDist, "src/tools/opt-dist", "opt-dist";
300321
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
322+
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
323+
Rls, "src/tools/rls", "rls";
324+
RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer";
325+
RustDemangler, "src/tools/rust-demangler", "rust-demangler";
326+
Rustdoc, "src/tools/rustdoc", "clippy";
327+
Rustfmt, "src/tools/rustfmt", "rustfmt";
328+
RustInstaller, "src/tools/rust-installer", "rust-installer";
329+
Tidy, "src/tools/tidy", "tidy";
301330
);

src/bootstrap/src/core/build_steps/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ pub fn run_cargo(
20152015
crate::exit!(1);
20162016
}
20172017

2018-
if builder.config.dry_run() || builder.kind == Kind::Clippy {
2018+
if builder.config.dry_run() {
20192019
return Vec::new();
20202020
}
20212021

src/bootstrap/src/core/builder.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -773,10 +773,28 @@ impl<'a> Builder<'a> {
773773
clippy::Rustc,
774774
clippy::Bootstrap,
775775
clippy::BuildHelper,
776+
clippy::BuildManifest,
777+
clippy::CargoMiri,
778+
clippy::Clippy,
779+
clippy::CollectLicenseMetadata,
780+
clippy::Compiletest,
776781
clippy::CoverageDump,
777-
clippy::Tidy,
778-
clippy::RemoteTestServer,
782+
clippy::Jsondocck,
783+
clippy::Jsondoclint,
784+
clippy::LintDocs,
785+
clippy::LlvmBitcodeLinker,
786+
clippy::Miri,
787+
clippy::MiroptTestTools,
788+
clippy::OptDist,
779789
clippy::RemoteTestClient,
790+
clippy::RemoteTestServer,
791+
clippy::Rls,
792+
clippy::RustAnalyzer,
793+
clippy::RustDemangler,
794+
clippy::Rustdoc,
795+
clippy::Rustfmt,
796+
clippy::RustInstaller,
797+
clippy::Tidy,
780798
),
781799
Kind::Check | Kind::Fix => describe!(
782800
check::Std,

0 commit comments

Comments
 (0)