Skip to content

Commit eb0a624

Browse files
committed
Update bootstrap for in-tree rustfmt
- Add rustfmt to `x.py check` - Update Cargo.lock - Remove rustfmt from the toolstate list - Make rustfmt an in-tree tool - Give an error on `x.py test rustfmt` if rustfmt fails to build or if tests fail - Don't call `save_toolstate` when testing rustfmt
1 parent 9c1c134 commit eb0a624

File tree

6 files changed

+13
-21
lines changed

6 files changed

+13
-21
lines changed

src/bootstrap/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ impl<'a> Builder<'a> {
377377
check::Rustdoc,
378378
check::CodegenBackend,
379379
check::Clippy,
380+
check::Rustfmt,
380381
check::Bootstrap
381382
),
382383
Kind::Test => describe!(

src/bootstrap/check.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,12 @@ macro_rules! tool_check_step {
362362
}
363363

364364
tool_check_step!(Rustdoc, "src/tools/rustdoc", "src/librustdoc", SourceType::InTree);
365-
// Clippy is a hybrid. It is an external tool, but uses a git subtree instead
365+
// Clippy and Rustfmt are hybrids. They are external tools, but use a git subtree instead
366366
// of a submodule. Since the SourceType only drives the deny-warnings
367367
// behavior, treat it as in-tree so that any new warnings in clippy will be
368368
// rejected.
369369
tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree);
370+
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
370371

371372
tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree);
372373

src/bootstrap/test.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,9 @@ impl Step for Rustfmt {
318318
let host = self.host;
319319
let compiler = builder.compiler(stage, host);
320320

321-
let build_result = builder.ensure(tool::Rustfmt {
322-
compiler,
323-
target: self.host,
324-
extra_features: Vec::new(),
325-
});
326-
if build_result.is_none() {
327-
eprintln!("failed to test rustfmt: could not build");
328-
return;
329-
}
321+
builder
322+
.ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() })
323+
.expect("in-tree tool");
330324

331325
let mut cargo = tool::prepare_tool_cargo(
332326
builder,
@@ -345,9 +339,7 @@ impl Step for Rustfmt {
345339

346340
cargo.add_rustc_lib_path(builder, compiler);
347341

348-
if try_run(builder, &mut cargo.into()) {
349-
builder.save_toolstate("rustfmt", ToolState::TestPass);
350-
}
342+
builder.run(&mut cargo.into());
351343
}
352344
}
353345

src/bootstrap/tool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ macro_rules! tool_extended {
726726
// Note: tools need to be also added to `Builder::get_step_descriptions` in `builder.rs`
727727
// to make `./x.py build <tool>` work.
728728
tool_extended!((self, builder),
729-
Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", stable=true, {};
729+
Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", stable=true, in_tree=true, {};
730730
CargoClippy, clippy, "src/tools/clippy", "cargo-clippy", stable=true, in_tree=true, {};
731731
Clippy, clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {};
732732
Miri, miri, "src/tools/miri", "miri", stable=false, {};
@@ -740,7 +740,7 @@ tool_extended!((self, builder),
740740
self.extra_features.push("clippy".to_owned());
741741
};
742742
RustDemangler, rust_demangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, {};
743-
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, {};
743+
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
744744
RustAnalyzer, rust_analyzer, "src/tools/rust-analyzer/crates/rust-analyzer", "rust-analyzer", stable=false, {};
745745
);
746746

src/bootstrap/toolstate.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ static STABLE_TOOLS: &[(&str, &str)] = &[
7777
("rust-by-example", "src/doc/rust-by-example"),
7878
("edition-guide", "src/doc/edition-guide"),
7979
("rls", "src/tools/rls"),
80-
("rustfmt", "src/tools/rustfmt"),
8180
];
8281

8382
// These tools are permitted to not build on the beta/stable channels.
@@ -278,10 +277,9 @@ impl Builder<'_> {
278277
if self.config.dry_run {
279278
return;
280279
}
281-
// Toolstate isn't tracked for clippy, but since most tools do, we avoid
282-
// checking in all the places we could save toolstate and just do so
283-
// here.
284-
if tool == "clippy-driver" {
280+
// Toolstate isn't tracked for clippy or rustfmt, but since most tools do, we avoid checking
281+
// in all the places we could save toolstate and just do so here.
282+
if tool == "clippy-driver" || tool == "rustfmt" {
285283
return;
286284
}
287285
if let Some(ref path) = self.config.save_toolstates {

src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ python3 "$X_PY" test --stage 2 --no-fail-fast \
1515
src/doc/embedded-book \
1616
src/doc/edition-guide \
1717
src/tools/rls \
18-
src/tools/rustfmt \
1918
src/tools/miri \
2019

2120
set -e
@@ -24,3 +23,4 @@ set -e
2423
cat /tmp/toolstate/toolstates.json
2524
python3 "$X_PY" test --stage 2 check-tools
2625
python3 "$X_PY" test --stage 2 src/tools/clippy
26+
python3 "$X_PY" test --stage 2 src/tools/rustfmt

0 commit comments

Comments
 (0)