diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-02-08 22:12:13 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-02-08 22:12:13 +0000 |
| commit | 1fcae03369abb4c2cc180cd5a49e1f4440a81300 (patch) | |
| tree | fe705ff77c286f5fc4c09acc98d2f124086d0479 /src | |
| parent | 3183b44a1ec209b06e0c26cbc92217176b59dc76 (diff) | |
| download | rust-1fcae03369abb4c2cc180cd5a49e1f4440a81300.tar.gz rust-1fcae03369abb4c2cc180cd5a49e1f4440a81300.zip | |
Rustfmt
Diffstat (limited to 'src')
24 files changed, 791 insertions, 580 deletions
diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 82779dc6306..25e5e9e6eb9 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -157,12 +157,16 @@ pub fn prebuilt_llvm_config( /// 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) = crate::utils::channel::read_commit_info_file(&config.src) { info.sha.trim().to_owned() diff --git a/src/bootstrap/src/core/build_steps/toolstate.rs b/src/bootstrap/src/core/build_steps/toolstate.rs index 84871331bd5..668133f05cb 100644 --- a/src/bootstrap/src/core/build_steps/toolstate.rs +++ b/src/bootstrap/src/core/build_steps/toolstate.rs @@ -42,11 +42,15 @@ 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/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 08421dc1f5b..8e767a8dcc6 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -315,29 +315,32 @@ 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/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/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 0c27597083d..74e1ed5c637 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -114,11 +114,14 @@ fn test_intersection() { ]; let subset = library_set.intersection_removing_matches(&mut command_paths, Kind::Build); assert_eq!(subset, set(&["library/core", "library/alloc"]),); - assert_eq!(command_paths, vec![ - CLIStepPath::from(PathBuf::from("library/core")).will_be_executed(true), - CLIStepPath::from(PathBuf::from("library/alloc")).will_be_executed(true), - CLIStepPath::from(PathBuf::from("library/stdarch")).will_be_executed(false), - ]); + assert_eq!( + command_paths, + vec![ + CLIStepPath::from(PathBuf::from("library/core")).will_be_executed(true), + CLIStepPath::from(PathBuf::from("library/alloc")).will_be_executed(true), + CLIStepPath::from(PathBuf::from("library/stdarch")).will_be_executed(false), + ] + ); } #[test] @@ -135,10 +138,13 @@ fn test_resolve_parent_and_subpaths() { let library_set = set(&["src/tools/miri", "src/tools/miri/cargo-miri"]); library_set.intersection_removing_matches(&mut command_paths, Kind::Build); - assert_eq!(command_paths, vec![ - CLIStepPath::from(PathBuf::from("src/tools/miri")).will_be_executed(true), - CLIStepPath::from(PathBuf::from("src/tools/miri/cargo-miri")).will_be_executed(true), - ]); + assert_eq!( + command_paths, + vec![ + CLIStepPath::from(PathBuf::from("src/tools/miri")).will_be_executed(true), + CLIStepPath::from(PathBuf::from("src/tools/miri/cargo-miri")).will_be_executed(true), + ] + ); } #[test] @@ -212,18 +218,22 @@ fn alias_and_path_for_library() { &["library".into(), "core".into()], configure("build", &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]), ); - assert_eq!(first(cache.all::<compile::Std>()), &[ - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1) - ]); + assert_eq!( + first(cache.all::<compile::Std>()), + &[ + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1) + ] + ); let mut cache = run_build( &["library".into(), "core".into()], configure("doc", &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]), ); - assert_eq!(first(cache.all::<doc::Std>()), &[ - doc_std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0) - ]); + assert_eq!( + first(cache.all::<doc::Std>()), + &[doc_std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0)] + ); } #[test] @@ -271,10 +281,13 @@ mod defaults { let mut cache = run_build(&[], configure("build", &[TEST_TRIPLE_1], &[TEST_TRIPLE_1])); let a = TargetSelection::from_user(TEST_TRIPLE_1); - assert_eq!(first(cache.all::<compile::Std>()), &[ - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), - ]); + assert_eq!( + first(cache.all::<compile::Std>()), + &[ + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), + ] + ); assert!(!cache.all::<compile::Assemble>().is_empty()); // Make sure rustdoc is only built once. assert_eq!( @@ -283,9 +296,10 @@ mod defaults { // - this is the compiler it's _linked_ to, not built with. &[tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }], ); - assert_eq!(first(cache.all::<compile::Rustc>()), &[ - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0) - ],); + assert_eq!( + first(cache.all::<compile::Rustc>()), + &[rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0)], + ); } #[test] @@ -294,9 +308,10 @@ mod defaults { let mut cache = run_build(&[], config); let a = TargetSelection::from_user(TEST_TRIPLE_1); - assert_eq!(first(cache.all::<compile::Std>()), &[ - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0) - ]); + assert_eq!( + first(cache.all::<compile::Std>()), + &[std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0)] + ); assert!(!cache.all::<compile::Assemble>().is_empty()); assert_eq!( first(cache.all::<tool::Rustdoc>()), @@ -323,25 +338,37 @@ 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 0), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 0), - ]); + assert_eq!( + first(cache.all::<compile::Std>()), + &[ + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 0), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 0), + ] + ); } #[test] @@ -355,15 +382,17 @@ 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 } },] + ); } } @@ -385,18 +414,20 @@ 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] @@ -407,19 +438,25 @@ mod dist { let a = TargetSelection::from_user(TEST_TRIPLE_1); let b = TargetSelection::from_user(TEST_TRIPLE_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 } - },]); - 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]); } @@ -433,27 +470,38 @@ mod dist { let a = TargetSelection::from_user(TEST_TRIPLE_1); let b = TargetSelection::from_user(TEST_TRIPLE_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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 2), + ], + ); assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]); } @@ -467,49 +515,56 @@ 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), + ] + ); } #[test] fn dist_with_targets_and_hosts() { let mut cache = run_build( &[], - configure(&[TEST_TRIPLE_1, TEST_TRIPLE_2], &[ - TEST_TRIPLE_1, - TEST_TRIPLE_2, - TEST_TRIPLE_3, - ]), + configure( + &[TEST_TRIPLE_1, TEST_TRIPLE_2], + &[TEST_TRIPLE_1, TEST_TRIPLE_2, TEST_TRIPLE_3], + ), ); let a = TargetSelection::from_user(TEST_TRIPLE_1); let b = TargetSelection::from_user(TEST_TRIPLE_2); let c = TargetSelection::from_user(TEST_TRIPLE_3); - 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]); } @@ -523,10 +578,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] @@ -539,65 +594,84 @@ mod dist { let a = TargetSelection::from_user(TEST_TRIPLE_1); let b = TargetSelection::from_user(TEST_TRIPLE_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::<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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, 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(&[TEST_TRIPLE_1, TEST_TRIPLE_2], &[ - TEST_TRIPLE_1, - TEST_TRIPLE_2, - TEST_TRIPLE_3, - ])); + let build = Build::new(configure( + &[TEST_TRIPLE_1, TEST_TRIPLE_2], + &[TEST_TRIPLE_1, TEST_TRIPLE_2, TEST_TRIPLE_3], + )); let mut builder = Builder::new(&build); - builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[ - "compiler/rustc".into(), - "library".into(), - ]); + builder.run_step_descriptions( + &Builder::get_step_descriptions(Kind::Build), + &["compiler/rustc".into(), "library".into()], + ); - assert_eq!(first(builder.cache.all::<compile::Std>()), &[ - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 2), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_3, stage = 2), - ]); + assert_eq!( + first(builder.cache.all::<compile::Std>()), + &[ + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 2), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_3, stage = 2), + ] + ); assert_eq!(builder.cache.all::<compile::Assemble>().len(), 5); - assert_eq!(first(builder.cache.all::<compile::Rustc>()), &[ - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2), - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 2), - ]); + assert_eq!( + first(builder.cache.all::<compile::Rustc>()), + &[ + rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), + rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 2), + rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 1), + rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_2, stage = 2), + ] + ); } #[test] @@ -626,20 +700,29 @@ mod dist { let a = TargetSelection::from_user(TEST_TRIPLE_1); - assert_eq!(first(builder.cache.all::<compile::Std>()), &[ - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), - std!(TEST_TRIPLE_1 => TEST_TRIPLE_3, 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), - rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), - ]); + assert_eq!( + first(builder.cache.all::<compile::Std>()), + &[ + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), + std!(TEST_TRIPLE_1 => TEST_TRIPLE_3, 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!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0), + rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1), + ] + ); } #[test] @@ -669,18 +752,22 @@ mod dist { let host = TargetSelection::from_user(TEST_TRIPLE_1); - 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: crate::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: crate::Mode::Std, + crates: vec!["std".to_owned()], + },] + ); } #[test] @@ -699,14 +786,16 @@ 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] @@ -743,9 +832,10 @@ 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 @@ -757,11 +847,14 @@ 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 4694dd2ca4e..d3ed7ecddd3 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1928,11 +1928,14 @@ 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/librustdoc/clean/cfg/tests.rs b/src/librustdoc/clean/cfg/tests.rs index 2c62e12c96d..26dc101e4b5 100644 --- a/src/librustdoc/clean/cfg/tests.rs +++ b/src/librustdoc/clean/cfg/tests.rs @@ -276,10 +276,13 @@ 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]); @@ -302,18 +305,16 @@ 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/mod.rs b/src/librustdoc/clean/mod.rs index b14381c0c40..1d62a93e723 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -544,14 +544,18 @@ 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 } => { - (def.name, GenericParamDefKind::Const { + ty::GenericParamDefKind::Const { has_default, synthetic } => ( + def.name, + GenericParamDefKind::Const { ty: Box::new(clean_middle_ty( ty::Binder::dummy( cx.tcx @@ -573,8 +577,8 @@ fn clean_generic_param_def( None }, synthetic, - }) - } + }, + ), }; GenericParamDef { name, def_id: def.def_id, kind } @@ -619,21 +623,25 @@ 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 } => { - (param.name.ident().name, GenericParamDefKind::Const { + hir::GenericParamKind::Const { ty, default, synthetic } => ( + param.name.ident().name, + GenericParamDefKind::Const { ty: Box::new(clean_ty(ty, cx)), default: default.map(|ct| { Box::new(lower_const_arg_for_rustdoc(cx.tcx, ct, FeedConstTy::No).to_string()) }), synthetic, - }) - } + }, + ), }; GenericParamDef { name, def_id: param.def_id.to_def_id(), kind } @@ -653,9 +661,10 @@ 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,11 +1064,10 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[hir::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}"); } @@ -1422,11 +1430,11 @@ 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 { - parent: None, - predicates, - }); + let mut generics = clean_ty_generics( + cx, + tcx.generics_of(assoc_item.def_id), + ty::GenericPredicates { parent: None, predicates }, + ); simplify::move_bounds_to_generic_parameters(&mut generics); if let ty::AssocItemContainer::Trait = assoc_item.container { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 583cd404dca..5f7c30a33ab 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1253,10 +1253,13 @@ impl GenericBound { } pub(crate) fn maybe_sized(cx: &mut DocContext<'_>) -> GenericBound { - Self::sized_with(cx, hir::TraitBoundModifiers { - polarity: hir::BoundPolarity::Maybe(DUMMY_SP), - constness: hir::BoundConstness::Never, - }) + Self::sized_with( + cx, + hir::TraitBoundModifiers { + polarity: hir::BoundPolarity::Maybe(DUMMY_SP), + constness: hir::BoundConstness::Never, + }, + ) } fn sized_with(cx: &mut DocContext<'_>, modifiers: hir::TraitBoundModifiers) -> GenericBound { diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 7b2aee4b4a5..8c91cae4931 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -65,26 +65,34 @@ 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/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index 2001a763c09..bb42b877a2c 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -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/search_index.rs b/src/librustdoc/html/render/search_index.rs index 8ac8b3a1f84..95f617c9839 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -1265,13 +1265,14 @@ 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/json/mod.rs b/src/librustdoc/json/mod.rs index 789a5614967..6f8cf25554f 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -268,11 +268,14 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { .iter() .chain(&self.cache.external_paths) .map(|(&k, &(ref path, kind))| { - (self.id_from_item_default(k.into()), types::ItemSummary { - crate_id: k.krate.as_u32(), - path: path.iter().map(|s| s.to_string()).collect(), - kind: kind.into_json(self), - }) + ( + self.id_from_item_default(k.into()), + types::ItemSummary { + crate_id: k.krate.as_u32(), + path: path.iter().map(|s| s.to_string()).collect(), + kind: kind.into_json(self), + }, + ) }) .collect(), external_crates: self @@ -281,13 +284,16 @@ 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/passes/lint/bare_urls.rs b/src/librustdoc/passes/lint/bare_urls.rs index 77d7cf5772d..1e07277d38e 100644 --- a/src/librustdoc/passes/lint/bare_urls.rs +++ b/src/librustdoc/passes/lint/bare_urls.rs @@ -77,9 +77,10 @@ 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/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index feec2a7444f..c21bf82b852 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -603,11 +603,14 @@ 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/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index ebba16d41f9..023658a3dd4 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -251,9 +251,10 @@ 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/coverage-dump/src/covfun.rs b/src/tools/coverage-dump/src/covfun.rs index 33fac3edccd..82ebd33d0d1 100644 --- a/src/tools/coverage-dump/src/covfun.rs +++ b/src/tools/coverage-dump/src/covfun.rs @@ -95,10 +95,13 @@ pub(crate) fn dump_covfun_mappings( // has increased or decreased the number of physical counters needed. // (It's possible for the generated code to have more counters that // aren't used by any mappings, but that should hopefully be rare.) - println!("Highest counter ID seen: {}", match max_counter { - Some(id) => format!("c{id}"), - None => "(none)".to_owned(), - }); + println!( + "Highest counter ID seen: {}", + match max_counter { + Some(id) => format!("c{id}"), + None => "(none)".to_owned(), + } + ); println!(); } Ok(()) diff --git a/src/tools/generate-copyright/src/cargo_metadata.rs b/src/tools/generate-copyright/src/cargo_metadata.rs index 420579372ac..51e353e9b22 100644 --- a/src/tools/generate-copyright/src/cargo_metadata.rs +++ b/src/tools/generate-copyright/src/cargo_metadata.rs @@ -98,12 +98,15 @@ 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/generate-copyright/src/main.rs b/src/tools/generate-copyright/src/main.rs index 0a446ecff5b..7a014989e68 100644 --- a/src/tools/generate-copyright/src/main.rs +++ b/src/tools/generate-copyright/src/main.rs @@ -24,12 +24,16 @@ fn main() -> Result<(), Error> { let root_path = std::path::absolute(".")?; // Scan Cargo dependencies - let mut collected_cargo_metadata = - cargo_metadata::get_metadata_and_notices(&cargo, &out_dir.join("vendor"), &root_path, &[ + let mut collected_cargo_metadata = cargo_metadata::get_metadata_and_notices( + &cargo, + &out_dir.join("vendor"), + &root_path, + &[ Path::new("./Cargo.toml"), Path::new("./src/tools/cargo/Cargo.toml"), Path::new("./library/Cargo.toml"), - ])?; + ], + )?; let library_collected_cargo_metadata = cargo_metadata::get_metadata_and_notices( &cargo, diff --git a/src/tools/jsondoclint/src/validator/tests.rs b/src/tools/jsondoclint/src/validator/tests.rs index a37e6c2eb5c..28deb7e7cee 100644 --- a/src/tools/jsondoclint/src/validator/tests.rs +++ b/src/tools/jsondoclint/src/validator/tests.rs @@ -21,32 +21,42 @@ 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(0), - 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(0), + 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 @@ -58,48 +68,60 @@ fn errors_on_local_in_paths_and_not_index() { crate_version: None, includes_private: false, index: FxHashMap::from_iter([ - (Id(0), Item { - id: Id(0), - crate_id: 0, - name: Some("microcore".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::from_iter([(("prim@i32".to_owned(), Id(2)))]), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Module(Module { - is_crate: true, - items: vec![Id(1)], - is_stripped: false, - }), - }), - (Id(1), Item { - id: Id(1), - 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![] }), - }), + ( + Id(0), + Item { + id: Id(0), + crate_id: 0, + name: Some("microcore".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::from_iter([(("prim@i32".to_owned(), Id(2)))]), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Module(Module { + is_crate: true, + items: vec![Id(1)], + is_stripped: false, + }), + }, + ), + ( + Id(1), + Item { + id: Id(1), + 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(2), ItemSummary { - crate_id: 0, - path: vec!["microcore".to_owned(), "i32".to_owned()], - kind: ItemKind::Primitive, - })]), + paths: FxHashMap::from_iter([( + Id(2), + 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(2), - kind: ErrorKind::Custom("Id for local item in `paths` but not in `index`".to_owned()), - }]); + check( + &krate, + &[Error { + id: Id(2), + kind: ErrorKind::Custom("Id for local item in `paths` but not in `index`".to_owned()), + }], + ); } #[test] @@ -117,84 +139,96 @@ fn errors_on_missing_path() { crate_version: None, includes_private: false, index: FxHashMap::from_iter([ - (Id(0), Item { - id: Id(0), - crate_id: 0, - name: Some("foo".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![Id(1), Id(2)], - is_stripped: false, - }), - }), - (Id(1), Item { - id: Id(0), - crate_id: 0, - name: Some("Bar".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::default(), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Struct(Struct { - kind: StructKind::Unit, - generics: generics.clone(), - impls: vec![], - }), - }), - (Id(2), Item { - id: Id(0), - crate_id: 0, - name: Some("mk_bar".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::default(), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Function(Function { - sig: FunctionSignature { - inputs: vec![], - output: Some(Type::ResolvedPath(Path { - path: "Bar".to_owned(), - id: Id(1), - args: None, - })), - is_c_variadic: false, - }, - generics, - header: FunctionHeader { - is_const: false, - is_unsafe: false, - is_async: false, - abi: Abi::Rust, - }, - has_body: true, - }), - }), + ( + Id(0), + Item { + id: Id(0), + crate_id: 0, + name: Some("foo".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![Id(1), Id(2)], + is_stripped: false, + }), + }, + ), + ( + Id(1), + Item { + id: Id(0), + crate_id: 0, + name: Some("Bar".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::default(), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Struct(Struct { + kind: StructKind::Unit, + generics: generics.clone(), + impls: vec![], + }), + }, + ), + ( + Id(2), + Item { + id: Id(0), + crate_id: 0, + name: Some("mk_bar".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::default(), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Function(Function { + sig: FunctionSignature { + inputs: vec![], + output: Some(Type::ResolvedPath(Path { + path: "Bar".to_owned(), + id: Id(1), + args: None, + })), + is_c_variadic: false, + }, + generics, + header: FunctionHeader { + is_const: false, + is_unsafe: false, + is_async: false, + abi: Abi::Rust, + }, + has_body: true, + }), + }, + ), ]), - paths: FxHashMap::from_iter([(Id(0), ItemSummary { - crate_id: 0, - path: vec!["foo".to_owned()], - kind: ItemKind::Module, - })]), + paths: FxHashMap::from_iter([( + Id(0), + ItemSummary { crate_id: 0, path: vec!["foo".to_owned()], kind: ItemKind::Module }, + )]), external_crates: FxHashMap::default(), format_version: rustdoc_json_types::FORMAT_VERSION, }; - check(&krate, &[Error { - kind: ErrorKind::Custom( - r#"No entry in '$.paths' for Path { path: "Bar", id: Id(1), args: None }"#.to_owned(), - ), - id: Id(1), - }]); + check( + &krate, + &[Error { + kind: ErrorKind::Custom( + r#"No entry in '$.paths' for Path { path: "Bar", id: Id(1), args: None }"# + .to_owned(), + ), + id: Id(1), + }], + ); } #[test] @@ -204,18 +238,25 @@ fn checks_local_crate_id_is_correct() { root: Id(0), crate_version: None, includes_private: false, - index: FxHashMap::from_iter([(Id(0), Item { - id: Id(0), - 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(0), + Item { + id: Id(0), + 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 f6e84465780..9fd33e23204 100644 --- a/src/tools/lint-docs/src/lib.rs +++ b/src/tools/lint-docs/src/lib.rs @@ -19,24 +19,30 @@ 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/rust-installer/src/compression.rs b/src/tools/rust-installer/src/compression.rs index 96c48657c46..df3a98ae789 100644 --- a/src/tools/rust-installer/src/compression.rs +++ b/src/tools/rust-installer/src/compression.rs @@ -81,14 +81,17 @@ 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/tidy/src/ext_tool_checks.rs b/src/tools/tidy/src/ext_tool_checks.rs index 2a4cff1d12e..4f9a20fa9e2 100644 --- a/src/tools/tidy/src/ext_tool_checks.rs +++ b/src/tools/tidy/src/ext_tool_checks.rs @@ -95,10 +95,14 @@ fn check_impl( if res.is_err() && show_diff { eprintln!("\npython linting failed! Printing diff suggestions:"); - let _ = run_ruff(root_path, outdir, py_path, &cfg_args, &file_args, &[ - "check".as_ref(), - "--diff".as_ref(), - ]); + let _ = run_ruff( + root_path, + outdir, + py_path, + &cfg_args, + &file_args, + &["check".as_ref(), "--diff".as_ref()], + ); } // Rethrow error let _ = res?; @@ -120,10 +124,14 @@ fn check_impl( if show_diff { eprintln!("\npython formatting does not match! Printing diff:"); - let _ = run_ruff(root_path, outdir, py_path, &cfg_args, &file_args, &[ - "format".as_ref(), - "--diff".as_ref(), - ]); + let _ = run_ruff( + root_path, + outdir, + py_path, + &cfg_args, + &file_args, + &["format".as_ref(), "--diff".as_ref()], + ); } eprintln!("rerun tidy with `--extra-checks=py:fmt --bless` to reformat Python code"); } @@ -148,10 +156,11 @@ 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/known_bug.rs b/src/tools/tidy/src/known_bug.rs index a8771654144..e1921715ab9 100644 --- a/src/tools/tidy/src/known_bug.rs +++ b/src/tools/tidy/src/known_bug.rs @@ -14,13 +14,10 @@ pub fn check(filepath: &Path, bad: &mut bool) { let test_path_segments_str = test_path_segments.iter().map(|s| s.as_str()).collect::<Vec<&str>>(); - if !matches!(test_path_segments_str[..], [ - .., - "tests", - "crashes", - "auxiliary", - _aux_file_rs - ]) && !contents.lines().any(|line| line.starts_with("//@ known-bug: ")) + if !matches!( + test_path_segments_str[..], + [.., "tests", "crashes", "auxiliary", _aux_file_rs] + ) && !contents.lines().any(|line| line.starts_with("//@ known-bug: ")) { tidy_error!( bad, diff --git a/src/tools/unicode-table-generator/src/raw_emitter.rs b/src/tools/unicode-table-generator/src/raw_emitter.rs index 46010692fe5..ee94d3c93a6 100644 --- a/src/tools/unicode-table-generator/src/raw_emitter.rs +++ b/src/tools/unicode-table-generator/src/raw_emitter.rs @@ -355,12 +355,15 @@ 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<_, _>>(); @@ -375,21 +378,24 @@ 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 } |
