Remove most files from format ignore list
Also moves formatting to use edition 2018, and to be done in parallel. This brings near-linear speed ups (at least with a small amount of cores).
This commit is contained in:
parent
9b98af84c4
commit
8eb7c58dbb
115
rustfmt.toml
115
rustfmt.toml
|
@ -1,74 +1,59 @@
|
||||||
# Currently, most of the code in the compiler uses historical style.
|
# Run rustfmt with this config (it should be picked up automatically).
|
||||||
#
|
|
||||||
# For new code, consider running rustfmt with this config (it should
|
|
||||||
# be picked up automatically).
|
|
||||||
version = "Two"
|
version = "Two"
|
||||||
use_small_heuristics = "Max"
|
use_small_heuristics = "Max"
|
||||||
|
merge_derives = false
|
||||||
|
|
||||||
# by default we ignore everything in the repository
|
# by default we ignore everything in the repository
|
||||||
# tidy only checks files which are not ignored, each entry follows gitignore style
|
# tidy only checks files which are not ignored, each entry follows gitignore style
|
||||||
ignore = [
|
ignore = [
|
||||||
# remove directories below, or opt out their subdirectories, as they are formatted
|
# tests for now are not formatted, as they are sometimes pretty-printing constrained
|
||||||
"src/bootstrap/",
|
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
|
||||||
"src/build_helper/",
|
"src/test",
|
||||||
"src/liballoc/",
|
|
||||||
"src/libarena/",
|
# tidy issues (line length, etc.)
|
||||||
"src/libcore/",
|
# to be fixed shortly
|
||||||
"src/libfmt_macros/",
|
"src/libcore/iter/adapters/mod.rs",
|
||||||
"src/libgraphviz/",
|
"src/libcore/iter/traits/iterator.rs",
|
||||||
"src/libpanic_abort/",
|
"src/librustc/hir/lowering.rs",
|
||||||
"src/libpanic_unwind/",
|
"src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs",
|
||||||
"src/libproc_macro/",
|
"src/librustc/lint/mod.rs",
|
||||||
"src/libprofiler_builtins/",
|
"src/librustc/middle/resolve_lifetime.rs",
|
||||||
"src/librustc/",
|
"src/librustc/traits/mod.rs",
|
||||||
"src/librustc_apfloat/",
|
"src/librustc/ty/constness.rs",
|
||||||
"src/librustc_asan/",
|
"src/librustc/ty/context.rs",
|
||||||
"src/librustc_codegen_llvm/",
|
"src/librustc/ty/wf.rs",
|
||||||
"src/librustc_codegen_ssa/",
|
"src/librustc_codegen_llvm/back/write.rs",
|
||||||
"src/librustc_codegen_utils/",
|
"src/librustc_codegen_llvm/consts.rs",
|
||||||
"src/librustc_data_structures/",
|
"src/librustc_codegen_llvm/debuginfo/metadata.rs",
|
||||||
"src/librustc_driver/",
|
"src/librustc_codegen_ssa/base.rs",
|
||||||
"src/librustc_errors/",
|
"src/librustc_codegen_ssa/mir/place.rs",
|
||||||
"src/librustc_feature/",
|
"src/librustc_codegen_utils/symbol_names/v0.rs",
|
||||||
"src/librustc_incremental/",
|
"src/librustc_errors/emitter.rs",
|
||||||
"src/librustc_index/",
|
"src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs",
|
||||||
"src/librustc_interface/",
|
"src/librustc_mir/borrow_check/type_check/mod.rs",
|
||||||
"src/librustc_lexer/",
|
"src/librustc_mir/build/expr/as_rvalue.rs",
|
||||||
"src/librustc_lint/",
|
"src/librustc_mir/build/matches/mod.rs",
|
||||||
"src/librustc_llvm/",
|
"src/librustc_mir/build/mod.rs",
|
||||||
"src/librustc_lsan/",
|
"src/librustc_mir/const_eval.rs",
|
||||||
"src/librustc_macros/",
|
"src/librustc_mir/interpret/place.rs",
|
||||||
"src/librustc_metadata/",
|
"src/librustc_mir/monomorphize/collector.rs",
|
||||||
"src/librustc_mir/",
|
"src/librustc_passes/ast_validation.rs",
|
||||||
"src/librustc_msan/",
|
"src/librustc_resolve/lib.rs",
|
||||||
"src/librustc_parse/",
|
"src/librustc_resolve/resolve_imports.rs",
|
||||||
"src/librustc_passes/",
|
"src/librustc_typeck/astconv.rs",
|
||||||
"src/librustc_plugin/",
|
"src/librustc_typeck/check/_match.rs",
|
||||||
"src/librustc_plugin_impl/",
|
"src/librustc_typeck/check/coercion.rs",
|
||||||
"src/librustc_privacy/",
|
"src/librustc_typeck/check/method/confirm.rs",
|
||||||
"src/librustc_resolve/",
|
"src/librustc_typeck/check/mod.rs",
|
||||||
"src/librustc_save_analysis/",
|
"src/librustc_typeck/check/wfcheck.rs",
|
||||||
"src/librustc_session/",
|
"src/librustdoc/html/markdown/tests.rs",
|
||||||
"src/librustc_target/",
|
"src/libstd/sys/sgx/abi/mem.rs",
|
||||||
"src/librustc_traits/",
|
"src/libstd/sys/unix/os.rs",
|
||||||
"src/librustc_tsan/",
|
"src/libsyntax_expand/parse/lexer/tests.rs",
|
||||||
"src/librustc_typeck/",
|
"src/libsyntax_expand/parse/tests.rs",
|
||||||
"src/librustdoc/",
|
"src/libsyntax_ext/test.rs",
|
||||||
"src/libserialize/",
|
"src/tools/build-manifest/src/main.rs",
|
||||||
"src/libstd/",
|
"src/librustc_feature",
|
||||||
"src/libsyntax/",
|
|
||||||
"src/libsyntax_expand/",
|
|
||||||
"src/libsyntax_ext/",
|
|
||||||
"src/libsyntax_pos/",
|
|
||||||
"src/libterm/",
|
|
||||||
"src/libtest/",
|
|
||||||
"src/libunwind/",
|
|
||||||
"src/rtstartup/",
|
|
||||||
"src/rustc/",
|
|
||||||
"src/rustllvm/",
|
|
||||||
"src/test/",
|
|
||||||
"src/tools/",
|
|
||||||
"src/etc",
|
|
||||||
|
|
||||||
# do not format submodules
|
# do not format submodules
|
||||||
"src/doc/book",
|
"src/doc/book",
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
//! Runs rustfmt on the repository.
|
//! Runs rustfmt on the repository.
|
||||||
|
|
||||||
use crate::Build;
|
use crate::Build;
|
||||||
use std::process::Command;
|
use build_helper::t;
|
||||||
use ignore::WalkBuilder;
|
use ignore::WalkBuilder;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use build_helper::t;
|
use std::process::Command;
|
||||||
|
|
||||||
fn rustfmt(build: &Build, path: &Path, check: bool) {
|
fn rustfmt(src: &Path, rustfmt: &Path, path: &Path, check: bool) {
|
||||||
let rustfmt_path = build.config.initial_rustfmt.as_ref().unwrap_or_else(|| {
|
let mut cmd = Command::new(&rustfmt);
|
||||||
eprintln!("./x.py fmt is not supported on this channel");
|
|
||||||
std::process::exit(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut cmd = Command::new(&rustfmt_path);
|
|
||||||
// avoid the submodule config paths from coming into play,
|
// avoid the submodule config paths from coming into play,
|
||||||
// we only allow a single global config for the workspace for now
|
// we only allow a single global config for the workspace for now
|
||||||
cmd.arg("--config-path").arg(&build.src.canonicalize().unwrap());
|
cmd.arg("--config-path").arg(&src.canonicalize().unwrap());
|
||||||
|
cmd.arg("--edition").arg("2018");
|
||||||
cmd.arg("--unstable-features");
|
cmd.arg("--unstable-features");
|
||||||
cmd.arg("--skip-children");
|
cmd.arg("--skip-children");
|
||||||
if check {
|
if check {
|
||||||
|
@ -51,14 +47,21 @@ pub fn format(build: &Build, check: bool) {
|
||||||
}
|
}
|
||||||
let ignore_fmt = ignore_fmt.build().unwrap();
|
let ignore_fmt = ignore_fmt.build().unwrap();
|
||||||
|
|
||||||
let walker = WalkBuilder::new(&build.src)
|
let rustfmt_path = build.config.initial_rustfmt.as_ref().unwrap_or_else(|| {
|
||||||
.types(matcher)
|
eprintln!("./x.py fmt is not supported on this channel");
|
||||||
.overrides(ignore_fmt)
|
std::process::exit(1);
|
||||||
.build();
|
});
|
||||||
for entry in walker {
|
let src = build.src.clone();
|
||||||
let entry = t!(entry);
|
let walker = WalkBuilder::new(&build.src).types(matcher).overrides(ignore_fmt).build_parallel();
|
||||||
if entry.file_type().map_or(false, |t| t.is_file()) {
|
walker.run(|| {
|
||||||
rustfmt(build, &entry.path(), check);
|
let src = src.clone();
|
||||||
}
|
let rustfmt_path = rustfmt_path.clone();
|
||||||
}
|
Box::new(move |entry| {
|
||||||
|
let entry = t!(entry);
|
||||||
|
if entry.file_type().map_or(false, |t| t.is_file()) {
|
||||||
|
rustfmt(&src, &rustfmt_path, &entry.path(), check);
|
||||||
|
}
|
||||||
|
ignore::WalkState::Continue
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue