mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-29 21:41:47 +00:00
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.
|
||||
#
|
||||
# For new code, consider running rustfmt with this config (it should
|
||||
# be picked up automatically).
|
||||
# Run rustfmt with this config (it should be picked up automatically).
|
||||
version = "Two"
|
||||
use_small_heuristics = "Max"
|
||||
merge_derives = false
|
||||
|
||||
# by default we ignore everything in the repository
|
||||
# tidy only checks files which are not ignored, each entry follows gitignore style
|
||||
ignore = [
|
||||
# remove directories below, or opt out their subdirectories, as they are formatted
|
||||
"src/bootstrap/",
|
||||
"src/build_helper/",
|
||||
"src/liballoc/",
|
||||
"src/libarena/",
|
||||
"src/libcore/",
|
||||
"src/libfmt_macros/",
|
||||
"src/libgraphviz/",
|
||||
"src/libpanic_abort/",
|
||||
"src/libpanic_unwind/",
|
||||
"src/libproc_macro/",
|
||||
"src/libprofiler_builtins/",
|
||||
"src/librustc/",
|
||||
"src/librustc_apfloat/",
|
||||
"src/librustc_asan/",
|
||||
"src/librustc_codegen_llvm/",
|
||||
"src/librustc_codegen_ssa/",
|
||||
"src/librustc_codegen_utils/",
|
||||
"src/librustc_data_structures/",
|
||||
"src/librustc_driver/",
|
||||
"src/librustc_errors/",
|
||||
"src/librustc_feature/",
|
||||
"src/librustc_incremental/",
|
||||
"src/librustc_index/",
|
||||
"src/librustc_interface/",
|
||||
"src/librustc_lexer/",
|
||||
"src/librustc_lint/",
|
||||
"src/librustc_llvm/",
|
||||
"src/librustc_lsan/",
|
||||
"src/librustc_macros/",
|
||||
"src/librustc_metadata/",
|
||||
"src/librustc_mir/",
|
||||
"src/librustc_msan/",
|
||||
"src/librustc_parse/",
|
||||
"src/librustc_passes/",
|
||||
"src/librustc_plugin/",
|
||||
"src/librustc_plugin_impl/",
|
||||
"src/librustc_privacy/",
|
||||
"src/librustc_resolve/",
|
||||
"src/librustc_save_analysis/",
|
||||
"src/librustc_session/",
|
||||
"src/librustc_target/",
|
||||
"src/librustc_traits/",
|
||||
"src/librustc_tsan/",
|
||||
"src/librustc_typeck/",
|
||||
"src/librustdoc/",
|
||||
"src/libserialize/",
|
||||
"src/libstd/",
|
||||
"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",
|
||||
# tests for now are not formatted, as they are sometimes pretty-printing constrained
|
||||
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
|
||||
"src/test",
|
||||
|
||||
# tidy issues (line length, etc.)
|
||||
# to be fixed shortly
|
||||
"src/libcore/iter/adapters/mod.rs",
|
||||
"src/libcore/iter/traits/iterator.rs",
|
||||
"src/librustc/hir/lowering.rs",
|
||||
"src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs",
|
||||
"src/librustc/lint/mod.rs",
|
||||
"src/librustc/middle/resolve_lifetime.rs",
|
||||
"src/librustc/traits/mod.rs",
|
||||
"src/librustc/ty/constness.rs",
|
||||
"src/librustc/ty/context.rs",
|
||||
"src/librustc/ty/wf.rs",
|
||||
"src/librustc_codegen_llvm/back/write.rs",
|
||||
"src/librustc_codegen_llvm/consts.rs",
|
||||
"src/librustc_codegen_llvm/debuginfo/metadata.rs",
|
||||
"src/librustc_codegen_ssa/base.rs",
|
||||
"src/librustc_codegen_ssa/mir/place.rs",
|
||||
"src/librustc_codegen_utils/symbol_names/v0.rs",
|
||||
"src/librustc_errors/emitter.rs",
|
||||
"src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs",
|
||||
"src/librustc_mir/borrow_check/type_check/mod.rs",
|
||||
"src/librustc_mir/build/expr/as_rvalue.rs",
|
||||
"src/librustc_mir/build/matches/mod.rs",
|
||||
"src/librustc_mir/build/mod.rs",
|
||||
"src/librustc_mir/const_eval.rs",
|
||||
"src/librustc_mir/interpret/place.rs",
|
||||
"src/librustc_mir/monomorphize/collector.rs",
|
||||
"src/librustc_passes/ast_validation.rs",
|
||||
"src/librustc_resolve/lib.rs",
|
||||
"src/librustc_resolve/resolve_imports.rs",
|
||||
"src/librustc_typeck/astconv.rs",
|
||||
"src/librustc_typeck/check/_match.rs",
|
||||
"src/librustc_typeck/check/coercion.rs",
|
||||
"src/librustc_typeck/check/method/confirm.rs",
|
||||
"src/librustc_typeck/check/mod.rs",
|
||||
"src/librustc_typeck/check/wfcheck.rs",
|
||||
"src/librustdoc/html/markdown/tests.rs",
|
||||
"src/libstd/sys/sgx/abi/mem.rs",
|
||||
"src/libstd/sys/unix/os.rs",
|
||||
"src/libsyntax_expand/parse/lexer/tests.rs",
|
||||
"src/libsyntax_expand/parse/tests.rs",
|
||||
"src/libsyntax_ext/test.rs",
|
||||
"src/tools/build-manifest/src/main.rs",
|
||||
"src/librustc_feature",
|
||||
|
||||
# do not format submodules
|
||||
"src/doc/book",
|
||||
|
@ -1,21 +1,17 @@
|
||||
//! Runs rustfmt on the repository.
|
||||
|
||||
use crate::Build;
|
||||
use std::process::Command;
|
||||
use build_helper::t;
|
||||
use ignore::WalkBuilder;
|
||||
use std::path::Path;
|
||||
use build_helper::t;
|
||||
use std::process::Command;
|
||||
|
||||
fn rustfmt(build: &Build, path: &Path, check: bool) {
|
||||
let rustfmt_path = build.config.initial_rustfmt.as_ref().unwrap_or_else(|| {
|
||||
eprintln!("./x.py fmt is not supported on this channel");
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
||||
let mut cmd = Command::new(&rustfmt_path);
|
||||
fn rustfmt(src: &Path, rustfmt: &Path, path: &Path, check: bool) {
|
||||
let mut cmd = Command::new(&rustfmt);
|
||||
// avoid the submodule config paths from coming into play,
|
||||
// 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("--skip-children");
|
||||
if check {
|
||||
@ -51,14 +47,21 @@ pub fn format(build: &Build, check: bool) {
|
||||
}
|
||||
let ignore_fmt = ignore_fmt.build().unwrap();
|
||||
|
||||
let walker = WalkBuilder::new(&build.src)
|
||||
.types(matcher)
|
||||
.overrides(ignore_fmt)
|
||||
.build();
|
||||
for entry in walker {
|
||||
let entry = t!(entry);
|
||||
if entry.file_type().map_or(false, |t| t.is_file()) {
|
||||
rustfmt(build, &entry.path(), check);
|
||||
}
|
||||
}
|
||||
let rustfmt_path = build.config.initial_rustfmt.as_ref().unwrap_or_else(|| {
|
||||
eprintln!("./x.py fmt is not supported on this channel");
|
||||
std::process::exit(1);
|
||||
});
|
||||
let src = build.src.clone();
|
||||
let walker = WalkBuilder::new(&build.src).types(matcher).overrides(ignore_fmt).build_parallel();
|
||||
walker.run(|| {
|
||||
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
Block a user