diff options
Diffstat (limited to 'src')
130 files changed, 743 insertions, 905 deletions
diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index f03f03e2d93..b9df7336cca 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -11,8 +11,8 @@ use std::str::FromStr; use std::{env, process}; use bootstrap::{ - find_recent_config_change_ids, human_readable_changes, t, Build, Config, Flags, Subcommand, - CONFIG_CHANGE_HISTORY, + Build, CONFIG_CHANGE_HISTORY, Config, Flags, Subcommand, find_recent_config_change_ids, + human_readable_changes, t, }; fn main() { diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index ba12e64c4a2..7671fc7e013 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -5,9 +5,9 @@ use std::path::PathBuf; use crate::core::build_steps::compile::{ add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, std_crates_for_run_make, }; -use crate::core::build_steps::tool::{prepare_tool_cargo, SourceType}; +use crate::core::build_steps::tool::{SourceType, prepare_tool_cargo}; use crate::core::builder::{ - self, crate_description, Alias, Builder, Kind, RunConfig, ShouldRun, Step, + self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, crate_description, }; use crate::core::config::TargetSelection; use crate::{Compiler, Mode, Subcommand}; diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index f608e5d715e..040690623a1 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -9,7 +9,7 @@ use std::fs; use std::io::{self, ErrorKind}; use std::path::Path; -use crate::core::builder::{crate_description, Builder, RunConfig, ShouldRun, Step}; +use crate::core::builder::{Builder, RunConfig, ShouldRun, Step, crate_description}; use crate::utils::helpers::t; use crate::{Build, Compiler, Kind, Mode, Subcommand}; diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index a0992350722..cd198c425c0 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -1,12 +1,12 @@ //! Implementation of running clippy on the compiler, standard library and various tools. use super::compile::{librustc_stamp, libstd_stamp, run_cargo, rustc_cargo, std_cargo}; -use super::tool::{prepare_tool_cargo, SourceType}; +use super::tool::{SourceType, prepare_tool_cargo}; use super::{check, compile}; use crate::builder::{Builder, ShouldRun}; use crate::core::build_steps::compile::std_crates_for_run_make; use crate::core::builder; -use crate::core::builder::{crate_description, Alias, Kind, RunConfig, Step}; +use crate::core::builder::{Alias, Kind, RunConfig, Step, crate_description}; use crate::{Mode, Subcommand, TargetSelection}; /// Disable the most spammy clippy lints diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index db7b239c0ae..0e596f0da0e 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -9,8 +9,8 @@ use std::borrow::Cow; use std::collections::HashSet; use std::ffi::OsStr; -use std::io::prelude::*; use std::io::BufReader; +use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process::Stdio; use std::{env, fs, str}; @@ -22,14 +22,14 @@ use crate::core::build_steps::tool::SourceType; use crate::core::build_steps::{dist, llvm}; use crate::core::builder; use crate::core::builder::{ - crate_description, Builder, Cargo, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath, + Builder, Cargo, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath, crate_description, }; use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection}; use crate::utils::exec::command; use crate::utils::helpers::{ self, exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date, }; -use crate::{CLang, Compiler, DependencyType, GitRepo, Mode, LLVM_TOOLS}; +use crate::{CLang, Compiler, DependencyType, GitRepo, LLVM_TOOLS, Mode}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Std { diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 294a56b3e97..4c557366297 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -14,8 +14,8 @@ use std::io::Write; use std::path::{Path, PathBuf}; use std::{env, fs}; -use object::read::archive::ArchiveFile; use object::BinaryFormat; +use object::read::archive::ArchiveFile; use crate::core::build_steps::doc::DocumentationFormat; use crate::core::build_steps::tool::{self, Tool}; @@ -24,12 +24,12 @@ use crate::core::build_steps::{compile, llvm}; use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; use crate::core::config::TargetSelection; use crate::utils::channel::{self, Info}; -use crate::utils::exec::{command, BootstrapCommand}; +use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{ exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit, }; use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball}; -use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS}; +use crate::{Compiler, DependencyType, LLVM_TOOLS, Mode}; pub fn pkgname(builder: &Builder<'_>, component: &str) -> String { format!("{}-{}", component, builder.rust_package_vers()) diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 979671cfa9d..919a42180d7 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -11,14 +11,14 @@ use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::{env, fs, mem}; +use crate::Mode; use crate::core::build_steps::compile; -use crate::core::build_steps::tool::{self, prepare_tool_cargo, SourceType, Tool}; +use crate::core::build_steps::tool::{self, SourceType, Tool, prepare_tool_cargo}; use crate::core::builder::{ - self, crate_description, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, + self, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, crate_description, }; use crate::core::config::{Config, TargetSelection}; use crate::utils::helpers::{symlink_dir, t, up_to_date}; -use crate::Mode; macro_rules! submodule_helper { ($path:expr, submodule) => { diff --git a/src/bootstrap/src/core/build_steps/format.rs b/src/bootstrap/src/core/build_steps/format.rs index bbd81fb570b..952d8d73328 100644 --- a/src/bootstrap/src/core/build_steps/format.rs +++ b/src/bootstrap/src/core/build_steps/format.rs @@ -3,8 +3,8 @@ use std::collections::VecDeque; use std::path::{Path, PathBuf}; use std::process::Command; -use std::sync::mpsc::SyncSender; use std::sync::Mutex; +use std::sync::mpsc::SyncSender; use build_helper::ci::CiEnv; use build_helper::git::get_git_modified_files; diff --git a/src/bootstrap/src/core/build_steps/gcc.rs b/src/bootstrap/src/core/build_steps/gcc.rs index f7a88930b8d..b950bec11fd 100644 --- a/src/bootstrap/src/core/build_steps/gcc.rs +++ b/src/bootstrap/src/core/build_steps/gcc.rs @@ -15,8 +15,8 @@ use std::sync::OnceLock; use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::core::config::TargetSelection; use crate::utils::exec::command; -use crate::utils::helpers::{self, t, HashStamp}; -use crate::{generate_smart_stamp_hash, Kind}; +use crate::utils::helpers::{self, HashStamp, t}; +use crate::{Kind, generate_smart_stamp_hash}; pub struct Meta { stamp: HashStamp, diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index d8752d03761..b3bc6df1f87 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -23,9 +23,9 @@ use crate::core::config::{Config, TargetSelection}; use crate::utils::channel; use crate::utils::exec::command; use crate::utils::helpers::{ - self, exe, get_clang_cl_resource_dir, output, t, unhashed_basename, up_to_date, HashStamp, + self, HashStamp, exe, get_clang_cl_resource_dir, output, t, unhashed_basename, up_to_date, }; -use crate::{generate_smart_stamp_hash, CLang, GitRepo, Kind}; +use crate::{CLang, GitRepo, Kind, generate_smart_stamp_hash}; #[derive(Clone)] pub struct LlvmResult { @@ -154,16 +154,12 @@ pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> L /// This retrieves the LLVM sha we *want* to use, according to git history. pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String { let llvm_sha = if is_git { - get_closest_merge_commit( - Some(&config.src), - &config.git_config(), - &[ - config.src.join("src/llvm-project"), - config.src.join("src/bootstrap/download-ci-llvm-stamp"), - // the LLVM shared object file is named `LLVM-12-rust-{version}-nightly` - config.src.join("src/version"), - ], - ) + get_closest_merge_commit(Some(&config.src), &config.git_config(), &[ + config.src.join("src/llvm-project"), + config.src.join("src/bootstrap/download-ci-llvm-stamp"), + // the LLVM shared object file is named `LLVM-12-rust-{version}-nightly` + config.src.join("src/version"), + ]) .unwrap() } else if let Some(info) = channel::read_commit_info_file(&config.src) { info.sha.trim().to_owned() diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 65d635c0bd6..c7bcd76cadd 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -5,14 +5,14 @@ use std::path::PathBuf; +use crate::Mode; use crate::core::build_steps::dist::distdir; use crate::core::build_steps::test; use crate::core::build_steps::tool::{self, SourceType, Tool}; use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; -use crate::core::config::flags::get_completion; use crate::core::config::TargetSelection; +use crate::core::config::flags::get_completion; use crate::utils::exec::command; -use crate::Mode; #[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct BuildManifest; diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index f7b26712cab..f4c5fe5ff94 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -9,7 +9,7 @@ use std::env::consts::EXE_SUFFIX; use std::fmt::Write as _; use std::fs::File; use std::io::Write; -use std::path::{Path, PathBuf, MAIN_SEPARATOR_STR}; +use std::path::{MAIN_SEPARATOR_STR, Path, PathBuf}; use std::str::FromStr; use std::{fmt, fs, io}; @@ -19,7 +19,7 @@ use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY; use crate::utils::exec::command; use crate::utils::helpers::{self, hex_encode}; -use crate::{t, Config}; +use crate::{Config, t}; #[cfg(test)] mod tests; diff --git a/src/bootstrap/src/core/build_steps/synthetic_targets.rs b/src/bootstrap/src/core/build_steps/synthetic_targets.rs index 04297c01d10..477ff9553a4 100644 --- a/src/bootstrap/src/core/build_steps/synthetic_targets.rs +++ b/src/bootstrap/src/core/build_steps/synthetic_targets.rs @@ -7,10 +7,10 @@ //! one of the target specs already defined in this module, or create new ones by adding a new step //! that calls create_synthetic_target. +use crate::Compiler; use crate::core::builder::{Builder, ShouldRun, Step}; use crate::core::config::TargetSelection; use crate::utils::exec::command; -use crate::Compiler; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub(crate) struct MirOptPanicAbortSyntheticTarget { diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 2047345d78a..8f076e5554e 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -15,17 +15,17 @@ use crate::core::build_steps::tool::{self, SourceType, Tool}; use crate::core::build_steps::toolstate::ToolState; use crate::core::build_steps::{compile, dist, llvm}; use crate::core::builder::{ - self, crate_description, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, + self, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, crate_description, }; -use crate::core::config::flags::{get_completion, Subcommand}; use crate::core::config::TargetSelection; -use crate::utils::exec::{command, BootstrapCommand}; +use crate::core::config::flags::{Subcommand, get_completion}; +use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{ - self, add_link_lib_path, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var, - linker_args, linker_flags, t, target_supports_cranelift_backend, up_to_date, LldThreads, + self, LldThreads, add_link_lib_path, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var, + linker_args, linker_flags, t, target_supports_cranelift_backend, up_to_date, }; use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests}; -use crate::{envify, CLang, DocTests, GitRepo, Mode}; +use crate::{CLang, DocTests, GitRepo, Mode, envify}; const ADB_TEST_DIR: &str = "/data/local/tmp/work"; @@ -1075,12 +1075,8 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to crate::exit!(1); } let all = false; - crate::core::build_steps::format::format( - builder, - !builder.config.cmd.bless(), - all, - &[], - ); + crate::core::build_steps::format::format(builder, !builder.config.cmd.bless(), all, &[ + ]); } builder.info("tidy check"); @@ -3440,11 +3436,10 @@ impl Step for CodegenGCC { let compiler = self.compiler; let target = self.target; - builder.ensure(compile::Std::new_with_extra_rust_args( - compiler, - target, - &["-Csymbol-mangling-version=v0", "-Cpanic=abort"], - )); + builder.ensure(compile::Std::new_with_extra_rust_args(compiler, target, &[ + "-Csymbol-mangling-version=v0", + "-Cpanic=abort", + ])); // If we're not doing a full bootstrap but we're testing a stage2 // version of libstd, then what we're actually testing is the libstd diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index a437f829ba5..64dfe054d9c 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -9,9 +9,9 @@ use crate::core::builder; use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step}; use crate::core::config::TargetSelection; use crate::utils::channel::GitInfo; -use crate::utils::exec::{command, BootstrapCommand}; +use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{add_dylib_path, exe, git, t}; -use crate::{gha, Compiler, Kind, Mode}; +use crate::{Compiler, Kind, Mode, gha}; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub enum SourceType { diff --git a/src/bootstrap/src/core/build_steps/toolstate.rs b/src/bootstrap/src/core/build_steps/toolstate.rs index b73961062f6..8ac311b2493 100644 --- a/src/bootstrap/src/core/build_steps/toolstate.rs +++ b/src/bootstrap/src/core/build_steps/toolstate.rs @@ -42,15 +42,11 @@ pub enum ToolState { impl fmt::Display for ToolState { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "{}", - match self { - ToolState::TestFail => "test-fail", - ToolState::TestPass => "test-pass", - ToolState::BuildFail => "build-fail", - } - ) + write!(f, "{}", match self { + ToolState::TestFail => "test-fail", + ToolState::TestPass => "test-pass", + ToolState::BuildFail => "build-fail", + }) } } diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index d2c23ee8432..47420f8fe72 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1,4 +1,4 @@ -use std::any::{type_name, Any}; +use std::any::{Any, type_name}; use std::cell::{Cell, RefCell}; use std::collections::BTreeSet; use std::ffi::{OsStr, OsString}; @@ -12,6 +12,7 @@ use std::{env, fs}; use clap::ValueEnum; +pub use crate::Compiler; use crate::core::build_steps::tool::{self, SourceType}; use crate::core::build_steps::{ check, clean, clippy, compile, dist, doc, gcc, install, llvm, run, setup, test, vendor, @@ -19,14 +20,13 @@ use crate::core::build_steps::{ use crate::core::config::flags::{Color, Subcommand}; use crate::core::config::{DryRun, SplitDebuginfo, TargetSelection}; use crate::utils::cache::Cache; -use crate::utils::exec::{command, BootstrapCommand}; +use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{ - self, add_dylib_path, add_link_lib_path, check_cfg_arg, exe, libdir, linker_args, linker_flags, - t, LldThreads, + self, LldThreads, add_dylib_path, add_link_lib_path, check_cfg_arg, exe, libdir, linker_args, + linker_flags, t, }; -pub use crate::Compiler; use crate::{ - prepare_behaviour_dump_dir, Build, CLang, Crate, DocTests, GitRepo, Mode, EXTRA_CHECK_CFGS, + Build, CLang, Crate, DocTests, EXTRA_CHECK_CFGS, GitRepo, Mode, prepare_behaviour_dump_dir, }; #[cfg(test)] @@ -314,33 +314,30 @@ const PATH_REMAP: &[(&str, &[&str])] = &[ // actual path is `proc-macro-srv-cli` ("rust-analyzer-proc-macro-srv", &["src/tools/rust-analyzer/crates/proc-macro-srv-cli"]), // Make `x test tests` function the same as `x t tests/*` - ( - "tests", - &[ - // tidy-alphabetical-start - "tests/assembly", - "tests/codegen", - "tests/codegen-units", - "tests/coverage", - "tests/coverage-run-rustdoc", - "tests/crashes", - "tests/debuginfo", - "tests/incremental", - "tests/mir-opt", - "tests/pretty", - "tests/run-make", - "tests/run-pass-valgrind", - "tests/rustdoc", - "tests/rustdoc-gui", - "tests/rustdoc-js", - "tests/rustdoc-js-std", - "tests/rustdoc-json", - "tests/rustdoc-ui", - "tests/ui", - "tests/ui-fulldeps", - // tidy-alphabetical-end - ], - ), + ("tests", &[ + // tidy-alphabetical-start + "tests/assembly", + "tests/codegen", + "tests/codegen-units", + "tests/coverage", + "tests/coverage-run-rustdoc", + "tests/crashes", + "tests/debuginfo", + "tests/incremental", + "tests/mir-opt", + "tests/pretty", + "tests/run-make", + "tests/run-pass-valgrind", + "tests/rustdoc", + "tests/rustdoc-gui", + "tests/rustdoc-js", + "tests/rustdoc-js-std", + "tests/rustdoc-json", + "tests/rustdoc-ui", + "tests/ui", + "tests/ui-fulldeps", + // tidy-alphabetical-end + ]), ]; fn remap_paths(paths: &mut Vec<PathBuf>) { diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index c554684d5a7..bd81dc930be 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1,9 +1,9 @@ use std::thread; use super::*; +use crate::Flags; use crate::core::build_steps::doc::DocumentationFormat; use crate::core::config::Config; -use crate::Flags; fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config { configure_with_args(&[cmd.to_owned()], host, target) @@ -202,10 +202,10 @@ fn test_exclude_kind() { fn alias_and_path_for_library() { let mut cache = run_build(&["library".into(), "core".into()], configure("build", &["A-A"], &["A-A"])); - assert_eq!( - first(cache.all::<compile::Std>()), - &[std!(A => A, stage = 0), std!(A => A, stage = 1)] - ); + assert_eq!(first(cache.all::<compile::Std>()), &[ + std!(A => A, stage = 0), + std!(A => A, stage = 1) + ]); let mut cache = run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"])); @@ -216,18 +216,18 @@ mod defaults { use pretty_assertions::assert_eq; use super::{configure, first, run_build}; - use crate::core::builder::*; use crate::Config; + use crate::core::builder::*; #[test] fn build_default() { let mut cache = run_build(&[], configure("build", &["A-A"], &["A-A"])); let a = TargetSelection::from_user("A-A"); - assert_eq!( - first(cache.all::<compile::Std>()), - &[std!(A => A, stage = 0), std!(A => A, stage = 1),] - ); + assert_eq!(first(cache.all::<compile::Std>()), &[ + std!(A => A, stage = 0), + std!(A => A, stage = 1), + ]); assert!(!cache.all::<compile::Assemble>().is_empty()); // Make sure rustdoc is only built once. assert_eq!( @@ -269,34 +269,25 @@ mod defaults { // there's not really a need for us to build for target A in this case // (since we're producing stage 1 libraries/binaries). But currently // bootstrap is just a bit buggy here; this should be fixed though. - assert_eq!( - first(cache.all::<compile::Std>()), - &[ - std!(A => A, stage = 0), - std!(A => A, stage = 1), - std!(A => B, stage = 0), - std!(A => B, stage = 1), - ] - ); - assert_eq!( - first(cache.all::<compile::Assemble>()), - &[ - compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } }, - compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } }, - compile::Assemble { target_compiler: Compiler { host: b, stage: 1 } }, - ] - ); - assert_eq!( - first(cache.all::<tool::Rustdoc>()), - &[ - tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }, - tool::Rustdoc { compiler: Compiler { host: b, stage: 1 } }, - ], - ); - assert_eq!( - first(cache.all::<compile::Rustc>()), - &[rustc!(A => A, stage = 0), rustc!(A => B, stage = 0),] - ); + assert_eq!(first(cache.all::<compile::Std>()), &[ + std!(A => A, stage = 0), + std!(A => A, stage = 1), + std!(A => B, stage = 0), + std!(A => B, stage = 1), + ]); + assert_eq!(first(cache.all::<compile::Assemble>()), &[ + compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } }, + compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } }, + compile::Assemble { target_compiler: Compiler { host: b, stage: 1 } }, + ]); + assert_eq!(first(cache.all::<tool::Rustdoc>()), &[ + tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }, + tool::Rustdoc { compiler: Compiler { host: b, stage: 1 } }, + ],); + assert_eq!(first(cache.all::<compile::Rustc>()), &[ + rustc!(A => A, stage = 0), + rustc!(A => B, stage = 0), + ]); } #[test] @@ -310,24 +301,22 @@ mod defaults { // error_index_generator uses stage 0 to share rustdoc artifacts with the // rustdoc tool. assert_eq!(first(cache.all::<doc::ErrorIndex>()), &[doc::ErrorIndex { target: a },]); - assert_eq!( - first(cache.all::<tool::ErrorIndex>()), - &[tool::ErrorIndex { compiler: Compiler { host: a, stage: 0 } }] - ); + assert_eq!(first(cache.all::<tool::ErrorIndex>()), &[tool::ErrorIndex { + compiler: Compiler { host: a, stage: 0 } + }]); // docs should be built with the beta compiler, not with the stage0 artifacts. // recall that rustdoc is off-by-one: `stage` is the compiler rustdoc is _linked_ to, // not the one it was built by. - assert_eq!( - first(cache.all::<tool::Rustdoc>()), - &[tool::Rustdoc { compiler: Compiler { host: a, stage: 0 } },] - ); + assert_eq!(first(cache.all::<tool::Rustdoc>()), &[tool::Rustdoc { + compiler: Compiler { host: a, stage: 0 } + },]); } } mod dist { use pretty_assertions::assert_eq; - use super::{first, run_build, Config}; + use super::{Config, first, run_build}; use crate::core::builder::*; fn configure(host: &[&str], target: &[&str]) -> Config { @@ -342,20 +331,18 @@ mod dist { assert_eq!(first(cache.all::<dist::Docs>()), &[dist::Docs { host: a },]); assert_eq!(first(cache.all::<dist::Mingw>()), &[dist::Mingw { host: a },]); - assert_eq!( - first(cache.all::<dist::Rustc>()), - &[dist::Rustc { compiler: Compiler { host: a, stage: 2 } },] - ); - assert_eq!( - first(cache.all::<dist::Std>()), - &[dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a },] - ); + assert_eq!(first(cache.all::<dist::Rustc>()), &[dist::Rustc { + compiler: Compiler { host: a, stage: 2 } + },]); + assert_eq!(first(cache.all::<dist::Std>()), &[dist::Std { + compiler: Compiler { host: a, stage: 1 }, + target: a + },]); assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]); // Make sure rustdoc is only built once. - assert_eq!( - first(cache.all::<tool::Rustdoc>()), - &[tool::Rustdoc { compiler: Compiler { host: a, stage: 2 } },] - ); + assert_eq!(first(cache.all::<tool::Rustdoc>()), &[tool::Rustdoc { + compiler: Compiler { host: a, stage: 2 } + },]); } #[test] @@ -365,25 +352,19 @@ mod dist { let a = TargetSelection::from_user("A-A"); let b = TargetSelection::from_user("B-B"); - assert_eq!( - first(cache.all::<dist::Docs>()), - &[dist::Docs { host: a }, dist::Docs { host: b },] - ); - assert_eq!( - first(cache.all::<dist::Mingw>()), - &[dist::Mingw { host: a }, dist::Mingw { host: b },] - ); - assert_eq!( - first(cache.all::<dist::Rustc>()), - &[dist::Rustc { compiler: Compiler { host: a, stage: 2 } },] - ); - assert_eq!( - first(cache.all::<dist::Std>()), - &[ - dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, - dist::Std { compiler: Compiler { host: a, stage: 2 }, target: b }, - ] - ); + assert_eq!(first(cache.all::<dist::Docs>()), &[dist::Docs { host: a }, dist::Docs { + host: b + },]); + assert_eq!(first(cache.all::<dist::Mingw>()), &[dist::Mingw { host: a }, dist::Mingw { + host: b + },]); + assert_eq!(first(cache.all::<dist::Rustc>()), &[dist::Rustc { + compiler: Compiler { host: a, stage: 2 } + },]); + assert_eq!(first(cache.all::<dist::Std>()), &[ + dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, + dist::Std { compiler: Compiler { host: a, stage: 2 }, target: b }, + ]); assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]); } @@ -394,38 +375,27 @@ mod dist { let a = TargetSelection::from_user("A-A"); let b = TargetSelection::from_user("B-B"); - assert_eq!( - first(cache.all::<dist::Docs>()), - &[dist::Docs { host: a }, dist::Docs { host: b },] - ); - assert_eq!( - first(cache.all::<dist::Mingw>()), - &[dist::Mingw { host: a }, dist::Mingw { host: b },] - ); - assert_eq!( - first(cache.all::<dist::Rustc>()), - &[ - dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, - dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, - ] - ); - assert_eq!( - first(cache.all::<dist::Std>()), - &[ - dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, - dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, - ] - ); - assert_eq!( - first(cache.all::<compile::Std>()), - &[ - std!(A => A, stage = 0), - std!(A => A, stage = 1), - std!(A => A, stage = 2), - std!(A => B, stage = 1), - std!(A => B, stage = 2), - ], - ); + assert_eq!(first(cache.all::<dist::Docs>()), &[dist::Docs { host: a }, dist::Docs { + host: b + },]); + assert_eq!(first(cache.all::<dist::Mingw>()), &[dist::Mingw { host: a }, dist::Mingw { + host: b + },]); + assert_eq!(first(cache.all::<dist::Rustc>()), &[ + dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, + dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, + ]); + assert_eq!(first(cache.all::<dist::Std>()), &[ + dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, + dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, + ]); + assert_eq!(first(cache.all::<compile::Std>()), &[ + std!(A => A, stage = 0), + std!(A => A, stage = 1), + std!(A => A, stage = 2), + std!(A => B, stage = 1), + std!(A => B, stage = 2), + ],); assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]); } @@ -438,14 +408,13 @@ mod dist { config.hosts = vec![b]; let mut cache = run_build(&[], config); - assert_eq!( - first(cache.all::<dist::Rustc>()), - &[dist::Rustc { compiler: Compiler { host: b, stage: 2 } },] - ); - assert_eq!( - first(cache.all::<compile::Rustc>()), - &[rustc!(A => A, stage = 0), rustc!(A => B, stage = 1),] - ); + assert_eq!(first(cache.all::<dist::Rustc>()), &[dist::Rustc { + compiler: Compiler { host: b, stage: 2 } + },]); + assert_eq!(first(cache.all::<compile::Rustc>()), &[ + rustc!(A => A, stage = 0), + rustc!(A => B, stage = 1), + ]); } #[test] @@ -456,29 +425,25 @@ mod dist { let b = TargetSelection::from_user("B-B"); let c = TargetSelection::from_user("C-C"); - assert_eq!( - first(cache.all::<dist::Docs>()), - &[dist::Docs { host: a }, dist::Docs { host: b }, dist::Docs { host: c },] - ); - assert_eq!( - first(cache.all::<dist::Mingw>()), - &[dist::Mingw { host: a }, dist::Mingw { host: b }, dist::Mingw { host: c },] - ); - assert_eq!( - first(cache.all::<dist::Rustc>()), - &[ - dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, - dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, - ] - ); - assert_eq!( - first(cache.all::<dist::Std>()), - &[ - dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, - dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, - dist::Std { compiler: Compiler { host: a, stage: 2 }, target: c }, - ] - ); + assert_eq!(first(cache.all::<dist::Docs>()), &[ + dist::Docs { host: a }, + dist::Docs { host: b }, + dist::Docs { host: c }, + ]); + assert_eq!(first(cache.all::<dist::Mingw>()), &[ + dist::Mingw { host: a }, + dist::Mingw { host: b }, + dist::Mingw { host: c }, + ]); + assert_eq!(first(cache.all::<dist::Rustc>()), &[ + dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, + dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, + ]); + assert_eq!(first(cache.all::<dist::Std>()), &[ + dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, + dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, + dist::Std { compiler: Compiler { host: a, stage: 2 }, target: c }, + ]); assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]); } @@ -492,10 +457,10 @@ mod dist { assert_eq!(first(cache.all::<dist::Docs>()), &[dist::Docs { host: c },]); assert_eq!(first(cache.all::<dist::Mingw>()), &[dist::Mingw { host: c },]); - assert_eq!( - first(cache.all::<dist::Std>()), - &[dist::Std { compiler: Compiler { host: a, stage: 2 }, target: c },] - ); + assert_eq!(first(cache.all::<dist::Std>()), &[dist::Std { + compiler: Compiler { host: a, stage: 2 }, + target: c + },]); } #[test] @@ -505,81 +470,61 @@ mod dist { let a = TargetSelection::from_user("A-A"); let b = TargetSelection::from_user("B-B"); - assert_eq!( - first(cache.all::<dist::Docs>()), - &[dist::Docs { host: a }, dist::Docs { host: b },] - ); - assert_eq!( - first(cache.all::<dist::Mingw>()), - &[dist::Mingw { host: a }, dist::Mingw { host: b },] - ); - assert_eq!( - first(cache.all::<dist::Rustc>()), - &[ - dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, - dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, - ] - ); - assert_eq!( - first(cache.all::<dist::Std>()), - &[ - dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, - dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, - ] - ); + assert_eq!(first(cache.all::<dist::Docs>()), &[dist::Docs { host: a }, dist::Docs { + host: b + },]); + assert_eq!(first(cache.all::<dist::Mingw>()), &[dist::Mingw { host: a }, dist::Mingw { + host: b + },]); + assert_eq!(first(cache.all::<dist::Rustc>()), &[ + dist::Rustc { compiler: Compiler { host: a, stage: 2 } }, + dist::Rustc { compiler: Compiler { host: b, stage: 2 } }, + ]); + assert_eq!(first(cache.all::<dist::Std>()), &[ + dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a }, + dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b }, + ]); assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]); - assert_eq!( - first(cache.all::<compile::Std>()), - &[ - std!(A => A, stage = 0), - std!(A => A, stage = 1), - std!(A => A, stage = 2), - std!(A => B, stage = 1), - std!(A => B, stage = 2), - ] - ); - assert_eq!( - first(cache.all::<compile::Assemble>()), - &[ - compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } }, - compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } }, - compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } }, - compile::Assemble { target_compiler: Compiler { host: b, stage: 2 } }, - ] - ); + assert_eq!(first(cache.all::<compile::Std>()), &[ + std!(A => A, stage = 0), + std!(A => A, stage = 1), + std!(A => A, stage = 2), + std!(A => B, stage = 1), + std!(A => B, stage = 2), + ]); + assert_eq!(first(cache.all::<compile::Assemble>()), &[ + compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } }, + compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } }, + compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } }, + compile::Assemble { target_compiler: Compiler { host: b, stage: 2 } }, + ]); } #[test] fn build_all() { let build = Build::new(configure(&["A-A", "B-B"], &["A-A", "B-B", "C-C"])); let mut builder = Builder::new(&build); - builder.run_step_descriptions( - &Builder::get_step_descriptions(Kind::Build), - &["compiler/rustc".into(), "library".into()], - ); - - assert_eq!( - first(builder.cache.all::<compile::Std>()), - &[ - std!(A => A, stage = 0), - std!(A => A, stage = 1), - std!(A => A, stage = 2), - std!(A => B, stage = 1), - std!(A => B, stage = 2), - std!(A => C, stage = 2), - ] - ); + builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[ + "compiler/rustc".into(), + "library".into(), + ]); + + assert_eq!(first(builder.cache.all::<compile::Std>()), &[ + std!(A => A, stage = 0), + std!(A => A, stage = 1), + std!(A => A, stage = 2), + std!(A => B, stage = 1), + std!(A => B, stage = 2), + std!(A => C, stage = 2), + ]); assert_eq!(builder.cache.all::<compile::Assemble>().len(), 5); - assert_eq!( - first(builder.cache.all::<compile::Rustc>()), - &[ - rustc!(A => A, stage = 0), - rustc!(A => A, stage = 1), - rustc!(A => A, stage = 2), - rustc!(A => B, stage = 1), - rustc!(A => B, stage = 2), - ] - ); + assert_eq!(first(builder.cache.all::<compile::Rustc>()), &[ + rustc!(A => A, stage = 0), + rustc!(A => A, stage = 1), + rustc!(A => A, stage = 2), + rustc!(A => B, stage = 1), + rustc!(A => B, stage = 2), + ]); } #[test] @@ -608,22 +553,20 @@ mod dist { let a = TargetSelection::from_user("A-A"); - assert_eq!( - first(builder.cache.all::<compile::Std>()), - &[std!(A => A, stage = 0), std!(A => A, stage = 1), std!(A => C, stage = 2),] - ); - assert_eq!( - first(builder.cache.all::<compile::Assemble>()), - &[ - compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } }, - compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } }, - compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } }, - ] - ); - assert_eq!( - first(builder.cache.all::<compile::Rustc>()), - &[rustc!(A => A, stage = 0), rustc!(A => A, stage = 1),] - ); + assert_eq!(first(builder.cache.all::<compile::Std>()), &[ + std!(A => A, stage = 0), + std!(A => A, stage = 1), + std!(A => C, stage = 2), + ]); + assert_eq!(first(builder.cache.all::<compile::Assemble>()), &[ + compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } }, + compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } }, + compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } }, + ]); + assert_eq!(first(builder.cache.all::<compile::Rustc>()), &[ + rustc!(A => A, stage = 0), + rustc!(A => A, stage = 1), + ]); } #[test] @@ -652,22 +595,18 @@ mod dist { let host = TargetSelection::from_user("A-A"); - builder.run_step_descriptions( - &[StepDescription::from::<test::Crate>(Kind::Test)], - &["library/std".into()], - ); + builder.run_step_descriptions(&[StepDescription::from::<test::Crate>(Kind::Test)], &[ + "library/std".into(), + ]); // Ensure we don't build any compiler artifacts. assert!(!builder.cache.contains::<compile::Rustc>()); - assert_eq!( - first(builder.cache.all::<test::Crate>()), - &[test::Crate { - compiler: Compiler { host, stage: 0 }, - target: host, - mode: Mode::Std, - crates: vec!["std".to_owned()], - },] - ); + assert_eq!(first(builder.cache.all::<test::Crate>()), &[test::Crate { + compiler: Compiler { host, stage: 0 }, + target: host, + mode: Mode::Std, + crates: vec!["std".to_owned()], + },]); } #[test] @@ -686,16 +625,14 @@ mod dist { first(builder.cache.all::<doc::ErrorIndex>()), &[doc::ErrorIndex { target: a },] ); - assert_eq!( - first(builder.cache.all::<tool::ErrorIndex>()), - &[tool::ErrorIndex { compiler: Compiler { host: a, stage: 1 } }] - ); + assert_eq!(first(builder.cache.all::<tool::ErrorIndex>()), &[tool::ErrorIndex { + compiler: Compiler { host: a, stage: 1 } + }]); // This is actually stage 1, but Rustdoc::run swaps out the compiler with // stage minus 1 if --stage is not 0. Very confusing! - assert_eq!( - first(builder.cache.all::<tool::Rustdoc>()), - &[tool::Rustdoc { compiler: Compiler { host: a, stage: 2 } },] - ); + assert_eq!(first(builder.cache.all::<tool::Rustdoc>()), &[tool::Rustdoc { + compiler: Compiler { host: a, stage: 2 } + },]); } #[test] @@ -731,10 +668,9 @@ mod dist { first(builder.cache.all::<doc::ErrorIndex>()), &[doc::ErrorIndex { target: a },] ); - assert_eq!( - first(builder.cache.all::<tool::ErrorIndex>()), - &[tool::ErrorIndex { compiler: Compiler { host: a, stage: 1 } }] - ); + assert_eq!(first(builder.cache.all::<tool::ErrorIndex>()), &[tool::ErrorIndex { + compiler: Compiler { host: a, stage: 1 } + }]); // Unfortunately rustdoc is built twice. Once from stage1 for compiletest // (and other things), and once from stage0 for std crates. Ideally it // would only be built once. If someone wants to fix this, it might be @@ -746,13 +682,10 @@ mod dist { // The stage 0 copy is the one downloaded for bootstrapping. It is // (currently) needed to run "cargo test" on the linkchecker, and // should be relatively "free". - assert_eq!( - first(builder.cache.all::<tool::Rustdoc>()), - &[ - tool::Rustdoc { compiler: Compiler { host: a, stage: 0 } }, - tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }, - tool::Rustdoc { compiler: Compiler { host: a, stage: 2 } }, - ] - ); + assert_eq!(first(builder.cache.all::<tool::Rustdoc>()), &[ + tool::Rustdoc { compiler: Compiler { host: a, stage: 0 } }, + tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }, + tool::Rustdoc { compiler: Compiler { host: a, stage: 2 } }, + ]); } } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index dcecd7f8084..77e0ece3104 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -7,14 +7,14 @@ use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; use std::fmt::{self, Display}; use std::io::IsTerminal; -use std::path::{absolute, Path, PathBuf}; +use std::path::{Path, PathBuf, absolute}; use std::process::Command; use std::str::FromStr; use std::sync::OnceLock; use std::{cmp, env, fs}; use build_helper::exit; -use build_helper::git::{get_closest_merge_commit, output_result, GitConfig}; +use build_helper::git::{GitConfig, get_closest_merge_commit, output_result}; use serde::{Deserialize, Deserializer}; use serde_derive::Deserialize; @@ -22,7 +22,7 @@ use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX; use crate::core::build_steps::llvm; pub use crate::core::config::flags::Subcommand; use crate::core::config::flags::{Color, Flags, Warnings}; -use crate::utils::cache::{Interned, INTERNER}; +use crate::utils::cache::{INTERNER, Interned}; use crate::utils::channel::{self, GitInfo}; use crate::utils::helpers::{self, exe, output, t}; @@ -1745,14 +1745,11 @@ impl Config { config.rustc_default_linker = default_linker; config.musl_root = musl_root.map(PathBuf::from); config.save_toolstates = save_toolstates.map(PathBuf::from); - set( - &mut config.deny_warnings, - match flags.warnings { - Warnings::Deny => Some(true), - Warnings::Warn => Some(false), - Warnings::Default => deny_warnings, - }, - ); + set(&mut config.deny_warnings, match flags.warnings { + Warnings::Deny => Some(true), + Warnings::Warn => Some(false), + Warnings::Default => deny_warnings, + }); set(&mut config.backtrace_on_ice, backtrace_on_ice); set(&mut config.rust_verify_llvm_ir, verify_llvm_ir); config.rust_thin_lto_import_instr_limit = thin_lto_import_instr_limit; diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs index effc5f50911..87db5f93fb0 100644 --- a/src/bootstrap/src/core/config/flags.rs +++ b/src/bootstrap/src/core/config/flags.rs @@ -9,7 +9,7 @@ use clap::{CommandFactory, Parser, ValueEnum}; use crate::core::build_steps::setup::Profile; use crate::core::builder::{Builder, Kind}; -use crate::core::config::{target_selection_list, Config, TargetSelectionList}; +use crate::core::config::{Config, TargetSelectionList, target_selection_list}; use crate::{Build, DocTests}; #[derive(Copy, Clone, Default, Debug, ValueEnum)] diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs index a45e73b5d95..e38d4eac051 100644 --- a/src/bootstrap/src/core/config/tests.rs +++ b/src/bootstrap/src/core/config/tests.rs @@ -1,5 +1,5 @@ use std::env; -use std::fs::{remove_file, File}; +use std::fs::{File, remove_file}; use std::io::Write; use std::path::Path; diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index d8b39ac0b6d..444b75876f2 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -10,9 +10,9 @@ use build_helper::ci::CiEnv; use xz2::bufread::XzDecoder; use crate::core::config::BUILDER_CONFIG_FILENAME; -use crate::utils::exec::{command, BootstrapCommand}; +use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{check_run, exe, hex_encode, move_file, program_out_of_date}; -use crate::{t, Config}; +use crate::{Config, t}; static SHOULD_FIX_BINS_AND_DYLIBS: OnceLock<bool> = OnceLock::new(); diff --git a/src/bootstrap/src/core/metadata.rs b/src/bootstrap/src/core/metadata.rs index d665544f593..983674d2c68 100644 --- a/src/bootstrap/src/core/metadata.rs +++ b/src/bootstrap/src/core/metadata.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use serde_derive::Deserialize; use crate::utils::exec::command; -use crate::{t, Build, Crate}; +use crate::{Build, Crate, t}; /// For more information, see the output of /// <https://doc.rust-lang.org/nightly/cargo/commands/cargo-metadata.html> diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index e0790c5bf70..5425739c56f 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -15,6 +15,7 @@ use std::{env, fs}; use build_helper::git::warn_old_master_branch; +use crate::Build; #[cfg(not(feature = "bootstrap-self-test"))] use crate::builder::Builder; use crate::builder::Kind; @@ -22,7 +23,6 @@ use crate::builder::Kind; use crate::core::build_steps::tool; use crate::core::config::Target; use crate::utils::exec::command; -use crate::Build; pub struct Finder { cache: HashMap<OsString, Option<PathBuf>>, diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 4ed2c72fd55..88122237858 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -35,8 +35,8 @@ use utils::helpers::hex_encode; use crate::core::builder; use crate::core::builder::{Builder, Kind}; -use crate::core::config::{flags, DryRun, LldMode, LlvmLibunwind, Target, TargetSelection}; -use crate::utils::exec::{command, BehaviorOnFailure, BootstrapCommand, CommandOutput, OutputMode}; +use crate::core::config::{DryRun, LldMode, LlvmLibunwind, Target, TargetSelection, flags}; +use crate::utils::exec::{BehaviorOnFailure, BootstrapCommand, CommandOutput, OutputMode, command}; use crate::utils::helpers::{ self, dir_is_empty, exe, libdir, mtime, output, set_file_times, symlink_dir, }; @@ -45,11 +45,11 @@ mod core; mod utils; pub use core::builder::PathSet; -pub use core::config::flags::{Flags, Subcommand}; pub use core::config::Config; +pub use core::config::flags::{Flags, Subcommand}; pub use utils::change_tracker::{ - find_recent_config_change_ids, human_readable_changes, CONFIG_CHANGE_HISTORY, + CONFIG_CHANGE_HISTORY, find_recent_config_change_ids, human_readable_changes, }; const LLVM_TOOLS: &[&str] = &[ diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index c39415e7c18..0df00469452 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -26,7 +26,7 @@ use std::path::{Path, PathBuf}; use std::{env, iter}; use crate::core::config::TargetSelection; -use crate::utils::exec::{command, BootstrapCommand}; +use crate::utils::exec::{BootstrapCommand, command}; use crate::{Build, CLang, GitRepo}; // The `cc` crate doesn't provide a way to obtain a path to the detected archiver, diff --git a/src/bootstrap/src/utils/change_tracker/tests.rs b/src/bootstrap/src/utils/change_tracker/tests.rs index d2bfc07d172..730b65b4879 100644 --- a/src/bootstrap/src/utils/change_tracker/tests.rs +++ b/src/bootstrap/src/utils/change_tracker/tests.rs @@ -1,4 +1,4 @@ -use crate::{find_recent_config_change_ids, CONFIG_CHANGE_HISTORY}; +use crate::{CONFIG_CHANGE_HISTORY, find_recent_config_change_ids}; #[test] fn test_find_recent_config_change_ids() { diff --git a/src/bootstrap/src/utils/channel.rs b/src/bootstrap/src/utils/channel.rs index 3ae512ef7f1..c361abb9c9e 100644 --- a/src/bootstrap/src/utils/channel.rs +++ b/src/bootstrap/src/utils/channel.rs @@ -9,8 +9,8 @@ use std::fs; use std::path::Path; use super::helpers; -use crate::utils::helpers::{output, t}; use crate::Build; +use crate::utils::helpers::{output, t}; #[derive(Clone, Default)] pub enum GitInfo { diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 85246e390bc..2519ace92b9 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -12,10 +12,10 @@ use std::{env, fs, io, str}; use build_helper::util::fail; +use crate::LldMode; use crate::core::builder::Builder; use crate::core::config::{Config, TargetSelection}; pub use crate::utils::shared_helpers::{dylib_path, dylib_path_var}; -use crate::LldMode; #[cfg(test)] mod tests; @@ -46,7 +46,7 @@ macro_rules! t { } pub use t; -use crate::utils::exec::{command, BootstrapCommand}; +use crate::utils::exec::{BootstrapCommand, command}; pub fn exe(name: &str, target: TargetSelection) -> String { crate::utils::shared_helpers::exe(name, &target.triple) diff --git a/src/bootstrap/src/utils/helpers/tests.rs b/src/bootstrap/src/utils/helpers/tests.rs index 86016a91e49..f6fe6f47aa4 100644 --- a/src/bootstrap/src/utils/helpers/tests.rs +++ b/src/bootstrap/src/utils/helpers/tests.rs @@ -1,4 +1,4 @@ -use std::fs::{self, remove_file, File}; +use std::fs::{self, File, remove_file}; use std::io::Write; use std::path::PathBuf; diff --git a/src/bootstrap/src/utils/job.rs b/src/bootstrap/src/utils/job.rs index 4012f5167ff..c5e892450c4 100644 --- a/src/bootstrap/src/utils/job.rs +++ b/src/bootstrap/src/utils/job.rs @@ -43,19 +43,19 @@ mod for_windows { use std::ffi::c_void; use std::{env, io, mem}; - use windows::core::PCWSTR; - use windows::Win32::Foundation::{CloseHandle, DuplicateHandle, DUPLICATE_SAME_ACCESS, HANDLE}; + use windows::Win32::Foundation::{CloseHandle, DUPLICATE_SAME_ACCESS, DuplicateHandle, HANDLE}; use windows::Win32::System::Diagnostics::Debug::{ - SetErrorMode, SEM_NOGPFAULTERRORBOX, THREAD_ERROR_MODE, + SEM_NOGPFAULTERRORBOX, SetErrorMode, THREAD_ERROR_MODE, }; use windows::Win32::System::JobObjects::{ - AssignProcessToJobObject, CreateJobObjectW, JobObjectExtendedLimitInformation, - SetInformationJobObject, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, - JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, JOB_OBJECT_LIMIT_PRIORITY_CLASS, + AssignProcessToJobObject, CreateJobObjectW, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, + JOB_OBJECT_LIMIT_PRIORITY_CLASS, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, + JobObjectExtendedLimitInformation, SetInformationJobObject, }; use windows::Win32::System::Threading::{ - GetCurrentProcess, OpenProcess, BELOW_NORMAL_PRIORITY_CLASS, PROCESS_DUP_HANDLE, + BELOW_NORMAL_PRIORITY_CLASS, GetCurrentProcess, OpenProcess, PROCESS_DUP_HANDLE, }; + use windows::core::PCWSTR; use crate::Build; diff --git a/src/bootstrap/src/utils/metrics.rs b/src/bootstrap/src/utils/metrics.rs index e9acb93363e..3b31fa36e88 100644 --- a/src/bootstrap/src/utils/metrics.rs +++ b/src/bootstrap/src/utils/metrics.rs @@ -15,9 +15,9 @@ use build_helper::metrics::{ }; use sysinfo::{CpuRefreshKind, RefreshKind, System}; +use crate::Build; use crate::core::builder::{Builder, Step}; use crate::utils::helpers::t; -use crate::Build; // Update this number whenever a breaking change is made to the build metrics. // diff --git a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs index d75ee147799..89e4393cb5c 100644 --- a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs +++ b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs @@ -6,7 +6,7 @@ use core::{panic, ptr}; -use r_efi::efi::{Char16, Handle, Status, SystemTable, RESET_SHUTDOWN}; +use r_efi::efi::{Char16, Handle, RESET_SHUTDOWN, Status, SystemTable}; #[panic_handler] fn panic_handler(_info: &panic::PanicInfo) -> ! { diff --git a/src/etc/test-float-parse/src/gen/fuzz.rs b/src/etc/test-float-parse/src/gen/fuzz.rs index 213bcfc64af..0c63e8aae26 100644 --- a/src/etc/test-float-parse/src/gen/fuzz.rs +++ b/src/etc/test-float-parse/src/gen/fuzz.rs @@ -1,14 +1,14 @@ -use std::any::{type_name, TypeId}; +use std::any::{TypeId, type_name}; use std::collections::BTreeMap; use std::fmt::Write; use std::marker::PhantomData; use std::ops::Range; use std::sync::Mutex; -use rand::distributions::{Distribution, Standard}; use rand::Rng; -use rand_chacha::rand_core::SeedableRng; +use rand::distributions::{Distribution, Standard}; use rand_chacha::ChaCha8Rng; +use rand_chacha::rand_core::SeedableRng; use crate::{Float, Generator, Int, SEED}; diff --git a/src/etc/test-float-parse/src/lib.rs b/src/etc/test-float-parse/src/lib.rs index f36e3928d26..71b1aa06671 100644 --- a/src/etc/test-float-parse/src/lib.rs +++ b/src/etc/test-float-parse/src/lib.rs @@ -2,12 +2,12 @@ mod traits; mod ui; mod validate; -use std::any::{type_name, TypeId}; +use std::any::{TypeId, type_name}; use std::cmp::min; use std::ops::RangeInclusive; use std::process::ExitCode; use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{mpsc, OnceLock}; +use std::sync::{OnceLock, mpsc}; use std::{fmt, time}; use indicatif::{MultiProgress, ProgressBar}; diff --git a/src/etc/test-float-parse/src/traits.rs b/src/etc/test-float-parse/src/traits.rs index dc009ea235f..f5333d63b36 100644 --- a/src/etc/test-float-parse/src/traits.rs +++ b/src/etc/test-float-parse/src/traits.rs @@ -3,8 +3,8 @@ use std::str::FromStr; use std::{fmt, ops}; -use num::bigint::ToBigInt; use num::Integer; +use num::bigint::ToBigInt; use crate::validate::Constants; diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 7e3881c798b..08c88fc950d 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -4,14 +4,14 @@ use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData}; use rustc_middle::bug; use rustc_middle::ty::{self, Region, Ty}; use rustc_span::def_id::DefId; -use rustc_span::symbol::{kw, Symbol}; +use rustc_span::symbol::{Symbol, kw}; use rustc_trait_selection::traits::auto_trait::{self, RegionTarget}; use thin_vec::ThinVec; use tracing::{debug, instrument}; use crate::clean::{ - self, clean_generic_param_def, clean_middle_ty, clean_predicate, - clean_trait_ref_with_constraints, clean_ty_generics, simplify, Lifetime, + self, Lifetime, clean_generic_param_def, clean_middle_ty, clean_predicate, + clean_trait_ref_with_constraints, clean_ty_generics, simplify, }; use crate::core::DocContext; diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index 95f6616cec3..36821294885 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -2,8 +2,8 @@ use rustc_hir as hir; use rustc_infer::infer::{DefineOpaqueTypes, InferOk, TyCtxtInferExt}; use rustc_infer::traits; use rustc_middle::ty::{self, Upcast}; -use rustc_span::def_id::DefId; use rustc_span::DUMMY_SP; +use rustc_span::def_id::DefId; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use thin_vec::ThinVec; use tracing::{debug, instrument, trace}; diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index fb9754c7ffc..26739219085 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -10,8 +10,8 @@ use rustc_ast::{LitKind, MetaItem, MetaItemKind, NestedMetaItem}; use rustc_data_structures::fx::FxHashSet; use rustc_feature::Features; use rustc_session::parse::ParseSess; -use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{Symbol, sym}; use crate::html::escape::Escape; diff --git a/src/librustdoc/clean/cfg/tests.rs b/src/librustdoc/clean/cfg/tests.rs index a9b3abadb20..0ab655103e2 100644 --- a/src/librustdoc/clean/cfg/tests.rs +++ b/src/librustdoc/clean/cfg/tests.rs @@ -1,6 +1,6 @@ use rustc_ast::{MetaItemLit, Path, Safety, StrStyle}; -use rustc_span::symbol::{kw, Ident}; -use rustc_span::{create_default_session_globals_then, DUMMY_SP}; +use rustc_span::symbol::{Ident, kw}; +use rustc_span::{DUMMY_SP, create_default_session_globals_then}; use thin_vec::thin_vec; use super::*; @@ -267,13 +267,10 @@ fn test_parse_ok() { let mi = dummy_meta_item_list!(not, [a]); assert_eq!(Cfg::parse(&mi), Ok(!word_cfg("a"))); - let mi = dummy_meta_item_list!( - not, - [dummy_meta_item_list!( - any, - [dummy_meta_item_word("a"), dummy_meta_item_list!(all, [b, c]),] - ),] - ); + let mi = dummy_meta_item_list!(not, [dummy_meta_item_list!(any, [ + dummy_meta_item_word("a"), + dummy_meta_item_list!(all, [b, c]), + ]),]); assert_eq!(Cfg::parse(&mi), Ok(!(word_cfg("a") | (word_cfg("b") & word_cfg("c"))))); let mi = dummy_meta_item_list!(all, [a, b, c]); @@ -296,16 +293,18 @@ fn test_parse_err() { let mi = dummy_meta_item_list!(foo, []); assert!(Cfg::parse(&mi).is_err()); - let mi = dummy_meta_item_list!( - all, - [dummy_meta_item_list!(foo, []), dummy_meta_item_word("b"),] - ); + let mi = + dummy_meta_item_list!( + all, + [dummy_meta_item_list!(foo, []), dummy_meta_item_word("b"),] + ); assert!(Cfg::parse(&mi).is_err()); - let mi = dummy_meta_item_list!( - any, - [dummy_meta_item_word("a"), dummy_meta_item_list!(foo, []),] - ); + let mi = + dummy_meta_item_list!( + any, + [dummy_meta_item_word("a"), dummy_meta_item_list!(foo, []),] + ); assert!(Cfg::parse(&mi).is_err()); let mi = dummy_meta_item_list!(not, [dummy_meta_item_list!(foo, []),]); diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 8383012885f..701bf618096 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -4,25 +4,25 @@ use std::iter::once; use std::sync::Arc; use rustc_data_structures::fx::FxHashSet; +use rustc_hir::Mutability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId, LocalModDefId}; -use rustc_hir::Mutability; use rustc_metadata::creader::{CStore, LoadedMacro}; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::def_id::LOCAL_CRATE; use rustc_span::hygiene::MacroKind; -use rustc_span::symbol::{sym, Symbol}; -use thin_vec::{thin_vec, ThinVec}; +use rustc_span::symbol::{Symbol, sym}; +use thin_vec::{ThinVec, thin_vec}; use tracing::{debug, trace}; use {rustc_ast as ast, rustc_hir as hir}; use super::Item; use crate::clean::{ - self, clean_bound_vars, clean_generics, clean_impl_item, clean_middle_assoc_item, - clean_middle_field, clean_middle_ty, clean_poly_fn_sig, clean_trait_ref_with_constraints, - clean_ty, clean_ty_alias_inner_type, clean_ty_generics, clean_variant_def, utils, Attributes, - AttributesExt, ImplKind, ItemId, Type, + self, Attributes, AttributesExt, ImplKind, ItemId, Type, clean_bound_vars, clean_generics, + clean_impl_item, clean_middle_assoc_item, clean_middle_field, clean_middle_ty, + clean_poly_fn_sig, clean_trait_ref_with_constraints, clean_ty, clean_ty_alias_inner_type, + clean_ty_generics, clean_variant_def, utils, }; use crate::core::DocContext; use crate::formats::item_type::ItemType; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e47ae7df77f..3d845cf878f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -38,18 +38,18 @@ use rustc_ast::token::{Token, TokenKind}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, IndexEntry}; use rustc_errors::codes::*; -use rustc_errors::{struct_span_code_err, FatalError}; -use rustc_hir::def::{CtorKind, DefKind, Res}; -use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE}; +use rustc_errors::{FatalError, struct_span_code_err}; use rustc_hir::PredicateOrigin; +use rustc_hir::def::{CtorKind, DefKind, Res}; +use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE, LocalDefId}; use rustc_hir_analysis::lower_ty; use rustc_middle::metadata::Reexport; use rustc_middle::middle::resolve_bound_vars as rbv; use rustc_middle::ty::{self, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::{bug, span_bug}; -use rustc_span::hygiene::{AstPass, MacroKind}; -use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::ExpnKind; +use rustc_span::hygiene::{AstPass, MacroKind}; +use rustc_span::symbol::{Ident, Symbol, kw, sym}; use rustc_trait_selection::traits::wf::object_region_bounds; use thin_vec::ThinVec; use tracing::{debug, instrument}; @@ -536,18 +536,14 @@ fn clean_generic_param_def( } else { None }; - ( - def.name, - GenericParamDefKind::Type { - bounds: ThinVec::new(), // These are filled in from the where-clauses. - default: default.map(Box::new), - synthetic, - }, - ) + (def.name, GenericParamDefKind::Type { + bounds: ThinVec::new(), // These are filled in from the where-clauses. + default: default.map(Box::new), + synthetic, + }) } - ty::GenericParamDefKind::Const { has_default, synthetic, is_host_effect: _ } => ( - def.name, - GenericParamDefKind::Const { + ty::GenericParamDefKind::Const { has_default, synthetic, is_host_effect: _ } => { + (def.name, GenericParamDefKind::Const { ty: Box::new(clean_middle_ty( ty::Binder::dummy( cx.tcx @@ -569,8 +565,8 @@ fn clean_generic_param_def( None }, synthetic, - }, - ), + }) + } }; GenericParamDef { name, def_id: def.def_id, kind } @@ -615,25 +611,21 @@ fn clean_generic_param<'tcx>( } else { ThinVec::new() }; - ( - param.name.ident().name, - GenericParamDefKind::Type { - bounds, - default: default.map(|t| clean_ty(t, cx)).map(Box::new), - synthetic, - }, - ) + (param.name.ident().name, GenericParamDefKind::Type { + bounds, + default: default.map(|t| clean_ty(t, cx)).map(Box::new), + synthetic, + }) } - hir::GenericParamKind::Const { ty, default, synthetic, is_host_effect: _ } => ( - param.name.ident().name, - GenericParamDefKind::Const { + hir::GenericParamKind::Const { ty, default, synthetic, is_host_effect: _ } => { + (param.name.ident().name, GenericParamDefKind::Const { ty: Box::new(clean_ty(ty, cx)), default: default.map(|ct| { Box::new(ty::Const::from_const_arg(cx.tcx, ct, ty::FeedConstTy::No).to_string()) }), synthetic, - }, - ), + }) + } }; GenericParamDef { name, def_id: param.def_id.to_def_id(), kind } @@ -653,10 +645,9 @@ fn is_impl_trait(param: &hir::GenericParam<'_>) -> bool { /// /// See `lifetime_to_generic_param` in `rustc_ast_lowering` for more information. fn is_elided_lifetime(param: &hir::GenericParam<'_>) -> bool { - matches!( - param.kind, - hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(_) } - ) + matches!(param.kind, hir::GenericParamKind::Lifetime { + kind: hir::LifetimeParamKind::Elided(_) + }) } pub(crate) fn clean_generics<'tcx>( @@ -1055,10 +1046,11 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib .. } = param { - func.decl - .inputs - .values - .insert(a.get() as _, Argument { name, type_: *ty, is_const: true }); + func.decl.inputs.values.insert(a.get() as _, Argument { + name, + type_: *ty, + is_const: true, + }); } else { panic!("unexpected non const in position {pos}"); } @@ -1402,15 +1394,12 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo let bounds = tcx.explicit_item_bounds(assoc_item.def_id).iter_identity_copied(); predicates = tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied())); } - let mut generics = clean_ty_generics( - cx, - tcx.generics_of(assoc_item.def_id), - ty::GenericPredicates { + let mut generics = + clean_ty_generics(cx, tcx.generics_of(assoc_item.def_id), ty::GenericPredicates { parent: None, predicates, effects_min_tys: ty::List::empty(), - }, - ); + }); simplify::move_bounds_to_generic_parameters(&mut generics); if let ty::TraitContainer = assoc_item.container { diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs index 995919f73f8..d39ecf83ac0 100644 --- a/src/librustdoc/clean/render_macro_matchers.rs +++ b/src/librustdoc/clean/render_macro_matchers.rs @@ -1,11 +1,11 @@ use rustc_ast::token::{self, BinOpToken, Delimiter, IdentIsRaw}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; -use rustc_ast_pretty::pprust::state::State as Printer; use rustc_ast_pretty::pprust::PrintState; +use rustc_ast_pretty::pprust::state::State as Printer; use rustc_middle::ty::TyCtxt; use rustc_session::parse::ParseSess; -use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{Ident, Symbol, kw}; /// Render a macro matcher in a format suitable for displaying to the user /// as part of an item declaration. diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 383efe568ae..31710bc014a 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -12,7 +12,7 @@ use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel, StableS use rustc_const_eval::const_eval::is_unstable_const_fn; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def::{CtorKind, DefKind, Res}; -use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; +use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::lang_items::LangItem; use rustc_hir::{BodyId, Mutability}; use rustc_hir_analysis::check::intrinsic::intrinsic_operation_unsafety; @@ -22,12 +22,12 @@ use rustc_middle::span_bug; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::{self, TyCtxt, Visibility}; use rustc_resolve::rustdoc::{ - add_doc_fragment, attrs_to_doc_fragments, inner_docs, span_of_fragments, DocFragment, + DocFragment, add_doc_fragment, attrs_to_doc_fragments, inner_docs, span_of_fragments, }; use rustc_session::Session; use rustc_span::hygiene::MacroKind; -use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::{FileName, Loc, DUMMY_SP}; +use rustc_span::symbol::{Ident, Symbol, kw, sym}; +use rustc_span::{DUMMY_SP, FileName, Loc}; use rustc_target::abi::VariantIdx; use rustc_target::spec::abi::Abi; use thin_vec::ThinVec; @@ -1064,10 +1064,14 @@ impl AttributesExt for [ast::Attribute] { } impl AttributesExt for [(Cow<'_, ast::Attribute>, Option<DefId>)] { - type AttributeIterator<'a> = impl Iterator<Item = ast::NestedMetaItem> + 'a - where Self: 'a; - type Attributes<'a> = impl Iterator<Item = &'a ast::Attribute> + 'a - where Self: 'a; + type AttributeIterator<'a> + = impl Iterator<Item = ast::NestedMetaItem> + 'a + where + Self: 'a; + type Attributes<'a> + = impl Iterator<Item = &'a ast::Attribute> + 'a + where + Self: 'a; fn lists(&self, name: Symbol) -> Self::AttributeIterator<'_> { AttributesExt::iter(self) @@ -1809,8 +1813,8 @@ impl PrimitiveType { } pub(crate) fn simplified_types() -> &'static SimplifiedTypes { - use ty::{FloatTy, IntTy, UintTy}; use PrimitiveType::*; + use ty::{FloatTy, IntTy, UintTy}; static CELL: OnceCell<SimplifiedTypes> = OnceCell::new(); let single = |x| iter::once(x).collect(); diff --git a/src/librustdoc/clean/types/tests.rs b/src/librustdoc/clean/types/tests.rs index ddf6a11ec4e..7ff5026150b 100644 --- a/src/librustdoc/clean/types/tests.rs +++ b/src/librustdoc/clean/types/tests.rs @@ -1,4 +1,4 @@ -use rustc_resolve::rustdoc::{unindent_doc_fragments, DocFragmentKind}; +use rustc_resolve::rustdoc::{DocFragmentKind, unindent_doc_fragments}; use rustc_span::create_default_session_globals_then; use super::*; diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 885758c17cf..b91c1725d0c 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -5,12 +5,12 @@ use std::sync::LazyLock as Lazy; use rustc_ast::tokenstream::TokenTree; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE}; +use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; use rustc_metadata::rendered_const; use rustc_middle::mir; use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt, TypeVisitableExt}; -use rustc_span::symbol::{kw, sym, Symbol}; -use thin_vec::{thin_vec, ThinVec}; +use rustc_span::symbol::{Symbol, kw, sym}; +use thin_vec::{ThinVec, thin_vec}; use tracing::{debug, warn}; use {rustc_ast as ast, rustc_hir as hir}; @@ -18,10 +18,10 @@ use crate::clean::auto_trait::synthesize_auto_trait_impls; use crate::clean::blanket_impl::synthesize_blanket_impls; use crate::clean::render_macro_matchers::render_macro_matcher; use crate::clean::{ - clean_doc_module, clean_middle_const, clean_middle_region, clean_middle_ty, inline, AssocItemConstraint, AssocItemConstraintKind, Crate, ExternalCrate, Generic, GenericArg, GenericArgs, ImportSource, Item, ItemKind, Lifetime, Path, PathSegment, Primitive, - PrimitiveType, Term, Type, + PrimitiveType, Term, Type, clean_doc_module, clean_middle_const, clean_middle_region, + clean_middle_ty, inline, }; use crate::core::DocContext; use crate::html::format::visibility_to_src_with_space; diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index b3c87a72508..7a37f5c70a5 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -8,15 +8,15 @@ use std::{fmt, io}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::DiagCtxtHandle; use rustc_session::config::{ - self, get_cmd_lint_options, nightly_options, parse_crate_types_from_list, parse_externs, - parse_target_triple, CodegenOptions, CrateType, ErrorOutputType, Externs, Input, - JsonUnusedExterns, UnstableOptions, + self, CodegenOptions, CrateType, ErrorOutputType, Externs, Input, JsonUnusedExterns, + UnstableOptions, get_cmd_lint_options, nightly_options, parse_crate_types_from_list, + parse_externs, parse_target_triple, }; use rustc_session::lint::Level; use rustc_session::search_paths::SearchPath; -use rustc_session::{getopts, EarlyDiagCtxt}; -use rustc_span::edition::Edition; +use rustc_session::{EarlyDiagCtxt, getopts}; use rustc_span::FileName; +use rustc_span::edition::Edition; use rustc_target::spec::TargetTriple; use crate::core::new_dcx; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index b5648bf2c13..8e46d93c28e 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::unord::UnordSet; use rustc_errors::codes::*; -use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter}; +use rustc_errors::emitter::{DynEmitter, HumanEmitter, stderr_destination}; use rustc_errors::json::JsonEmitter; use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, TerminalUrl}; use rustc_feature::UnstableFeatures; @@ -17,14 +17,14 @@ use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId}; use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{HirId, Path}; use rustc_interface::interface; -use rustc_lint::{late_lint_mod, MissingDoc}; +use rustc_lint::{MissingDoc, late_lint_mod}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; use rustc_session::config::{self, CrateType, ErrorOutputType, Input, ResolveDocLinks}; pub(crate) use rustc_session::config::{Options, UnstableOptions}; -use rustc_session::{lint, Session}; +use rustc_session::{Session, lint}; use rustc_span::symbol::sym; -use rustc_span::{source_map, Span}; +use rustc_span::{Span, source_map}; use tracing::{debug, info}; use crate::clean::inline::build_external_trait; diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 73eafaf78ca..3ee6b24ac92 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -16,14 +16,14 @@ pub(crate) use markdown::test as test_markdown; use rustc_ast as ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{ColorConfig, DiagCtxtHandle, ErrorGuaranteed, FatalError}; -use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::CRATE_HIR_ID; +use rustc_hir::def_id::LOCAL_CRATE; use rustc_interface::interface; use rustc_session::config::{self, CrateType, ErrorOutputType, Input}; use rustc_session::lint; +use rustc_span::FileName; use rustc_span::edition::Edition; use rustc_span::symbol::sym; -use rustc_span::FileName; use rustc_target::spec::{Target, TargetTriple}; use tempfile::{Builder as TempFileBuilder, TempDir}; use tracing::debug; diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index f4d9b78cc32..d560e3a476b 100644 --- a/src/librustdoc/doctest/make.rs +++ b/src/librustdoc/doctest/make.rs @@ -10,10 +10,10 @@ use rustc_errors::{ColorConfig, FatalError}; use rustc_parse::new_parser_from_source_str; use rustc_parse::parser::attr::InnerAttrPolicy; use rustc_session::parse::ParseSess; +use rustc_span::FileName; use rustc_span::edition::Edition; use rustc_span::source_map::SourceMap; use rustc_span::symbol::sym; -use rustc_span::FileName; use tracing::debug; use super::GlobalTestOptions; @@ -252,8 +252,8 @@ fn parse_source( info: &mut ParseSourceInfo, crate_name: &Option<&str>, ) -> ParsingResult { - use rustc_errors::emitter::{Emitter, HumanEmitter}; use rustc_errors::DiagCtxt; + use rustc_errors::emitter::{Emitter, HumanEmitter}; use rustc_parse::parser::ForceCollect; use rustc_span::source_map::FilePathMapping; @@ -441,8 +441,8 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> Option<AttrKind> rustc_driver::catch_fatal_errors(|| { rustc_span::create_session_if_not_set_then(edition, |_| { - use rustc_errors::emitter::HumanEmitter; use rustc_errors::DiagCtxt; + use rustc_errors::emitter::HumanEmitter; use rustc_span::source_map::FilePathMapping; let filename = FileName::anon_source_code(source); diff --git a/src/librustdoc/doctest/markdown.rs b/src/librustdoc/doctest/markdown.rs index 4f83bd5e882..a0d39ce749d 100644 --- a/src/librustdoc/doctest/markdown.rs +++ b/src/librustdoc/doctest/markdown.rs @@ -8,10 +8,10 @@ use rustc_span::FileName; use tempfile::tempdir; use super::{ - generate_args_file, CreateRunnableDocTests, DocTestVisitor, GlobalTestOptions, ScrapedDocTest, + CreateRunnableDocTests, DocTestVisitor, GlobalTestOptions, ScrapedDocTest, generate_args_file, }; use crate::config::Options; -use crate::html::markdown::{find_testable_code, ErrorCodes, LangString, MdRelLine}; +use crate::html::markdown::{ErrorCodes, LangString, MdRelLine, find_testable_code}; struct MdCollector { tests: Vec<ScrapedDocTest>, diff --git a/src/librustdoc/doctest/runner.rs b/src/librustdoc/doctest/runner.rs index 9cb220ef7ba..326ca4ee1e6 100644 --- a/src/librustdoc/doctest/runner.rs +++ b/src/librustdoc/doctest/runner.rs @@ -4,8 +4,8 @@ use rustc_data_structures::fx::FxHashSet; use rustc_span::edition::Edition; use crate::doctest::{ - run_test, DocTestBuilder, GlobalTestOptions, IndividualTestOptions, RunnableDocTest, - RustdocOptions, ScrapedDocTest, TestFailure, UnusedExterns, + DocTestBuilder, GlobalTestOptions, IndividualTestOptions, RunnableDocTest, RustdocOptions, + ScrapedDocTest, TestFailure, UnusedExterns, run_test, }; use crate::html::markdown::{Ignore, LangString}; diff --git a/src/librustdoc/doctest/rust.rs b/src/librustdoc/doctest/rust.rs index 71a0e3d72de..cc85a73430b 100644 --- a/src/librustdoc/doctest/rust.rs +++ b/src/librustdoc/doctest/rust.rs @@ -4,19 +4,19 @@ use std::env; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; -use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID}; -use rustc_hir::{self as hir, intravisit, CRATE_HIR_ID}; +use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId}; +use rustc_hir::{self as hir, CRATE_HIR_ID, intravisit}; use rustc_middle::hir::map::Map; use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt; use rustc_resolve::rustdoc::span_of_fragments; use rustc_session::Session; use rustc_span::source_map::SourceMap; -use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP}; +use rustc_span::{BytePos, DUMMY_SP, FileName, Pos, Span}; use super::{DocTestVisitor, ScrapedDocTest}; -use crate::clean::types::AttributesExt; use crate::clean::Attributes; +use crate::clean::types::AttributesExt; use crate::html::markdown::{self, ErrorCodes, LangString, MdRelLine}; struct RustCollector { diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 1b3176e7918..8597d2e2b63 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -10,12 +10,12 @@ use crate::clean::types::ExternalLocation; use crate::clean::{self, ExternalCrate, ItemId, PrimitiveType}; use crate::core::DocContext; use crate::fold::DocFolder; -use crate::formats::item_type::ItemType; use crate::formats::Impl; +use crate::formats::item_type::ItemType; use crate::html::format::join_with_double_colon; use crate::html::markdown::short_markdown_summary; -use crate::html::render::search_index::get_function_type_for_search; use crate::html::render::IndexItem; +use crate::html::render::search_index::get_function_type_for_search; use crate::visit_lib::RustdocEffectiveVisibilities; /// This cache is used to store information about the [`clean::Crate`] being diff --git a/src/librustdoc/formats/mod.rs b/src/librustdoc/formats/mod.rs index 0bdea36043c..2e8b5d9f594 100644 --- a/src/librustdoc/formats/mod.rs +++ b/src/librustdoc/formats/mod.rs @@ -2,7 +2,7 @@ pub(crate) mod cache; pub(crate) mod item_type; pub(crate) mod renderer; -pub(crate) use renderer::{run_format, FormatRenderer}; +pub(crate) use renderer::{FormatRenderer, run_format}; use rustc_hir::def_id::DefId; use crate::clean::{self, ItemId}; diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index cf362272d7d..2e70a8c080d 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -22,12 +22,12 @@ use rustc_metadata::creader::{CStore, LoadedMacro}; use rustc_middle::ty; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::kw; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; use rustc_target::spec::abi::Abi; use tracing::{debug, trace}; use {rustc_ast as ast, rustc_hir as hir}; -use super::url_parts_builder::{estimate_item_path_byte_length, UrlPartsBuilder}; +use super::url_parts_builder::{UrlPartsBuilder, estimate_item_path_byte_length}; use crate::clean::types::ExternalLocation; use crate::clean::utils::find_nearest_parent_module; use crate::clean::{self, ExternalCrate, PrimitiveType}; diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index e728da67dc2..69b3421f888 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -12,7 +12,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_lexer::{Cursor, LiteralKind, TokenKind}; use rustc_span::edition::Edition; use rustc_span::symbol::Symbol; -use rustc_span::{BytePos, Span, DUMMY_SP}; +use rustc_span::{BytePos, DUMMY_SP, Span}; use super::format::{self, Buffer}; use crate::clean::PrimitiveType; @@ -72,34 +72,26 @@ fn write_header( tooltip: Tooltip, extra_classes: &[String], ) { - write!( - out, - "<div class=\"example-wrap{}\">", - match tooltip { - Tooltip::Ignore => " ignore", - Tooltip::CompileFail => " compile_fail", - Tooltip::ShouldPanic => " should_panic", - Tooltip::Edition(_) => " edition", - Tooltip::None => "", - }, - ); + write!(out, "<div class=\"example-wrap{}\">", match tooltip { + Tooltip::Ignore => " ignore", + Tooltip::CompileFail => " compile_fail", + Tooltip::ShouldPanic => " should_panic", + Tooltip::Edition(_) => " edition", + Tooltip::None => "", + },); if tooltip != Tooltip::None { let edition_code; - write!( - out, - "<a href=\"#\" class=\"tooltip\" title=\"{}\">ⓘ</a>", - match tooltip { - Tooltip::Ignore => "This example is not tested", - Tooltip::CompileFail => "This example deliberately fails to compile", - Tooltip::ShouldPanic => "This example panics", - Tooltip::Edition(edition) => { - edition_code = format!("This example runs with edition {edition}"); - &edition_code - } - Tooltip::None => unreachable!(), - }, - ); + write!(out, "<a href=\"#\" class=\"tooltip\" title=\"{}\">ⓘ</a>", match tooltip { + Tooltip::Ignore => "This example is not tested", + Tooltip::CompileFail => "This example deliberately fails to compile", + Tooltip::ShouldPanic => "This example panics", + Tooltip::Edition(edition) => { + edition_code = format!("This example runs with edition {edition}"); + &edition_code + } + Tooltip::None => unreachable!(), + },); } if let Some(extra) = extra_content { diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs index 9d511018dec..75328e724fe 100644 --- a/src/librustdoc/html/highlight/tests.rs +++ b/src/librustdoc/html/highlight/tests.rs @@ -2,7 +2,7 @@ use expect_test::expect_file; use rustc_data_structures::fx::FxHashMap; use rustc_span::create_default_session_globals_then; -use super::{write_code, DecorationInfo}; +use super::{DecorationInfo, write_code}; use crate::html::format::Buffer; const STYLE: &str = r#" diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 780cda9b1cd..3684dc42ac7 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -3,10 +3,10 @@ use std::path::PathBuf; use rinja::Template; use rustc_data_structures::fx::FxHashMap; -use super::static_files::{StaticFiles, STATIC_FILES}; +use super::static_files::{STATIC_FILES, StaticFiles}; use crate::externalfiles::ExternalHtml; use crate::html::format::{Buffer, Print}; -use crate::html::render::{ensure_trailing_slash, StylePath}; +use crate::html::render::{StylePath, ensure_trailing_slash}; #[derive(Clone)] pub(crate) struct Layout { diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 050ba60318e..b18d621478c 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -35,8 +35,8 @@ use std::str::{self, CharIndices}; use std::sync::OnceLock; use pulldown_cmark::{ - html, BrokenLink, BrokenLinkCallback, CodeBlockKind, CowStr, Event, LinkType, OffsetIter, - Options, Parser, Tag, TagEnd, + BrokenLink, BrokenLinkCallback, CodeBlockKind, CowStr, Event, LinkType, OffsetIter, Options, + Parser, Tag, TagEnd, html, }; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Diag, DiagMessage}; diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index 3ec60c0efd2..2001a763c09 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -1,8 +1,8 @@ -use rustc_span::edition::{Edition, DEFAULT_EDITION}; +use rustc_span::edition::{DEFAULT_EDITION, Edition}; use super::{ - find_testable_code, plain_text_summary, short_markdown_summary, ErrorCodes, HeadingOffset, - IdMap, Ignore, LangString, LangStringToken, Markdown, MarkdownItemInfo, TagIterator, + ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, LangStringToken, Markdown, + MarkdownItemInfo, TagIterator, find_testable_code, plain_text_summary, short_markdown_summary, }; #[test] @@ -275,14 +275,14 @@ fn test_lang_string_tokenizer() { case("foo", &[LangStringToken::LangToken("foo")]); case("foo,bar", &[LangStringToken::LangToken("foo"), LangStringToken::LangToken("bar")]); case(".foo,.bar", &[]); - case( - "{.foo,.bar}", - &[LangStringToken::ClassAttribute("foo"), LangStringToken::ClassAttribute("bar")], - ); - case( - " {.foo,.bar} ", - &[LangStringToken::ClassAttribute("foo"), LangStringToken::ClassAttribute("bar")], - ); + case("{.foo,.bar}", &[ + LangStringToken::ClassAttribute("foo"), + LangStringToken::ClassAttribute("bar"), + ]); + case(" {.foo,.bar} ", &[ + LangStringToken::ClassAttribute("foo"), + LangStringToken::ClassAttribute("bar"), + ]); case("foo bar", &[LangStringToken::LangToken("foo"), LangStringToken::LangToken("bar")]); case("foo\tbar", &[LangStringToken::LangToken("foo"), LangStringToken::LangToken("bar")]); case("foo\t, bar", &[LangStringToken::LangToken("foo"), LangStringToken::LangToken("bar")]); diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index a9b9377c0b9..bce3f218908 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -3,7 +3,7 @@ use std::collections::BTreeMap; use std::io; use std::path::{Path, PathBuf}; use std::rc::Rc; -use std::sync::mpsc::{channel, Receiver}; +use std::sync::mpsc::{Receiver, channel}; use rinja::Template; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -11,24 +11,24 @@ use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE}; use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::edition::Edition; -use rustc_span::{sym, FileName, Symbol}; +use rustc_span::{FileName, Symbol, sym}; use tracing::info; use super::print_item::{full_path, item_path, print_item}; -use super::sidebar::{print_sidebar, sidebar_module_like, ModuleLike, Sidebar}; -use super::{collect_spans_and_sources, scrape_examples_help, AllTypes, LinkFromSrc, StylePath}; +use super::sidebar::{ModuleLike, Sidebar, print_sidebar, sidebar_module_like}; +use super::{AllTypes, LinkFromSrc, StylePath, collect_spans_and_sources, scrape_examples_help}; use crate::clean::types::ExternalLocation; use crate::clean::utils::has_doc_flag; use crate::clean::{self, ExternalCrate}; use crate::config::{ModuleSorting, RenderOptions, ShouldMerge}; use crate::docfs::{DocFS, PathError}; use crate::error::Error; +use crate::formats::FormatRenderer; use crate::formats::cache::Cache; use crate::formats::item_type::ItemType; -use crate::formats::FormatRenderer; use crate::html::escape::Escape; -use crate::html::format::{join_with_double_colon, Buffer}; -use crate::html::markdown::{self, plain_text_summary, ErrorCodes, IdMap}; +use crate::html::format::{Buffer, join_with_double_colon}; +use crate::html::markdown::{self, ErrorCodes, IdMap, plain_text_summary}; use crate::html::render::write_shared::write_shared; use crate::html::url_parts_builder::UrlPartsBuilder; use crate::html::{layout, sources, static_files}; diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 668bd391348..227df0c5f39 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -48,30 +48,30 @@ use rinja::Template; use rustc_attr::{ConstStability, DeprecatedSince, Deprecation, StabilityLevel, StableSince}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_hir::def_id::{DefId, DefIdSet}; use rustc_hir::Mutability; +use rustc_hir::def_id::{DefId, DefIdSet}; use rustc_middle::ty::print::PrintTraitRefExt; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::RustcVersion; -use rustc_span::symbol::{sym, Symbol}; -use rustc_span::{BytePos, FileName, RealFileName, DUMMY_SP}; +use rustc_span::symbol::{Symbol, sym}; +use rustc_span::{BytePos, DUMMY_SP, FileName, RealFileName}; use serde::ser::SerializeMap; use serde::{Serialize, Serializer}; use tracing::{debug, info}; pub(crate) use self::context::*; -pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc}; +pub(crate) use self::span_map::{LinkFromSrc, collect_spans_and_sources}; pub(crate) use self::write_shared::*; use crate::clean::{self, ItemId, RenderedLink}; use crate::error::Error; +use crate::formats::Impl; use crate::formats::cache::Cache; use crate::formats::item_type::ItemType; -use crate::formats::Impl; use crate::html::escape::Escape; use crate::html::format::{ - display_fn, href, join_with_double_colon, print_abi_with_space, print_constness_with_space, - print_default_space, print_generic_bounds, print_where_clause, visibility_print_with_space, - Buffer, Ending, HrefError, PrintWithSpace, + Buffer, Ending, HrefError, PrintWithSpace, display_fn, href, join_with_double_colon, + print_abi_with_space, print_constness_with_space, print_default_space, print_generic_bounds, + print_where_clause, visibility_print_with_space, }; use crate::html::markdown::{ HeadingOffset, IdMap, Markdown, MarkdownItemInfo, MarkdownSummaryLine, @@ -79,7 +79,7 @@ use crate::html::markdown::{ use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD; use crate::html::{highlight, sources}; use crate::scrape_examples::{CallData, CallLocation}; -use crate::{try_none, DOC_RUST_LANG_ORG_CHANNEL}; +use crate::{DOC_RUST_LANG_ORG_CHANNEL, try_none}; pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ { crate::html::format::display_fn(move |f| { diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 52e25152770..d120e7f36eb 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -13,27 +13,27 @@ use rustc_hir::def_id::DefId; use rustc_index::IndexVec; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::hygiene::MacroKind; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{Symbol, kw, sym}; use rustc_target::abi::VariantIdx; use tracing::{debug, info}; use super::type_layout::document_type_layout; use super::{ + AssocItemLink, AssocItemRender, Context, ImplRenderingParameters, RenderMode, collect_paths_for_type, document, ensure_trailing_slash, get_filtered_impls_for_reference, item_ty_to_section, notable_traits_button, notable_traits_json, render_all_impls, render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre, render_impl, render_rightside, render_stability_since_raw, - render_stability_since_raw_with_extra, write_section_heading, AssocItemLink, AssocItemRender, - Context, ImplRenderingParameters, RenderMode, + render_stability_since_raw_with_extra, write_section_heading, }; use crate::clean; use crate::config::ModuleSorting; -use crate::formats::item_type::ItemType; use crate::formats::Impl; +use crate::formats::item_type::ItemType; use crate::html::escape::{Escape, EscapeBodyTextWithWbr}; use crate::html::format::{ - display_fn, join_with_double_colon, print_abi_with_space, print_constness_with_space, - print_where_clause, visibility_print_with_space, Buffer, Ending, PrintWithSpace, + Buffer, Ending, PrintWithSpace, display_fn, join_with_double_colon, print_abi_with_space, + print_constness_with_space, print_where_clause, visibility_print_with_space, }; use crate::html::highlight; use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine}; diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 86b719c46e8..660ca3b2594 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_middle::ty::TyCtxt; use rustc_span::def_id::DefId; use rustc_span::sym; -use rustc_span::symbol::{kw, Symbol}; +use rustc_span::symbol::{Symbol, kw}; use serde::ser::{Serialize, SerializeSeq, SerializeStruct, Serializer}; use thin_vec::ThinVec; use tracing::instrument; @@ -1169,14 +1169,13 @@ fn simplify_fn_type<'a, 'tcx>( *stored_bounds = type_bounds; } } - ty_constraints.push(( - RenderTypeId::AssociatedType(name), - vec![RenderType { + ty_constraints.push((RenderTypeId::AssociatedType(name), vec![ + RenderType { id: Some(RenderTypeId::Index(idx)), generics: None, bindings: None, - }], - )) + }, + ])) } } } diff --git a/src/librustdoc/html/render/sidebar.rs b/src/librustdoc/html/render/sidebar.rs index 842ee81624e..e7706e7fdea 100644 --- a/src/librustdoc/html/render/sidebar.rs +++ b/src/librustdoc/html/render/sidebar.rs @@ -8,10 +8,10 @@ use rustc_hir::def_id::DefIdSet; use rustc_middle::ty::{self, TyCtxt}; use tracing::debug; -use super::{item_ty_to_section, Context, ItemSection}; +use super::{Context, ItemSection, item_ty_to_section}; use crate::clean; -use crate::formats::item_type::ItemType; use crate::formats::Impl; +use crate::formats::item_type::ItemType; use crate::html::format::Buffer; use crate::html::markdown::{IdMap, MarkdownWithToc}; diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index 5b53277c059..2143f1ff236 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -10,7 +10,7 @@ use rustc_middle::ty::TyCtxt; use rustc_span::hygiene::MacroKind; use rustc_span::{BytePos, ExpnKind, Span}; -use crate::clean::{self, rustc_span, PrimitiveType}; +use crate::clean::{self, PrimitiveType, rustc_span}; use crate::html::sources; /// This enum allows us to store two different kinds of information: diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index dc1a8cca6bc..16253799215 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -29,26 +29,26 @@ use itertools::Itertools; use regex::Regex; use rustc_data_structures::flock; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::TyCtxt; -use rustc_span::def_id::DefId; +use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_span::Symbol; +use rustc_span::def_id::DefId; use serde::de::DeserializeOwned; use serde::ser::SerializeSeq; use serde::{Deserialize, Serialize, Serializer}; -use super::{collect_paths_for_type, ensure_trailing_slash, Context, RenderMode}; +use super::{Context, RenderMode, collect_paths_for_type, ensure_trailing_slash}; use crate::clean::{Crate, Item, ItemId, ItemKind}; use crate::config::{EmitType, PathToParts, RenderOptions, ShouldMerge}; use crate::docfs::PathError; use crate::error::Error; +use crate::formats::Impl; use crate::formats::cache::Cache; use crate::formats::item_type::ItemType; -use crate::formats::Impl; use crate::html::format::Buffer; use crate::html::layout; use crate::html::render::ordered_json::{EscapedJson, OrderedJson}; -use crate::html::render::search_index::{build_index, SerializedSearchIndex}; +use crate::html::render::search_index::{SerializedSearchIndex, build_index}; use crate::html::render::sorted_template::{self, FileFormat, SortedTemplate}; use crate::html::render::{AssocItemLink, ImplRenderingParameters, StylePath}; use crate::html::static_files::{self, suffix_path}; diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index 0d6a4603cd2..c8c45b8fa32 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -10,7 +10,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_span::{sym, FileName}; +use rustc_span::{FileName, sym}; use tracing::info; use crate::clean; diff --git a/src/librustdoc/html/tests.rs b/src/librustdoc/html/tests.rs index 059f99c0c9e..b568942bbcb 100644 --- a/src/librustdoc/html/tests.rs +++ b/src/librustdoc/html/tests.rs @@ -1,4 +1,4 @@ -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; use crate::html::format::href_relative_parts; diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 82ce619a19d..b411f9a1a52 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -19,8 +19,8 @@ use rustc_target::spec::abi::Abi as RustcAbi; use rustdoc_json_types::*; use crate::clean::{self, ItemId}; -use crate::formats::item_type::ItemType; use crate::formats::FormatRenderer; +use crate::formats::item_type::ItemType; use crate::json::JsonRenderer; use crate::passes::collect_intra_doc_links::UrlFragment; diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index f30a34cdccf..7f82fb5c686 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -8,8 +8,8 @@ mod conversions; mod import_finder; use std::cell::RefCell; -use std::fs::{create_dir_all, File}; -use std::io::{stdout, BufWriter, Write}; +use std::fs::{File, create_dir_all}; +use std::io::{BufWriter, Write, stdout}; use std::path::PathBuf; use std::rc::Rc; @@ -24,14 +24,14 @@ use rustdoc_json_types as types; use rustdoc_json_types::FxHashMap; use tracing::{debug, trace}; -use crate::clean::types::{ExternalCrate, ExternalLocation}; use crate::clean::ItemKind; +use crate::clean::types::{ExternalCrate, ExternalLocation}; use crate::config::RenderOptions; use crate::docfs::PathError; use crate::error::Error; -use crate::formats::cache::Cache; use crate::formats::FormatRenderer; -use crate::json::conversions::{id_from_item, id_from_item_default, IntoWithTcx}; +use crate::formats::cache::Cache; +use crate::json::conversions::{IntoWithTcx, id_from_item, id_from_item_default}; use crate::{clean, try_err}; #[derive(Clone)] @@ -253,14 +253,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { .iter() .chain(&self.cache.external_paths) .map(|(&k, &(ref path, kind))| { - ( - id_from_item_default(k.into(), self.tcx), - types::ItemSummary { - crate_id: k.krate.as_u32(), - path: path.iter().map(|s| s.to_string()).collect(), - kind: kind.into_tcx(self.tcx), - }, - ) + (id_from_item_default(k.into(), self.tcx), types::ItemSummary { + crate_id: k.krate.as_u32(), + path: path.iter().map(|s| s.to_string()).collect(), + kind: kind.into_tcx(self.tcx), + }) }) .collect(), external_crates: self @@ -269,16 +266,13 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { .iter() .map(|(crate_num, external_location)| { let e = ExternalCrate { crate_num: *crate_num }; - ( - crate_num.as_u32(), - types::ExternalCrate { - name: e.name(self.tcx).to_string(), - html_root_url: match external_location { - ExternalLocation::Remote(s) => Some(s.clone()), - _ => None, - }, + (crate_num.as_u32(), types::ExternalCrate { + name: e.name(self.tcx).to_string(), + html_root_url: match external_location { + ExternalLocation::Remote(s) => Some(s.clone()), + _ => None, }, - ) + }) }) .collect(), format_version: types::FORMAT_VERSION, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 6649e1721a4..f210873e696 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -73,14 +73,14 @@ extern crate jemalloc_sys; use std::env::{self, VarError}; use std::io::{self, IsTerminal}; use std::process; -use std::sync::atomic::AtomicBool; use std::sync::Arc; +use std::sync::atomic::AtomicBool; use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError}; use rustc_interface::interface; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{make_crate_type_option, ErrorOutputType, RustcOptGroup}; -use rustc_session::{getopts, EarlyDiagCtxt}; +use rustc_session::config::{ErrorOutputType, RustcOptGroup, make_crate_type_option}; +use rustc_session::{EarlyDiagCtxt, getopts}; use tracing::info; use crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL; diff --git a/src/librustdoc/lint.rs b/src/librustdoc/lint.rs index 754ba58648d..bdfdeeabc5a 100644 --- a/src/librustdoc/lint.rs +++ b/src/librustdoc/lint.rs @@ -2,8 +2,8 @@ use std::sync::LazyLock as Lazy; use rustc_data_structures::fx::FxHashMap; use rustc_lint::LintStore; -use rustc_lint_defs::{declare_tool_lint, Lint, LintId}; -use rustc_session::{lint, Session}; +use rustc_lint_defs::{Lint, LintId, declare_tool_lint}; +use rustc_session::{Session, lint}; /// This function is used to setup the lint initialization. By default, in rustdoc, everything /// is "allowed". Depending if we run in test mode or not, we want some of them to be at their diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 581ebbbe58d..978f96f38be 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -1,5 +1,5 @@ use std::fmt::Write as _; -use std::fs::{create_dir_all, read_to_string, File}; +use std::fs::{File, create_dir_all, read_to_string}; use std::io::prelude::*; use std::path::Path; diff --git a/src/librustdoc/passes/calculate_doc_coverage.rs b/src/librustdoc/passes/calculate_doc_coverage.rs index 7391909406e..15c0d77e7ba 100644 --- a/src/librustdoc/passes/calculate_doc_coverage.rs +++ b/src/librustdoc/passes/calculate_doc_coverage.rs @@ -13,9 +13,9 @@ use tracing::debug; use crate::clean; use crate::core::DocContext; -use crate::html::markdown::{find_testable_code, ErrorCodes}; -use crate::passes::check_doc_test_visibility::{should_have_doc_example, Tests}; +use crate::html::markdown::{ErrorCodes, find_testable_code}; use crate::passes::Pass; +use crate::passes::check_doc_test_visibility::{Tests, should_have_doc_example}; use crate::visit::DocVisitor; pub(crate) const CALCULATE_DOC_COVERAGE: Pass = Pass { diff --git a/src/librustdoc/passes/check_doc_test_visibility.rs b/src/librustdoc/passes/check_doc_test_visibility.rs index 733fd919e71..52b2cd7774d 100644 --- a/src/librustdoc/passes/check_doc_test_visibility.rs +++ b/src/librustdoc/passes/check_doc_test_visibility.rs @@ -15,7 +15,7 @@ use crate::clean; use crate::clean::utils::inherits_doc_hidden; use crate::clean::*; use crate::core::DocContext; -use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString, MdRelLine}; +use crate::html::markdown::{ErrorCodes, Ignore, LangString, MdRelLine, find_testable_code}; use crate::visit::DocVisitor; pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass { diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 676c972529b..ddc80ea7cb1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -14,25 +14,25 @@ use rustc_data_structures::intern::Interned; use rustc_errors::{Applicability, Diag, DiagMessage}; use rustc_hir::def::Namespace::*; use rustc_hir::def::{DefKind, Namespace, PerNS}; -use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; +use rustc_hir::def_id::{CRATE_DEF_ID, DefId}; use rustc_hir::{Mutability, Safety}; use rustc_middle::ty::{Ty, TyCtxt}; use rustc_middle::{bug, span_bug, ty}; use rustc_resolve::rustdoc::{ - has_primitive_or_keyword_docs, prepare_to_doc_link_resolution, source_span_for_markdown_range, - strip_generics_from_path, MalformedGenerics, + MalformedGenerics, has_primitive_or_keyword_docs, prepare_to_doc_link_resolution, + source_span_for_markdown_range, strip_generics_from_path, }; use rustc_session::lint::Lint; -use rustc_span::hygiene::MacroKind; -use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::BytePos; -use smallvec::{smallvec, SmallVec}; +use rustc_span::hygiene::MacroKind; +use rustc_span::symbol::{Ident, Symbol, sym}; +use smallvec::{SmallVec, smallvec}; use tracing::{debug, info, instrument, trace}; use crate::clean::utils::find_nearest_parent_module; use crate::clean::{self, Crate, Item, ItemLink, PrimitiveType}; use crate::core::DocContext; -use crate::html::markdown::{markdown_links, MarkdownLink, MarkdownLinkRange}; +use crate::html::markdown::{MarkdownLink, MarkdownLinkRange, markdown_links}; use crate::lint::{BROKEN_INTRA_DOC_LINKS, PRIVATE_INTRA_DOC_LINKS}; use crate::passes::Pass; use crate::visit::DocVisitor; diff --git a/src/librustdoc/passes/lint/bare_urls.rs b/src/librustdoc/passes/lint/bare_urls.rs index bac0e07f1c1..1397eadb288 100644 --- a/src/librustdoc/passes/lint/bare_urls.rs +++ b/src/librustdoc/passes/lint/bare_urls.rs @@ -77,10 +77,9 @@ fn find_raw_urls( // For now, we only check "full" URLs (meaning, starting with "http://" or "https://"). for match_ in URL_REGEX.find_iter(text) { let url_range = match_.range(); - f( - cx, - "this URL is not a hyperlink", - Range { start: range.start + url_range.start, end: range.start + url_range.end }, - ); + f(cx, "this URL is not a hyperlink", Range { + start: range.start + url_range.start, + end: range.start + url_range.end, + }); } } diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs index 1b2431a629b..848e70a7bdb 100644 --- a/src/librustdoc/passes/lint/check_code_block_syntax.rs +++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs @@ -2,14 +2,14 @@ use rustc_data_structures::sync::{Lock, Lrc}; use rustc_errors::emitter::Emitter; -use rustc_errors::translation::{to_fluent_args, Translate}; +use rustc_errors::translation::{Translate, to_fluent_args}; use rustc_errors::{Applicability, DiagCtxt, DiagInner, LazyFallbackBundle}; use rustc_parse::{source_str_to_stream, unwrap_or_emit_fatal}; use rustc_resolve::rustdoc::source_span_for_markdown_range; use rustc_session::parse::ParseSess; use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, Transparency}; use rustc_span::source_map::{FilePathMapping, SourceMap}; -use rustc_span::{FileName, InnerSpan, DUMMY_SP}; +use rustc_span::{DUMMY_SP, FileName, InnerSpan}; use crate::clean; use crate::core::DocContext; diff --git a/src/librustdoc/passes/lint/redundant_explicit_links.rs b/src/librustdoc/passes/lint/redundant_explicit_links.rs index 9c37e11349a..f3599688454 100644 --- a/src/librustdoc/passes/lint/redundant_explicit_links.rs +++ b/src/librustdoc/passes/lint/redundant_explicit_links.rs @@ -5,15 +5,15 @@ use pulldown_cmark::{ }; use rustc_ast::NodeId; use rustc_errors::SuggestionStyle; -use rustc_hir::def::{DefKind, DocLinkResMap, Namespace, Res}; use rustc_hir::HirId; +use rustc_hir::def::{DefKind, DocLinkResMap, Namespace, Res}; use rustc_lint_defs::Applicability; use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, source_span_for_markdown_range}; -use rustc_span::def_id::DefId; use rustc_span::Symbol; +use rustc_span::def_id::DefId; -use crate::clean::utils::{find_nearest_parent_module, inherits_doc_hidden}; use crate::clean::Item; +use crate::clean::utils::{find_nearest_parent_module, inherits_doc_hidden}; use crate::core::DocContext; use crate::html::markdown::main_body_opts; diff --git a/src/librustdoc/passes/strip_aliased_non_local.rs b/src/librustdoc/passes/strip_aliased_non_local.rs index 6078ab36528..155ad543831 100644 --- a/src/librustdoc/passes/strip_aliased_non_local.rs +++ b/src/librustdoc/passes/strip_aliased_non_local.rs @@ -3,7 +3,7 @@ use rustc_middle::ty::{TyCtxt, Visibility}; use crate::clean; use crate::clean::Item; use crate::core::DocContext; -use crate::fold::{strip_item, DocFolder}; +use crate::fold::{DocFolder, strip_item}; use crate::passes::Pass; pub(crate) const STRIP_ALIASED_NON_LOCAL: Pass = Pass { diff --git a/src/librustdoc/passes/strip_hidden.rs b/src/librustdoc/passes/strip_hidden.rs index 7c5fbac94e4..430f3d8a574 100644 --- a/src/librustdoc/passes/strip_hidden.rs +++ b/src/librustdoc/passes/strip_hidden.rs @@ -2,7 +2,7 @@ use std::mem; -use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID}; +use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId}; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::sym; use tracing::debug; @@ -11,7 +11,7 @@ use crate::clean; use crate::clean::utils::inherits_doc_hidden; use crate::clean::{Item, ItemIdSet}; use crate::core::DocContext; -use crate::fold::{strip_item, DocFolder}; +use crate::fold::{DocFolder, strip_item}; use crate::passes::{ImplStripper, Pass}; pub(crate) const STRIP_HIDDEN: Pass = Pass { diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index a85428f8742..98b3446c26d 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -8,7 +8,7 @@ use tracing::debug; use crate::clean::utils::inherits_doc_hidden; use crate::clean::{self, Item, ItemId, ItemIdSet}; -use crate::fold::{strip_item, DocFolder}; +use crate::fold::{DocFolder, strip_item}; use crate::formats::cache::Cache; use crate::visit_lib::RustdocEffectiveVisibilities; diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index ba172f86539..2cf703f57c0 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -7,19 +7,19 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LocalDefIdSet}; -use rustc_hir::intravisit::{walk_body, walk_item, Visitor}; -use rustc_hir::{Node, CRATE_HIR_ID}; +use rustc_hir::intravisit::{Visitor, walk_body, walk_item}; +use rustc_hir::{CRATE_HIR_ID, Node}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt; +use rustc_span::Span; use rustc_span::def_id::{CRATE_DEF_ID, LOCAL_CRATE}; use rustc_span::hygiene::MacroKind; -use rustc_span::symbol::{kw, sym, Symbol}; -use rustc_span::Span; +use rustc_span::symbol::{Symbol, kw, sym}; use tracing::debug; use crate::clean::cfg::Cfg; use crate::clean::utils::{inherits_doc_hidden, should_ignore_res}; -use crate::clean::{reexport_chain, AttributesExt, NestedAttributesExt}; +use crate::clean::{AttributesExt, NestedAttributesExt, reexport_chain}; use crate::core; /// This module is used to store stuff from Rust's AST in a more convenient diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index eb5faeeaf9a..62e1695cbe3 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -598,14 +598,11 @@ impl Builder { }) .collect(); - dst.insert( - pkg.manifest_component_name(), - Package { - version: version_info.version.unwrap_or_default(), - git_commit_hash: version_info.git_commit, - target: targets, - }, - ); + dst.insert(pkg.manifest_component_name(), Package { + version: version_info.version.unwrap_or_default(), + git_commit_hash: version_info.git_commit, + target: targets, + }); } fn url(&self, path: &Path) -> String { diff --git a/src/tools/build-manifest/src/manifest.rs b/src/tools/build-manifest/src/manifest.rs index 695a8f5d4e7..f038deea702 100644 --- a/src/tools/build-manifest/src/manifest.rs +++ b/src/tools/build-manifest/src/manifest.rs @@ -3,8 +3,8 @@ use std::path::{Path, PathBuf}; use serde::{Serialize, Serializer}; -use crate::versions::PkgType; use crate::Builder; +use crate::versions::PkgType; #[derive(Serialize)] #[serde(rename_all = "kebab-case")] diff --git a/src/tools/bump-stage0/src/main.rs b/src/tools/bump-stage0/src/main.rs index f8c75ca7226..b2dc044ec66 100644 --- a/src/tools/bump-stage0/src/main.rs +++ b/src/tools/bump-stage0/src/main.rs @@ -1,7 +1,7 @@ #![deny(unused_variables)] use anyhow::{Context, Error}; -use build_helper::stage0_parser::{parse_stage0_file, Stage0Config, VersionMetadata}; +use build_helper::stage0_parser::{Stage0Config, VersionMetadata, parse_stage0_file}; use curl::easy::Easy; use indexmap::IndexMap; diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 414f9f3a7f1..2d8c0c3fa5e 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -11,7 +11,7 @@ use serde::de::{Deserialize, Deserializer, Error as _}; use test::{ColorConfig, OutputFormat}; pub use self::Mode::*; -use crate::util::{add_dylib_path, PathBufExt}; +use crate::util::{PathBufExt, add_dylib_path}; macro_rules! string_enum { ($(#[$meta:meta])* $vis:vis enum $name:ident { $($variant:ident => $repr:expr,)* }) => { diff --git a/src/tools/compiletest/src/errors.rs b/src/tools/compiletest/src/errors.rs index 4ca9f02ddc7..efe758e65cf 100644 --- a/src/tools/compiletest/src/errors.rs +++ b/src/tools/compiletest/src/errors.rs @@ -1,7 +1,7 @@ use std::fmt; use std::fs::File; -use std::io::prelude::*; use std::io::BufReader; +use std::io::prelude::*; use std::path::Path; use std::str::FromStr; use std::sync::OnceLock; diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 93df6aa7255..a291ff37112 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -1,8 +1,8 @@ use std::collections::HashSet; use std::env; use std::fs::File; -use std::io::prelude::*; use std::io::BufReader; +use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process::Command; use std::sync::OnceLock; @@ -11,7 +11,7 @@ use regex::Regex; use tracing::*; use crate::common::{Config, Debugger, FailMode, Mode, PassMode}; -use crate::header::cfg::{parse_cfg_name_directive, MatchOutcome}; +use crate::header::cfg::{MatchOutcome, parse_cfg_name_directive}; use crate::header::needs::CachedNeedsConditions; use crate::util::static_regex; use crate::{extract_cdb_version, extract_gdb_version}; diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs index e903f60ceb3..99c0e850f1a 100644 --- a/src/tools/compiletest/src/header/needs.rs +++ b/src/tools/compiletest/src/header/needs.rs @@ -1,5 +1,5 @@ use crate::common::{Config, Sanitizer}; -use crate::header::{llvm_has_libzstd, IgnoreDecision}; +use crate::header::{IgnoreDecision, llvm_has_libzstd}; pub(super) fn handle_needs( cache: &CachedNeedsConditions, diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 3a9a7eb9118..ae661200c6c 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use super::iter_header; use crate::common::{Config, Debugger, Mode}; -use crate::header::{parse_normalize_rule, EarlyProps, HeadersCache}; +use crate::header::{EarlyProps, HeadersCache, parse_normalize_rule}; fn make_test_description<R: Read>( config: &Config, @@ -226,10 +226,9 @@ fn revisions() { let config: Config = cfg().build(); assert_eq!(parse_rs(&config, "//@ revisions: a b c").revisions, vec!["a", "b", "c"],); - assert_eq!( - parse_makefile(&config, "# revisions: hello there").revisions, - vec!["hello", "there"], - ); + assert_eq!(parse_makefile(&config, "# revisions: hello there").revisions, vec![ + "hello", "there" + ],); } #[test] diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 3339116d542..cfc619f9342 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -34,10 +34,10 @@ use test::ColorConfig; use tracing::*; use walkdir::WalkDir; -use self::header::{make_test_description, EarlyProps}; +use self::header::{EarlyProps, make_test_description}; use crate::common::{ - expected_output_path, output_base_dir, output_relative_path, Config, Debugger, Mode, PassMode, - TestPaths, UI_EXTENSIONS, + Config, Debugger, Mode, PassMode, TestPaths, UI_EXTENSIONS, expected_output_path, + output_base_dir, output_relative_path, }; use crate::header::HeadersCache; use crate::util::logv; diff --git a/src/tools/compiletest/src/read2.rs b/src/tools/compiletest/src/read2.rs index b2d068e78b4..2375f391d03 100644 --- a/src/tools/compiletest/src/read2.rs +++ b/src/tools/compiletest/src/read2.rs @@ -232,9 +232,9 @@ mod imp { use std::process::{ChildStderr, ChildStdout}; use std::{io, slice}; + use miow::Overlapped; use miow::iocp::{CompletionPort, CompletionStatus}; use miow::pipe::NamedPipe; - use miow::Overlapped; use windows::Win32::Foundation::ERROR_BROKEN_PIPE; struct Pipe<'a> { diff --git a/src/tools/compiletest/src/read2/tests.rs b/src/tools/compiletest/src/read2/tests.rs index 9e052ff069b..10572725431 100644 --- a/src/tools/compiletest/src/read2/tests.rs +++ b/src/tools/compiletest/src/read2/tests.rs @@ -1,6 +1,6 @@ use std::io::Write; -use crate::read2::{ProcOutput, FILTERED_PATHS_PLACEHOLDER_LEN, MAX_OUT_LEN}; +use crate::read2::{FILTERED_PATHS_PLACEHOLDER_LEN, MAX_OUT_LEN, ProcOutput}; #[test] fn test_abbreviate_short_string() { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 7b23aa34639..177d4044ec2 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::ffi::OsString; -use std::fs::{self, create_dir_all, File}; +use std::fs::{self, File, create_dir_all}; use std::hash::{DefaultHasher, Hash, Hasher}; use std::io::prelude::*; use std::io::{self, BufReader}; @@ -18,18 +18,18 @@ use regex::{Captures, Regex}; use tracing::*; use crate::common::{ - expected_output_path, incremental_dir, output_base_dir, output_base_name, - output_testname_unique, Assembly, Codegen, CodegenUnits, CompareMode, Config, CoverageMap, - CoverageRun, Crashes, DebugInfo, Debugger, FailMode, Incremental, JsDocTest, MirOpt, PassMode, - Pretty, RunMake, RunPassValgrind, Rustdoc, RustdocJson, TestPaths, Ui, UI_EXTENSIONS, UI_FIXED, - UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG, + Assembly, Codegen, CodegenUnits, CompareMode, Config, CoverageMap, CoverageRun, Crashes, + DebugInfo, Debugger, FailMode, Incremental, JsDocTest, MirOpt, PassMode, Pretty, RunMake, + RunPassValgrind, Rustdoc, RustdocJson, TestPaths, UI_EXTENSIONS, UI_FIXED, UI_RUN_STDERR, + UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG, Ui, expected_output_path, + incremental_dir, output_base_dir, output_base_name, output_testname_unique, }; use crate::compute_diff::{write_diff, write_filtered_diff}; use crate::errors::{self, Error, ErrorKind}; use crate::header::TestProps; -use crate::read2::{read2_abbreviated, Truncated}; -use crate::util::{add_dylib_path, logv, static_regex, PathBufExt}; -use crate::{json, ColorConfig}; +use crate::read2::{Truncated, read2_abbreviated}; +use crate::util::{PathBufExt, add_dylib_path, logv, static_regex}; +use crate::{ColorConfig, json}; mod debugger; @@ -62,7 +62,7 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R { use std::sync::Mutex; use windows::Win32::System::Diagnostics::Debug::{ - SetErrorMode, SEM_NOGPFAULTERRORBOX, THREAD_ERROR_MODE, + SEM_NOGPFAULTERRORBOX, SetErrorMode, THREAD_ERROR_MODE, }; static LOCK: Mutex<()> = Mutex::new(()); diff --git a/src/tools/compiletest/src/runtest/mir_opt.rs b/src/tools/compiletest/src/runtest/mir_opt.rs index 02289a8df1e..d1ec0035744 100644 --- a/src/tools/compiletest/src/runtest/mir_opt.rs +++ b/src/tools/compiletest/src/runtest/mir_opt.rs @@ -2,7 +2,7 @@ use std::fs; use std::path::{Path, PathBuf}; use glob::glob; -use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile}; +use miropt_test_tools::{MiroptTest, MiroptTestFile, files_for_miropt_test}; use tracing::debug; use super::{Emit, TestCx, WillExecute}; diff --git a/src/tools/compiletest/src/runtest/rustdoc.rs b/src/tools/compiletest/src/runtest/rustdoc.rs index 6a31888527e..3f33862d2cf 100644 --- a/src/tools/compiletest/src/runtest/rustdoc.rs +++ b/src/tools/compiletest/src/runtest/rustdoc.rs @@ -1,6 +1,6 @@ use std::process::Command; -use super::{remove_and_create_dir_all, TestCx}; +use super::{TestCx, remove_and_create_dir_all}; impl TestCx<'_> { pub(super) fn run_rustdoc_test(&self) { diff --git a/src/tools/compiletest/src/runtest/rustdoc_json.rs b/src/tools/compiletest/src/runtest/rustdoc_json.rs index a39887ccd02..31fdb0a5d13 100644 --- a/src/tools/compiletest/src/runtest/rustdoc_json.rs +++ b/src/tools/compiletest/src/runtest/rustdoc_json.rs @@ -1,6 +1,6 @@ use std::process::Command; -use super::{remove_and_create_dir_all, TestCx}; +use super::{TestCx, remove_and_create_dir_all}; impl TestCx<'_> { pub(super) fn run_rustdoc_json_test(&self) { diff --git a/src/tools/compiletest/src/runtest/ui.rs b/src/tools/compiletest/src/runtest/ui.rs index 88a0ec3aa3b..bd8ef952a86 100644 --- a/src/tools/compiletest/src/runtest/ui.rs +++ b/src/tools/compiletest/src/runtest/ui.rs @@ -2,12 +2,12 @@ use std::collections::HashSet; use std::fs::OpenOptions; use std::io::Write; -use rustfix::{apply_suggestions, get_suggestions_from_json, Filter}; +use rustfix::{Filter, apply_suggestions, get_suggestions_from_json}; use tracing::debug; use super::{ AllowUnused, Emit, ErrorKind, FailMode, LinkToAux, PassMode, TargetLocation, TestCx, - TestOutput, Truncated, WillExecute, UI_FIXED, + TestOutput, Truncated, UI_FIXED, WillExecute, }; use crate::{errors, json}; diff --git a/src/tools/coverage-dump/src/covfun.rs b/src/tools/coverage-dump/src/covfun.rs index 4729b327de5..c779dd0583c 100644 --- a/src/tools/coverage-dump/src/covfun.rs +++ b/src/tools/coverage-dump/src/covfun.rs @@ -2,10 +2,10 @@ use std::collections::HashMap; use std::fmt::{self, Debug, Write as _}; use std::sync::OnceLock; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use regex::Regex; -use crate::parser::{unescape_llvm_string_contents, Parser}; +use crate::parser::{Parser, unescape_llvm_string_contents}; pub(crate) fn dump_covfun_mappings( llvm_ir: &str, diff --git a/src/tools/coverage-dump/src/prf_names.rs b/src/tools/coverage-dump/src/prf_names.rs index c5f9c4ce54c..96d097c79a3 100644 --- a/src/tools/coverage-dump/src/prf_names.rs +++ b/src/tools/coverage-dump/src/prf_names.rs @@ -4,7 +4,7 @@ use std::sync::OnceLock; use anyhow::{anyhow, ensure}; use regex::Regex; -use crate::parser::{unescape_llvm_string_contents, Parser}; +use crate::parser::{Parser, unescape_llvm_string_contents}; /// Scans through the contents of an LLVM IR assembly file to find `__llvm_prf_names` /// entries, decodes them, and creates a table that maps name hash values to diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index 53a26112911..58224aed148 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -12,7 +12,7 @@ use std::io::Write; use std::path::{Path, PathBuf}; use std::str::FromStr; -use mdbook::book::{parse_summary, BookItem, Chapter}; +use mdbook::book::{BookItem, Chapter, parse_summary}; use mdbook::{Config, MDBook}; use rustc_errors::codes::DIAGNOSTICS; diff --git a/src/tools/generate-copyright/src/cargo_metadata.rs b/src/tools/generate-copyright/src/cargo_metadata.rs index c85e4aa371a..31b18c3dc10 100644 --- a/src/tools/generate-copyright/src/cargo_metadata.rs +++ b/src/tools/generate-copyright/src/cargo_metadata.rs @@ -99,15 +99,12 @@ pub fn get_metadata( } // otherwise it's an out-of-tree dependency let package_id = Package { name: package.name, version: package.version.to_string() }; - output.insert( - package_id, - PackageMetadata { - license: package.license.unwrap_or_else(|| String::from("Unspecified")), - authors: package.authors, - notices: BTreeMap::new(), - is_in_libstd: None, - }, - ); + output.insert(package_id, PackageMetadata { + license: package.license.unwrap_or_else(|| String::from("Unspecified")), + authors: package.authors, + notices: BTreeMap::new(), + is_in_libstd: None, + }); } } diff --git a/src/tools/jsondoclint/src/main.rs b/src/tools/jsondoclint/src/main.rs index aaaba78cb46..5cbf3460860 100644 --- a/src/tools/jsondoclint/src/main.rs +++ b/src/tools/jsondoclint/src/main.rs @@ -1,10 +1,10 @@ use std::io::{BufWriter, Write}; use std::path::{Path, PathBuf}; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use fs_err as fs; -use rustdoc_json_types::{Crate, Id, FORMAT_VERSION}; +use rustdoc_json_types::{Crate, FORMAT_VERSION, Id}; use serde::Serialize; use serde_json::Value; diff --git a/src/tools/jsondoclint/src/validator.rs b/src/tools/jsondoclint/src/validator.rs index 10ab62cb24a..b04919bdd3e 100644 --- a/src/tools/jsondoclint/src/validator.rs +++ b/src/tools/jsondoclint/src/validator.rs @@ -11,7 +11,7 @@ use rustdoc_json_types::{ use serde_json::Value; use crate::item_kind::Kind; -use crate::{json_find, Error, ErrorKind}; +use crate::{Error, ErrorKind, json_find}; // This is a rustc implementation detail that we rely on here const LOCAL_CRATE_ID: u32 = 0; diff --git a/src/tools/jsondoclint/src/validator/tests.rs b/src/tools/jsondoclint/src/validator/tests.rs index f28702de06d..d15aa7db315 100644 --- a/src/tools/jsondoclint/src/validator/tests.rs +++ b/src/tools/jsondoclint/src/validator/tests.rs @@ -1,5 +1,5 @@ use rustc_hash::FxHashMap; -use rustdoc_json_types::{Item, ItemKind, Visibility, FORMAT_VERSION}; +use rustdoc_json_types::{FORMAT_VERSION, Item, ItemKind, Visibility}; use super::*; use crate::json_find::SelectorPart; @@ -25,42 +25,32 @@ fn errors_on_missing_links() { root: id("0"), crate_version: None, includes_private: false, - index: FxHashMap::from_iter([( - id("0"), - Item { - name: Some("root".to_owned()), - id: id(""), - crate_id: 0, - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::from_iter([("Not Found".to_owned(), id("1"))]), - attrs: vec![], - deprecation: None, - inner: ItemEnum::Module(Module { - is_crate: true, - items: vec![], - is_stripped: false, - }), - }, - )]), + index: FxHashMap::from_iter([(id("0"), Item { + name: Some("root".to_owned()), + id: id(""), + crate_id: 0, + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::from_iter([("Not Found".to_owned(), id("1"))]), + attrs: vec![], + deprecation: None, + inner: ItemEnum::Module(Module { is_crate: true, items: vec![], is_stripped: false }), + })]), paths: FxHashMap::default(), external_crates: FxHashMap::default(), format_version: rustdoc_json_types::FORMAT_VERSION, }; - check( - &k, - &[Error { - kind: ErrorKind::NotFound(vec![vec![ - SelectorPart::Field("index".to_owned()), - SelectorPart::Field("0".to_owned()), - SelectorPart::Field("links".to_owned()), - SelectorPart::Field("Not Found".to_owned()), - ]]), - id: id("1"), - }], - ); + check(&k, &[Error { + kind: ErrorKind::NotFound(vec![vec![ + SelectorPart::Field("index".to_owned()), + SelectorPart::Field("0".to_owned()), + SelectorPart::Field("links".to_owned()), + SelectorPart::Field("Not Found".to_owned()), + ]]), + id: id("1"), + }]); } // Test we would catch @@ -72,60 +62,48 @@ fn errors_on_local_in_paths_and_not_index() { crate_version: None, includes_private: false, index: FxHashMap::from_iter([ - ( - id("0:0:1572"), - Item { - id: id("0:0:1572"), - crate_id: 0, - name: Some("microcore".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::from_iter([(("prim@i32".to_owned(), id("0:1:1571")))]), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Module(Module { - is_crate: true, - items: vec![id("0:1:717")], - is_stripped: false, - }), - }, - ), - ( - id("0:1:717"), - Item { - id: id("0:1:717"), - crate_id: 0, - name: Some("i32".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::default(), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Primitive(Primitive { name: "i32".to_owned(), impls: vec![] }), - }, - ), - ]), - paths: FxHashMap::from_iter([( - id("0:1:1571"), - ItemSummary { + (id("0:0:1572"), Item { + id: id("0:0:1572"), crate_id: 0, - path: vec!["microcore".to_owned(), "i32".to_owned()], - kind: ItemKind::Primitive, - }, - )]), + name: Some("microcore".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::from_iter([(("prim@i32".to_owned(), id("0:1:1571")))]), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Module(Module { + is_crate: true, + items: vec![id("0:1:717")], + is_stripped: false, + }), + }), + (id("0:1:717"), Item { + id: id("0:1:717"), + crate_id: 0, + name: Some("i32".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::default(), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Primitive(Primitive { name: "i32".to_owned(), impls: vec![] }), + }), + ]), + paths: FxHashMap::from_iter([(id("0:1:1571"), ItemSummary { + crate_id: 0, + path: vec!["microcore".to_owned(), "i32".to_owned()], + kind: ItemKind::Primitive, + })]), external_crates: FxHashMap::default(), format_version: rustdoc_json_types::FORMAT_VERSION, }; - check( - &krate, - &[Error { - id: id("0:1:1571"), - kind: ErrorKind::Custom("Id for local item in `paths` but not in `index`".to_owned()), - }], - ); + check(&krate, &[Error { + id: id("0:1:1571"), + kind: ErrorKind::Custom("Id for local item in `paths` but not in `index`".to_owned()), + }]); } #[test] @@ -135,25 +113,18 @@ fn checks_local_crate_id_is_correct() { root: id("root"), crate_version: None, includes_private: false, - index: FxHashMap::from_iter([( - id("root"), - Item { - id: id("root"), - crate_id: LOCAL_CRATE_ID.wrapping_add(1), - name: Some("irrelavent".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::default(), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Module(Module { - is_crate: true, - items: vec![], - is_stripped: false, - }), - }, - )]), + index: FxHashMap::from_iter([(id("root"), Item { + id: id("root"), + crate_id: LOCAL_CRATE_ID.wrapping_add(1), + name: Some("irrelavent".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::default(), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Module(Module { is_crate: true, items: vec![], is_stripped: false }), + })]), paths: FxHashMap::default(), external_crates: FxHashMap::default(), format_version: FORMAT_VERSION, diff --git a/src/tools/lint-docs/src/lib.rs b/src/tools/lint-docs/src/lib.rs index 532a27b22aa..8c7ff08ccd7 100644 --- a/src/tools/lint-docs/src/lib.rs +++ b/src/tools/lint-docs/src/lib.rs @@ -19,30 +19,24 @@ mod groups; /// level of the lint, which will be more difficult to support, since rustc /// currently does not track that historical information. static RENAMES: &[(Level, &[(&str, &str)])] = &[ - ( - Level::Allow, - &[ - ("single-use-lifetime", "single-use-lifetimes"), - ("elided-lifetime-in-path", "elided-lifetimes-in-paths"), - ("async-idents", "keyword-idents"), - ("disjoint-capture-migration", "rust-2021-incompatible-closure-captures"), - ("keyword-idents", "keyword-idents-2018"), - ("or-patterns-back-compat", "rust-2021-incompatible-or-patterns"), - ], - ), - ( - Level::Warn, - &[ - ("bare-trait-object", "bare-trait-objects"), - ("unstable-name-collision", "unstable-name-collisions"), - ("unused-doc-comment", "unused-doc-comments"), - ("redundant-semicolon", "redundant-semicolons"), - ("overlapping-patterns", "overlapping-range-endpoints"), - ("non-fmt-panic", "non-fmt-panics"), - ("unused-tuple-struct-fields", "dead-code"), - ("static-mut-ref", "static-mut-refs"), - ], - ), + (Level::Allow, &[ + ("single-use-lifetime", "single-use-lifetimes"), + ("elided-lifetime-in-path", "elided-lifetimes-in-paths"), + ("async-idents", "keyword-idents"), + ("disjoint-capture-migration", "rust-2021-incompatible-closure-captures"), + ("keyword-idents", "keyword-idents-2018"), + ("or-patterns-back-compat", "rust-2021-incompatible-or-patterns"), + ]), + (Level::Warn, &[ + ("bare-trait-object", "bare-trait-objects"), + ("unstable-name-collision", "unstable-name-collisions"), + ("unused-doc-comment", "unused-doc-comments"), + ("redundant-semicolon", "redundant-semicolons"), + ("overlapping-patterns", "overlapping-range-endpoints"), + ("non-fmt-panic", "non-fmt-panics"), + ("unused-tuple-struct-fields", "dead-code"), + ("static-mut-ref", "static-mut-refs"), + ]), (Level::Deny, &[("exceeding-bitshifts", "arithmetic-overflow")]), ]; diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 73389f930bd..6211b5670aa 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -6,7 +6,7 @@ use utils::io; use crate::bolt::{bolt_optimize, with_bolt_instrumented}; use crate::environment::{Environment, EnvironmentBuilder}; -use crate::exec::{cmd, Bootstrap}; +use crate::exec::{Bootstrap, cmd}; use crate::tests::run_tests; use crate::timer::Timer; use crate::training::{ diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index e7a3ed787ed..82c393d34a6 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -1,7 +1,7 @@ use anyhow::Context; use camino::{Utf8Path, Utf8PathBuf}; -use crate::environment::{executable_extension, Environment}; +use crate::environment::{Environment, executable_extension}; use crate::exec::cmd; use crate::utils::io::{copy_directory, find_file_in_dir, unpack_archive}; diff --git a/src/tools/opt-dist/src/training.rs b/src/tools/opt-dist/src/training.rs index 97e8ec5c6ed..30c79f95947 100644 --- a/src/tools/opt-dist/src/training.rs +++ b/src/tools/opt-dist/src/training.rs @@ -3,8 +3,8 @@ use build_helper::{LLVM_PGO_CRATES, RUSTC_PGO_CRATES}; use camino::{Utf8Path, Utf8PathBuf}; use humansize::BINARY; -use crate::environment::{executable_extension, Environment}; -use crate::exec::{cmd, CmdBuilder}; +use crate::environment::{Environment, executable_extension}; +use crate::exec::{CmdBuilder, cmd}; use crate::utils::io::{count_files, delete_directory}; use crate::utils::with_log_group; diff --git a/src/tools/opt-dist/src/utils/artifact_size.rs b/src/tools/opt-dist/src/utils/artifact_size.rs index e51b5f06dfb..74f7f75b9c0 100644 --- a/src/tools/opt-dist/src/utils/artifact_size.rs +++ b/src/tools/opt-dist/src/utils/artifact_size.rs @@ -11,7 +11,7 @@ use crate::utils::io::get_files_from_dir; pub fn print_binary_sizes(env: &Environment) -> anyhow::Result<()> { use std::fmt::Write; - use humansize::{format_size, BINARY}; + use humansize::{BINARY, format_size}; let root = env.build_artifacts().join("stage2"); diff --git a/src/tools/rust-installer/src/combiner.rs b/src/tools/rust-installer/src/combiner.rs index 66b3d324568..487b7cae844 100644 --- a/src/tools/rust-installer/src/combiner.rs +++ b/src/tools/rust-installer/src/combiner.rs @@ -1,7 +1,7 @@ use std::io::{Read, Write}; use std::path::Path; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use tar::Archive; use super::{Scripter, Tarballer}; diff --git a/src/tools/rust-installer/src/compression.rs b/src/tools/rust-installer/src/compression.rs index df3a98ae789..96c48657c46 100644 --- a/src/tools/rust-installer/src/compression.rs +++ b/src/tools/rust-installer/src/compression.rs @@ -81,17 +81,14 @@ impl CompressionFormat { let file = crate::util::create_new_file(path)?; Ok(match self { - CompressionFormat::Gz => Box::new(GzEncoder::new( - file, - match profile { - CompressionProfile::Fast => flate2::Compression::fast(), - CompressionProfile::Balanced => flate2::Compression::new(6), - CompressionProfile::Best => flate2::Compression::best(), - CompressionProfile::NoOp => panic!( - "compression profile 'no-op' should not call `CompressionFormat::encode`." - ), - }, - )), + CompressionFormat::Gz => Box::new(GzEncoder::new(file, match profile { + CompressionProfile::Fast => flate2::Compression::fast(), + CompressionProfile::Balanced => flate2::Compression::new(6), + CompressionProfile::Best => flate2::Compression::best(), + CompressionProfile::NoOp => panic!( + "compression profile 'no-op' should not call `CompressionFormat::encode`." + ), + })), CompressionFormat::Xz => { let encoder = match profile { CompressionProfile::NoOp => panic!( diff --git a/src/tools/rust-installer/src/generator.rs b/src/tools/rust-installer/src/generator.rs index e1228693344..d8a8a11332b 100644 --- a/src/tools/rust-installer/src/generator.rs +++ b/src/tools/rust-installer/src/generator.rs @@ -2,7 +2,7 @@ use std::collections::BTreeSet; use std::io::Write; use std::path::Path; -use anyhow::{bail, format_err, Context, Result}; +use anyhow::{Context, Result, bail, format_err}; use super::{Scripter, Tarballer}; use crate::compression::{CompressionFormats, CompressionProfile}; diff --git a/src/tools/rust-installer/src/tarballer.rs b/src/tools/rust-installer/src/tarballer.rs index a101be8f5ff..854bb85f2c5 100644 --- a/src/tools/rust-installer/src/tarballer.rs +++ b/src/tools/rust-installer/src/tarballer.rs @@ -2,7 +2,7 @@ use std::fs::{read_link, symlink_metadata}; use std::io::{BufWriter, Write}; use std::path::Path; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use tar::{Builder, Header, HeaderMode}; use walkdir::WalkDir; diff --git a/src/tools/rust-installer/src/util.rs b/src/tools/rust-installer/src/util.rs index 51b8c9c9d1b..bbded1df310 100644 --- a/src/tools/rust-installer/src/util.rs +++ b/src/tools/rust-installer/src/util.rs @@ -1,15 +1,15 @@ use std::fs; -// FIXME: what about Windows? Are default ACLs executable? -#[cfg(unix)] -use std::os::unix::fs::symlink as symlink_file; // Needed to set the script mode to executable. #[cfg(unix)] use std::os::unix::fs::OpenOptionsExt; +// FIXME: what about Windows? Are default ACLs executable? +#[cfg(unix)] +use std::os::unix::fs::symlink as symlink_file; #[cfg(windows)] use std::os::windows::fs::symlink_file; use std::path::Path; -use anyhow::{format_err, Context, Result}; +use anyhow::{Context, Result, format_err}; use walkdir::WalkDir; /// Converts a `&Path` to a UTF-8 `&str`. diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index a4faac0760f..2118af61396 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -1,9 +1,9 @@ use std::env; use std::path::{Path, PathBuf}; -use clap::{arg, crate_version, ArgMatches, Command}; -use mdbook::errors::Result as Result3; +use clap::{ArgMatches, Command, arg, crate_version}; use mdbook::MDBook; +use mdbook::errors::Result as Result3; use mdbook_i18n_helpers::preprocessors::Gettext; use mdbook_spec::Spec; use mdbook_trpl_listing::TrplListing; diff --git a/src/tools/rustdoc-themes/main.rs b/src/tools/rustdoc-themes/main.rs index 1eba83a8057..9f0663bd8ee 100644 --- a/src/tools/rustdoc-themes/main.rs +++ b/src/tools/rustdoc-themes/main.rs @@ -1,8 +1,8 @@ use std::env::args; -use std::fs::{create_dir_all, File}; +use std::fs::{File, create_dir_all}; use std::io::{BufRead, BufReader, BufWriter, Write}; use std::path::Path; -use std::process::{exit, Command}; +use std::process::{Command, exit}; fn get_themes<P: AsRef<Path>>(style_path: P) -> Vec<String> { let mut ret = Vec::with_capacity(10); diff --git a/src/tools/suggest-tests/src/main.rs b/src/tools/suggest-tests/src/main.rs index 6f09bddcf60..ee8cc40404d 100644 --- a/src/tools/suggest-tests/src/main.rs +++ b/src/tools/suggest-tests/src/main.rs @@ -1,6 +1,6 @@ use std::process::ExitCode; -use build_helper::git::{get_git_modified_files, GitConfig}; +use build_helper::git::{GitConfig, get_git_modified_files}; use suggest_tests::get_suggestions; fn main() -> ExitCode { diff --git a/src/tools/suggest-tests/src/static_suggestions.rs b/src/tools/suggest-tests/src/static_suggestions.rs index a282facd9df..b216138cf9a 100644 --- a/src/tools/suggest-tests/src/static_suggestions.rs +++ b/src/tools/suggest-tests/src/static_suggestions.rs @@ -1,6 +1,6 @@ use std::sync::OnceLock; -use crate::{sug, Suggestion}; +use crate::{Suggestion, sug}; // FIXME: perhaps this could use `std::lazy` when it is stablizied macro_rules! static_suggestions { diff --git a/src/tools/tidy/src/ext_tool_checks.rs b/src/tools/tidy/src/ext_tool_checks.rs index ea9ab01aaf8..8f21338c7db 100644 --- a/src/tools/tidy/src/ext_tool_checks.rs +++ b/src/tools/tidy/src/ext_tool_checks.rs @@ -172,11 +172,10 @@ fn check_impl( let files; if file_args_clang_format.is_empty() { let llvm_wrapper = root_path.join("compiler/rustc_llvm/llvm-wrapper"); - files = find_with_extension( - root_path, - Some(llvm_wrapper.as_path()), - &[OsStr::new("h"), OsStr::new("cpp")], - )?; + files = find_with_extension(root_path, Some(llvm_wrapper.as_path()), &[ + OsStr::new("h"), + OsStr::new("cpp"), + ])?; file_args_clang_format.extend(files.iter().map(|p| p.as_os_str())); } let args = merge_args(&cfg_args_clang_format, &file_args_clang_format); diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 38b3f3f6417..40608952c0b 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -9,7 +9,7 @@ use std::num::NonZeroUsize; use std::path::PathBuf; use std::str::FromStr; use std::sync::atomic::{AtomicBool, Ordering}; -use std::thread::{self, scope, ScopedJoinHandle}; +use std::thread::{self, ScopedJoinHandle, scope}; use std::{env, process}; use tidy::*; diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index c1032b19f97..751d678e581 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use std::path::Path; -use crate::iter_header::{iter_header, HeaderLine}; +use crate::iter_header::{HeaderLine, iter_header}; use crate::walk::filter_not_rust; const LLVM_COMPONENTS_HEADER: &str = "needs-llvm-components:"; diff --git a/src/tools/tidy/src/unknown_revision.rs b/src/tools/tidy/src/unknown_revision.rs index abfff1d632a..0ba05c80a79 100644 --- a/src/tools/tidy/src/unknown_revision.rs +++ b/src/tools/tidy/src/unknown_revision.rs @@ -12,7 +12,7 @@ use std::sync::OnceLock; use ignore::DirEntry; use regex::Regex; -use crate::iter_header::{iter_header, HeaderLine}; +use crate::iter_header::{HeaderLine, iter_header}; use crate::walk::{filter_dirs, filter_not_rust, walk}; pub fn check(tests_path: impl AsRef<Path>, bad: &mut bool) { diff --git a/src/tools/unicode-table-generator/src/case_mapping.rs b/src/tools/unicode-table-generator/src/case_mapping.rs index f28161c7829..00241b7ee0e 100644 --- a/src/tools/unicode-table-generator/src/case_mapping.rs +++ b/src/tools/unicode-table-generator/src/case_mapping.rs @@ -2,7 +2,7 @@ use std::char; use std::collections::BTreeMap; use std::fmt::{self, Write}; -use crate::{fmt_list, UnicodeData}; +use crate::{UnicodeData, fmt_list}; const INDEX_MASK: u32 = 1 << 22; diff --git a/src/tools/unicode-table-generator/src/main.rs b/src/tools/unicode-table-generator/src/main.rs index 9f89e7c33f7..e1832091d70 100644 --- a/src/tools/unicode-table-generator/src/main.rs +++ b/src/tools/unicode-table-generator/src/main.rs @@ -82,7 +82,7 @@ mod raw_emitter; mod skiplist; mod unicode_download; -use raw_emitter::{emit_codepoints, emit_whitespace, RawEmitter}; +use raw_emitter::{RawEmitter, emit_codepoints, emit_whitespace}; static PROPERTIES: &[&str] = &[ "Alphabetic", diff --git a/src/tools/unicode-table-generator/src/raw_emitter.rs b/src/tools/unicode-table-generator/src/raw_emitter.rs index 47120e4f169..bfffa1eee60 100644 --- a/src/tools/unicode-table-generator/src/raw_emitter.rs +++ b/src/tools/unicode-table-generator/src/raw_emitter.rs @@ -360,15 +360,12 @@ impl Canonicalized { let unique_mapping = unique_mapping .into_iter() .map(|(key, value)| { - ( - key, - match value { - UniqueMapping::Canonicalized(idx) => { - u8::try_from(canonical_words.len() + idx).unwrap() - } - UniqueMapping::Canonical(idx) => u8::try_from(idx).unwrap(), - }, - ) + (key, match value { + UniqueMapping::Canonicalized(idx) => { + u8::try_from(canonical_words.len() + idx).unwrap() + } + UniqueMapping::Canonical(idx) => u8::try_from(idx).unwrap(), + }) }) .collect::<HashMap<_, _>>(); @@ -383,24 +380,21 @@ impl Canonicalized { let canonicalized_words = canonicalized_words .into_iter() .map(|v| { - ( - u8::try_from(v.0).unwrap(), - match v.1 { - Mapping::RotateAndInvert(amount) => { - assert_eq!(amount, amount & LOWER_6); - 1 << 6 | (amount as u8) - } - Mapping::Rotate(amount) => { - assert_eq!(amount, amount & LOWER_6); - amount as u8 - } - Mapping::Invert => 1 << 6, - Mapping::ShiftRight(shift_by) => { - assert_eq!(shift_by, shift_by & LOWER_6); - 1 << 7 | (shift_by as u8) - } - }, - ) + (u8::try_from(v.0).unwrap(), match v.1 { + Mapping::RotateAndInvert(amount) => { + assert_eq!(amount, amount & LOWER_6); + 1 << 6 | (amount as u8) + } + Mapping::Rotate(amount) => { + assert_eq!(amount, amount & LOWER_6); + amount as u8 + } + Mapping::Invert => 1 << 6, + Mapping::ShiftRight(shift_by) => { + assert_eq!(shift_by, shift_by & LOWER_6); + 1 << 7 | (shift_by as u8) + } + }) }) .collect::<Vec<(u8, u8)>>(); Canonicalized { unique_mapping, canonical_words, canonicalized_words } diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index 9af8802b012..6cbdc83d5b5 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -5,11 +5,11 @@ use std::env; use std::fs::{self, write}; use std::path::Path; -use tidy::features::{collect_lang_features, collect_lib_features, Features}; +use tidy::features::{Features, collect_lang_features, collect_lib_features}; use tidy::t; use tidy::unstable_book::{ - collect_unstable_book_section_file_names, collect_unstable_feature_names, LANG_FEATURES_DIR, - LIB_FEATURES_DIR, PATH_STR, + LANG_FEATURES_DIR, LIB_FEATURES_DIR, PATH_STR, collect_unstable_book_section_file_names, + collect_unstable_feature_names, }; fn generate_stub_issue(path: &Path, name: &str, issue: u32) { |
