Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format the world #67540

Merged
merged 5 commits into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
115 changes: 50 additions & 65 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/bin/llvm-config-wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// `src/bootstrap/native.rs` for why this is needed when compiling LLD.

use std::env;
use std::process::{self, Stdio, Command};
use std::io::{self, Write};
use std::process::{self, Command, Stdio};

fn main() {
let real_llvm_config = env::var_os("LLVM_CONFIG_REAL").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use std::env;

use bootstrap::{Config, Build};
use bootstrap::{Build, Config};

fn main() {
let args = env::args().skip(1).collect::<Vec<_>>();
Expand Down
46 changes: 24 additions & 22 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ fn main() {

// Detect whether or not we're a build script depending on whether --target
// is passed (a bit janky...)
let target = args.windows(2)
.find(|w| &*w[0] == "--target")
.and_then(|w| w[1].to_str());
let target = args.windows(2).find(|w| &*w[0] == "--target").and_then(|w| w[1].to_str());
let version = args.iter().find(|w| &**w == "-vV");

let verbose = match env::var("RUSTC_VERBOSE") {
Expand Down Expand Up @@ -57,19 +55,16 @@ fn main() {
dylib_path.insert(0, PathBuf::from(&libdir));

let mut cmd = Command::new(rustc);
cmd.args(&args)
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());
cmd.args(&args).env(bootstrap::util::dylib_path_var(), env::join_paths(&dylib_path).unwrap());

// Get the name of the crate we're compiling, if any.
let crate_name = args.windows(2)
.find(|args| args[0] == "--crate-name")
.and_then(|args| args[1].to_str());
let crate_name =
args.windows(2).find(|args| args[0] == "--crate-name").and_then(|args| args[1].to_str());

if let Some(crate_name) = crate_name {
if let Some(target) = env::var_os("RUSTC_TIME") {
if target == "all" ||
target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
if target == "all"
|| target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
{
cmd.arg("-Ztime");
}
Expand Down Expand Up @@ -101,15 +96,22 @@ fn main() {
// `compiler_builtins` are unconditionally compiled with panic=abort to
// workaround undefined references to `rust_eh_unwind_resume` generated
// otherwise, see issue https://github.com/rust-lang/rust/issues/43095.
if crate_name == Some("panic_abort") ||
crate_name == Some("compiler_builtins") && stage != "0" {
if crate_name == Some("panic_abort")
|| crate_name == Some("compiler_builtins") && stage != "0"
{
cmd.arg("-C").arg("panic=abort");
}

// Set various options from config.toml to configure how we're building
// code.
let debug_assertions = match env::var("RUSTC_DEBUG_ASSERTIONS") {
Ok(s) => if s == "true" { "y" } else { "n" },
Ok(s) => {
if s == "true" {
"y"
} else {
"n"
}
}
Err(..) => "n",
};

Expand Down Expand Up @@ -178,17 +180,17 @@ fn main() {
if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some() {
if let Some(crate_name) = crate_name {
let start = Instant::now();
let status = cmd
.status()
.unwrap_or_else(|_| panic!("\n\n failed to run {:?}", cmd));
let status = cmd.status().unwrap_or_else(|_| panic!("\n\n failed to run {:?}", cmd));
let dur = start.elapsed();

let is_test = args.iter().any(|a| a == "--test");
eprintln!("[RUSTC-TIMING] {} test:{} {}.{:03}",
crate_name,
is_test,
dur.as_secs(),
dur.subsec_nanos() / 1_000_000);
eprintln!(
"[RUSTC-TIMING] {} test:{} {}.{:03}",
crate_name,
is_test,
dur.as_secs(),
dur.subsec_nanos() / 1_000_000
);

match status.code() {
Some(i) => std::process::exit(i),
Expand Down
16 changes: 6 additions & 10 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//! See comments in `src/bootstrap/rustc.rs` for more information.

use std::env;
use std::process::Command;
use std::path::PathBuf;
use std::ffi::OsString;
use std::path::PathBuf;
use std::process::Command;

fn main() {
let args = env::args_os().skip(1).collect::<Vec<_>>();
Expand Down Expand Up @@ -35,8 +35,7 @@ fn main() {
.arg("dox")
.arg("--sysroot")
.arg(&sysroot)
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());
.env(bootstrap::util::dylib_path_var(), env::join_paths(&dylib_path).unwrap());

// Force all crates compiled by this compiler to (a) be unstable and (b)
// allow the `rustc_private` feature to link to other unstable crates
Expand All @@ -55,8 +54,7 @@ fn main() {
if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
// This "unstable-options" can be removed when `--crate-version` is stabilized
if !has_unstable {
cmd.arg("-Z")
.arg("unstable-options");
cmd.arg("-Z").arg("unstable-options");
}
cmd.arg("--crate-version").arg(version);
has_unstable = true;
Expand All @@ -66,8 +64,7 @@ fn main() {
if let Some(_) = env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES") {
// This "unstable-options" can be removed when `--generate-redirect-pages` is stabilized
if !has_unstable {
cmd.arg("-Z")
.arg("unstable-options");
cmd.arg("-Z").arg("unstable-options");
}
cmd.arg("--generate-redirect-pages");
has_unstable = true;
Expand All @@ -77,8 +74,7 @@ fn main() {
if let Some(ref x) = env::var_os("RUSTDOC_RESOURCE_SUFFIX") {
// This "unstable-options" can be removed when `--resource-suffix` is stabilized
if !has_unstable {
cmd.arg("-Z")
.arg("unstable-options");
cmd.arg("-Z").arg("unstable-options");
}
cmd.arg("--resource-suffix").arg(x);
}
Expand Down
12 changes: 6 additions & 6 deletions src/bootstrap/bin/sccache-plus-cl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ fn main() {
env::set_var("CXX", env::var_os("SCCACHE_CXX").unwrap());
let mut cfg = cc::Build::new();
cfg.cargo_metadata(false)
.out_dir("/")
.target(&target)
.host(&target)
.opt_level(0)
.warnings(false)
.debug(false);
.out_dir("/")
.target(&target)
.host(&target)
.opt_level(0)
.warnings(false)
.debug(false);
let compiler = cfg.get_compiler();

// Invoke sccache with said compiler
Expand Down
Loading