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
This commit is contained in:
Joshua Nelson 2021-02-16 22:37:17 -05:00 committed by Caleb Cartwright
parent b2d45c0d4b
commit 956e0bae58
6 changed files with 13 additions and 21 deletions

View File

@ -379,6 +379,7 @@ impl<'a> Builder<'a> {
check::Clippy,
check::Miri,
check::Rls,
check::Rustfmt,
check::Bootstrap
),
Kind::Test => describe!(

View File

@ -363,13 +363,14 @@ macro_rules! tool_check_step {
}
tool_check_step!(Rustdoc, "src/tools/rustdoc", "src/librustdoc", SourceType::InTree);
// Clippy is a hybrid. It is an external tool, but uses a git subtree instead
// Clippy and Rustfmt are hybrids. They are external tools, but use a git subtree instead
// of a submodule. Since the SourceType only drives the deny-warnings
// behavior, treat it as in-tree so that any new warnings in clippy will be
// rejected.
tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree);
tool_check_step!(Miri, "src/tools/miri", SourceType::Submodule);
tool_check_step!(Rls, "src/tools/rls", SourceType::Submodule);
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree, false);

View File

@ -319,15 +319,9 @@ impl Step for Rustfmt {
let host = self.host;
let compiler = builder.compiler(stage, host);
let build_result = builder.ensure(tool::Rustfmt {
compiler,
target: self.host,
extra_features: Vec::new(),
});
if build_result.is_none() {
eprintln!("failed to test rustfmt: could not build");
return;
}
builder
.ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() })
.expect("in-tree tool");
let mut cargo = tool::prepare_tool_cargo(
builder,
@ -346,9 +340,7 @@ impl Step for Rustfmt {
cargo.add_rustc_lib_path(builder, compiler);
if try_run(builder, &mut cargo.into()) {
builder.save_toolstate("rustfmt", ToolState::TestPass);
}
builder.run(&mut cargo.into());
}
}

View File

@ -726,7 +726,7 @@ macro_rules! tool_extended {
// Note: tools need to be also added to `Builder::get_step_descriptions` in `builder.rs`
// to make `./x.py build <tool>` work.
tool_extended!((self, builder),
Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", stable=true, {};
Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", stable=true, in_tree=true, {};
CargoClippy, clippy, "src/tools/clippy", "cargo-clippy", stable=true, in_tree=true, {};
Clippy, clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {};
Miri, miri, "src/tools/miri", "miri", stable=false, {};
@ -740,7 +740,7 @@ tool_extended!((self, builder),
self.extra_features.push("clippy".to_owned());
};
RustDemangler, rust_demangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, {};
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, {};
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
RustAnalyzer, rust_analyzer, "src/tools/rust-analyzer/crates/rust-analyzer", "rust-analyzer", stable=false, {};
);

View File

@ -77,7 +77,6 @@ static STABLE_TOOLS: &[(&str, &str)] = &[
("rust-by-example", "src/doc/rust-by-example"),
("edition-guide", "src/doc/edition-guide"),
("rls", "src/tools/rls"),
("rustfmt", "src/tools/rustfmt"),
];
// These tools are permitted to not build on the beta/stable channels.
@ -278,10 +277,9 @@ impl Builder<'_> {
if self.config.dry_run {
return;
}
// Toolstate isn't tracked for clippy, but since most tools do, we avoid
// checking in all the places we could save toolstate and just do so
// here.
if tool == "clippy-driver" {
// Toolstate isn't tracked for clippy or rustfmt, but since most tools do, we avoid checking
// in all the places we could save toolstate and just do so here.
if tool == "clippy-driver" || tool == "rustfmt" {
return;
}
if let Some(ref path) = self.config.save_toolstates {

View File

@ -15,7 +15,6 @@ python3 "$X_PY" test --stage 2 --no-fail-fast \
src/doc/embedded-book \
src/doc/edition-guide \
src/tools/rls \
src/tools/rustfmt \
src/tools/miri \
set -e
@ -24,3 +23,4 @@ set -e
cat /tmp/toolstate/toolstates.json
python3 "$X_PY" test --stage 2 check-tools
python3 "$X_PY" test --stage 2 src/tools/clippy
python3 "$X_PY" test --stage 2 src/tools/rustfmt