diff options
| author | Oli Scherer <github35764891676564198441@oli-obk.de> | 2025-08-30 07:07:41 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-30 07:07:41 +0000 |
| commit | c8d20ceb1be87bc35035328aa1925cb3d95ad10b (patch) | |
| tree | f3ccfe3fdc0af4ed3cda4e0352ba5743c1c10536 /src | |
| parent | b00c449ef7330353c85e4b1bb4cd30cf5a10f919 (diff) | |
| parent | d269d234e033e2b52722ea78767fe10898184993 (diff) | |
| download | rust-c8d20ceb1be87bc35035328aa1925cb3d95ad10b.tar.gz rust-c8d20ceb1be87bc35035328aa1925cb3d95ad10b.zip | |
Merge pull request #4548 from rust-lang/rustup-2025-08-30
Automatic Rustup
Diffstat (limited to 'src')
66 files changed, 444 insertions, 352 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index d30005c8d51..0b75e85772f 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -99,28 +99,12 @@ impl Std { deps } - /// Returns true if the standard library will be uplifted from stage 1 for the given - /// `build_compiler` (which determines the stdlib stage) and `target`. + /// Returns true if the standard library should be uplifted from stage 1. /// - /// Uplifting is enabled if we're building a stage2+ libstd, full bootstrap is - /// disabled and we have a stage1 libstd already compiled for the given target. - pub fn should_be_uplifted_from_stage_1( - builder: &Builder<'_>, - stage: u32, - target: TargetSelection, - ) -> bool { - stage > 1 - && !builder.config.full_bootstrap - // This estimates if a stage1 libstd exists for the given target. If we're not - // cross-compiling, it should definitely exist by the time we're building a stage2 - // libstd. - // Or if we are cross-compiling, and we are building a cross-compiled rustc, then that - // rustc needs to link to a cross-compiled libstd, so again we should have a stage1 - // libstd for the given target prepared. - // Even if we guess wrong in the cross-compiled case, the worst that should happen is - // that we build a fresh stage1 libstd below, and then we immediately uplift it, so we - // don't pay the libstd build cost twice. - && (target == builder.host_target || builder.config.hosts.contains(&target)) + /// Uplifting is enabled if we're building a stage2+ libstd and full bootstrap is + /// disabled. + pub fn should_be_uplifted_from_stage_1(builder: &Builder<'_>, stage: u32) -> bool { + stage > 1 && !builder.config.full_bootstrap } } @@ -150,7 +134,9 @@ impl Step for Std { trace!(force_recompile); run.builder.ensure(Std { - build_compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()), + // Note: we don't use compiler_for_std here, so that `x build library --stage 2` + // builds a stage2 rustc. + build_compiler: run.builder.compiler(run.builder.top_stage, builder.host_target), target: run.target, crates, force_recompile, @@ -226,7 +212,7 @@ impl Step for Std { // Stage of the stdlib that we're building let stage = build_compiler.stage; - if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage, target) { + if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage) { let build_compiler_for_std_to_uplift = builder.compiler(1, builder.host_target); let stage_1_stamp = builder.std(build_compiler_for_std_to_uplift, target); diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 778c3beb50f..f113dd7683d 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -96,6 +96,8 @@ impl Step for Docs { } } +/// Builds the `rust-docs-json` installer component. +/// It contains the documentation of the standard library in JSON format. #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct JsonDocs { build_compiler: Compiler, @@ -113,12 +115,11 @@ impl Step for JsonDocs { fn make_run(run: RunConfig<'_>) { run.builder.ensure(JsonDocs { - build_compiler: run.builder.compiler(run.builder.top_stage, run.builder.host_target), + build_compiler: run.builder.compiler_for_std(run.builder.top_stage), target: run.target, }); } - /// Builds the `rust-docs-json` installer component. fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { let target = self.target; let directory = builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler( @@ -135,6 +136,10 @@ impl Step for JsonDocs { tarball.add_bulk_dir(directory, dest); Some(tarball.generate()) } + + fn metadata(&self) -> Option<StepMetadata> { + Some(StepMetadata::dist("json-docs", self.target).built_by(self.build_compiler)) + } } /// Builds the `rustc-docs` installer component. @@ -764,22 +769,7 @@ pub struct Std { impl Std { pub fn new(builder: &Builder<'_>, target: TargetSelection) -> Self { - // This is an important optimization mainly for CI. - // Normally, to build stage N libstd, we need stage N rustc. - // However, if we know that we will uplift libstd from stage 1 anyway, building the stage N - // rustc can be wasteful. - // In particular, if we do a cross-compiling dist stage 2 build from T1 to T2, we need: - // - stage 2 libstd for T2 (uplifted from stage 1, where it was built by T1 rustc) - // - stage 2 rustc for T2 - // However, without this optimization, we would also build stage 2 rustc for **T1**, which - // is completely wasteful. - let build_compiler = - if compile::Std::should_be_uplifted_from_stage_1(builder, builder.top_stage, target) { - builder.compiler(1, builder.host_target) - } else { - builder.compiler(builder.top_stage, builder.host_target) - }; - Std { build_compiler, target } + Std { build_compiler: builder.compiler_for_std(builder.top_stage), target } } } diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 8c20c8c479a..9ef1fee1fec 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -616,7 +616,7 @@ impl Step for Std { return; } run.builder.ensure(Std { - build_compiler: run.builder.compiler(run.builder.top_stage, run.builder.host_target), + build_compiler: run.builder.compiler_for_std(run.builder.top_stage), target: run.target, format: if run.builder.config.cmd.json() { DocumentationFormat::Json diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index abe79405984..26b4aaa8b5b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2025,8 +2025,6 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?} cmd.arg("--verbose"); } - cmd.arg("--json"); - if builder.config.rustc_debug_assertions { cmd.arg("--with-rustc-debug-assertions"); } diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index f794f4e079a..b224a7e7322 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1360,6 +1360,30 @@ impl<'a> Builder<'a> { self.ensure(compile::Assemble { target_compiler: Compiler::new(stage, host) }) } + /// This function can be used to provide a build compiler for building + /// the standard library, in order to avoid unnecessary rustc builds in case where std uplifting + /// would happen anyway. + /// + /// This is an important optimization mainly for CI. + /// + /// Normally, to build stage N libstd, we need stage N rustc. + /// However, if we know that we will uplift libstd from stage 1 anyway, building the stage N + /// rustc can be wasteful. + /// In particular, if we do a cross-compiling dist stage 2 build from target1 to target2, + /// we need: + /// - stage 2 libstd for target2 (uplifted from stage 1, where it was built by target1 rustc) + /// - stage 2 rustc for target2 + /// + /// However, without this optimization, we would also build stage 2 rustc for **target1**, + /// which is completely wasteful. + pub fn compiler_for_std(&self, stage: u32) -> Compiler { + if compile::Std::should_be_uplifted_from_stage_1(self, stage) { + self.compiler(1, self.host_target) + } else { + self.compiler(stage, self.host_target) + } + } + /// Similar to `compiler`, except handles the full-bootstrap option to /// silently use the stage1 compiler instead of a stage2 compiler if one is /// requested. diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 3c2cb782850..b079117c5a7 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1066,6 +1066,7 @@ mod snapshot { [build] rustc 1 <host> -> rustc 2 <target1> [build] rustc 2 <host> -> std 2 <host> [build] rustc 2 <host> -> std 2 <target1> + [build] rustc 1 <host> -> std 1 <target2> [build] rustc 2 <host> -> std 2 <target2> "); } @@ -1122,9 +1123,8 @@ mod snapshot { [doc] book/2018-edition (book) <host> [build] rustdoc 1 <host> [doc] rustc 1 <host> -> standalone 2 <host> + [doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> rustc 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> error-index 2 <host> [doc] rustc 1 <host> -> error-index 2 <host> [doc] nomicon (book) <host> @@ -1141,8 +1141,10 @@ mod snapshot { [doc] rustc 1 <host> -> releases 2 <host> [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[] + [doc] rustc 1 <host> -> std 1 <host> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <host> [dist] mingw <host> + [build] rustdoc 2 <host> [build] rustc 0 <host> -> GenerateCopyright 1 <host> [dist] rustc <host> [dist] rustc 1 <host> -> std 1 <host> @@ -1182,12 +1184,11 @@ mod snapshot { [doc] book/2018-edition (book) <host> [build] rustdoc 1 <host> [doc] rustc 1 <host> -> standalone 2 <host> + [doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> rustc 2 <host> [build] rustc 1 <host> -> LldWrapper 2 <host> [build] rustc 1 <host> -> WasmComponentLd 2 <host> [build] rustc 1 <host> -> LlvmBitcodeLinker 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> error-index 2 <host> [doc] rustc 1 <host> -> error-index 2 <host> [doc] nomicon (book) <host> @@ -1204,8 +1205,10 @@ mod snapshot { [doc] rustc 1 <host> -> releases 2 <host> [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[] + [doc] rustc 1 <host> -> std 1 <host> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <host> [dist] mingw <host> + [build] rustdoc 2 <host> [build] rustc 1 <host> -> rust-analyzer-proc-macro-srv 2 <host> [build] rustc 0 <host> -> GenerateCopyright 1 <host> [dist] rustc <host> @@ -1226,6 +1229,8 @@ mod snapshot { [build] rustc 1 <host> -> miri 2 <host> [build] rustc 1 <host> -> cargo-miri 2 <host> [dist] rustc 1 <host> -> miri 2 <host> + [doc] rustc 2 <host> -> std 2 <host> crates=[] + [dist] rustc 2 <host> -> json-docs 3 <host> [dist] rustc 1 <host> -> extended 2 <host> [dist] reproducible-artifacts <host> "); @@ -1259,10 +1264,9 @@ mod snapshot { [doc] book/2018-edition (book) <target1> [doc] rustc 1 <host> -> standalone 2 <host> [doc] rustc 1 <host> -> standalone 2 <target1> + [doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 <host> -> std 1 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> rustc 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [doc] rustc 2 <host> -> std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> error-index 2 <host> [doc] rustc 1 <host> -> error-index 2 <host> [doc] nomicon (book) <host> @@ -1290,15 +1294,17 @@ mod snapshot { [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <host> [dist] docs <target1> - [doc] rustc 2 <host> -> std 2 <host> crates=[] - [doc] rustc 2 <host> -> std 2 <target1> crates=[] + [doc] rustc 1 <host> -> std 1 <host> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <host> + [doc] rustc 1 <host> -> std 1 <target1> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <target1> [dist] mingw <host> [dist] mingw <target1> + [build] rustdoc 2 <host> [build] rustc 0 <host> -> GenerateCopyright 1 <host> [dist] rustc <host> [dist] rustc 1 <host> -> std 1 <host> - [build] rustc 2 <host> -> std 2 <target1> - [dist] rustc 2 <host> -> std 2 <target1> + [dist] rustc 1 <host> -> std 1 <target1> [dist] rustc 1 <host> -> rustc-dev 2 <host> [dist] src <> [dist] reproducible-artifacts <host> @@ -1327,9 +1333,8 @@ mod snapshot { [doc] book/2018-edition (book) <host> [build] rustdoc 1 <host> [doc] rustc 1 <host> -> standalone 2 <host> + [doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> rustc 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> error-index 2 <host> [doc] rustc 1 <host> -> error-index 2 <host> [build] llvm <target1> @@ -1352,8 +1357,10 @@ mod snapshot { [doc] rustc 1 <host> -> releases 2 <host> [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[] + [doc] rustc 1 <host> -> std 1 <host> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <host> [dist] mingw <host> + [build] rustdoc 2 <host> [build] rustc 0 <host> -> GenerateCopyright 1 <host> [dist] rustc <host> [build] rustdoc 2 <target1> @@ -1396,10 +1403,9 @@ mod snapshot { [doc] book/2018-edition (book) <target1> [doc] rustc 1 <host> -> standalone 2 <host> [doc] rustc 1 <host> -> standalone 2 <target1> + [doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 <host> -> std 1 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> rustc 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [doc] rustc 2 <host> -> std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> error-index 2 <host> [doc] rustc 1 <host> -> error-index 2 <host> [build] llvm <target1> @@ -1432,10 +1438,13 @@ mod snapshot { [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <host> [dist] docs <target1> - [doc] rustc 2 <host> -> std 2 <host> crates=[] - [doc] rustc 2 <host> -> std 2 <target1> crates=[] + [doc] rustc 1 <host> -> std 1 <host> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <host> + [doc] rustc 1 <host> -> std 1 <target1> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <target1> [dist] mingw <host> [dist] mingw <target1> + [build] rustdoc 2 <host> [build] rustc 0 <host> -> GenerateCopyright 1 <host> [dist] rustc <host> [build] rustdoc 2 <target1> @@ -1473,9 +1482,7 @@ mod snapshot { [build] rustdoc 1 <host> [build] rustc 1 <host> -> std 1 <host> [doc] rustc 1 <host> -> standalone 2 <target1> - [build] rustc 1 <host> -> rustc 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 <host> -> std 1 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [doc] nomicon (book) <target1> [doc] rustc 1 <host> -> reference (book) 2 <target1> [doc] rustdoc (book) <target1> @@ -1488,10 +1495,10 @@ mod snapshot { [doc] rustc 1 <host> -> releases 2 <target1> [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <target1> - [doc] rustc 2 <host> -> std 2 <target1> crates=[] + [doc] rustc 1 <host> -> std 1 <target1> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <target1> [dist] mingw <target1> - [build] rustc 2 <host> -> std 2 <target1> - [dist] rustc 2 <host> -> std 2 <target1> + [dist] rustc 1 <host> -> std 1 <target1> "); } @@ -1519,10 +1526,7 @@ mod snapshot { [build] rustdoc 1 <host> [build] rustc 1 <host> -> std 1 <host> [doc] rustc 1 <host> -> standalone 2 <target1> - [build] rustc 1 <host> -> rustc 2 <host> - [build] rustc 1 <host> -> WasmComponentLd 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 <host> -> std 1 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] llvm <target1> [build] rustc 1 <host> -> rustc 2 <target1> [build] rustc 1 <host> -> WasmComponentLd 2 <target1> @@ -1542,7 +1546,8 @@ mod snapshot { [doc] rustc 1 <host> -> releases 2 <target1> [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <target1> - [doc] rustc 2 <host> -> std 2 <target1> crates=[] + [doc] rustc 1 <host> -> std 1 <target1> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <target1> [dist] mingw <target1> [build] rustdoc 2 <target1> [build] rustc 1 <host> -> rust-analyzer-proc-macro-srv 2 <target1> @@ -1567,13 +1572,14 @@ mod snapshot { [dist] rustc 1 <host> -> miri 2 <target1> [build] rustc 1 <host> -> LlvmBitcodeLinker 2 <target1> [doc] rustc 2 <target1> -> std 2 <target1> crates=[] + [dist] rustc 2 <target1> -> json-docs 3 <target1> [dist] rustc 1 <host> -> extended 2 <target1> [dist] reproducible-artifacts <target1> "); } /// Simulates e.g. the powerpc64 builder, which is fully cross-compiled from x64, but it does - /// not build docs. Crutically, it shouldn't build host stage 2 rustc. + /// not build docs. Crucially, it shouldn't build host stage 2 rustc. /// /// This is a regression test for <https://github.com/rust-lang/rust/issues/138123> /// and <https://github.com/rust-lang/rust/issues/138004>. @@ -1663,10 +1669,9 @@ mod snapshot { [doc] book/2018-edition (book) <host> [build] rustdoc 1 <host> [doc] rustc 1 <host> -> standalone 2 <host> + [doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> rustc 2 <host> [build] rustc 1 <host> -> rustc_codegen_cranelift 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> error-index 2 <host> [doc] rustc 1 <host> -> error-index 2 <host> [doc] nomicon (book) <host> @@ -1683,8 +1688,10 @@ mod snapshot { [doc] rustc 1 <host> -> releases 2 <host> [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[] + [doc] rustc 1 <host> -> std 1 <host> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <host> [dist] mingw <host> + [build] rustdoc 2 <host> [build] rustc 0 <host> -> GenerateCopyright 1 <host> [dist] rustc <host> [dist] rustc 1 <host> -> rustc_codegen_cranelift 2 <host> @@ -1725,6 +1732,46 @@ mod snapshot { } #[test] + fn dist_rustc_docs() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .path("rustc-docs") + .render_steps(), @r" + [build] rustc 0 <host> -> UnstableBookGen 1 <host> + [build] rustc 0 <host> -> Rustbook 1 <host> + [doc] unstable-book (book) <host> + [build] llvm <host> + [build] rustc 0 <host> -> rustc 1 <host> + [build] rustc 1 <host> -> std 1 <host> + [doc] book (book) <host> + [doc] book/first-edition (book) <host> + [doc] book/second-edition (book) <host> + [doc] book/2018-edition (book) <host> + [build] rustdoc 1 <host> + [doc] rustc 1 <host> -> standalone 2 <host> + [doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 <host> -> rustc 2 <host> + [build] rustc 1 <host> -> error-index 2 <host> + [doc] rustc 1 <host> -> error-index 2 <host> + [doc] nomicon (book) <host> + [doc] rustc 1 <host> -> reference (book) 2 <host> + [doc] rustdoc (book) <host> + [doc] rust-by-example (book) <host> + [build] rustc 0 <host> -> LintDocs 1 <host> + [doc] rustc (book) <host> + [doc] cargo (book) <host> + [doc] clippy (book) <host> + [doc] embedded-book (book) <host> + [doc] edition-guide (book) <host> + [doc] style-guide (book) <host> + [doc] rustc 1 <host> -> releases 2 <host> + [build] rustc 0 <host> -> RustInstaller 1 <host> + "); + } + + #[test] fn check_compiler_no_explicit_stage() { let ctx = TestCtx::new(); insta::assert_snapshot!( @@ -2415,10 +2462,9 @@ mod snapshot { [doc] book/2018-edition (book) <host> [build] rustdoc 1 <host> [doc] rustc 1 <host> -> standalone 2 <host> + [doc] rustc 1 <host> -> std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> rustc 2 <host> [build] rustc 1 <host> -> WasmComponentLd 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 <host> -> error-index 2 <host> [doc] rustc 1 <host> -> error-index 2 <host> [doc] nomicon (book) <host> @@ -2436,6 +2482,7 @@ mod snapshot { [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <host> [dist] rustc 1 <host> -> std 1 <host> + [build] rustdoc 2 <host> [build] rustc 1 <host> -> rust-analyzer-proc-macro-srv 2 <host> [build] rustc 0 <host> -> GenerateCopyright 1 <host> [dist] rustc <host> diff --git a/src/bootstrap/src/utils/render_tests.rs b/src/bootstrap/src/utils/render_tests.rs index 40006aca5c5..90fd57d976d 100644 --- a/src/bootstrap/src/utils/render_tests.rs +++ b/src/bootstrap/src/utils/render_tests.rs @@ -250,8 +250,14 @@ impl<'a> Renderer<'a> { if failure.stdout.is_some() || failure.message.is_some() { println!("---- {} stdout ----", failure.name); if let Some(stdout) = &failure.stdout { - println!("{stdout}"); + // Captured test output normally ends with a newline, + // so only use `println!` if it doesn't. + print!("{stdout}"); + if !stdout.ends_with('\n') { + println!("\n\\ (no newline at end of output)"); + } } + println!("---- {} stdout end ----", failure.name); if let Some(message) = &failure.message { println!("NOTE: {message}"); } diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 2f815bcd141..edfc2db7d6f 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -103,7 +103,6 @@ target | notes [`powerpc64le-unknown-linux-gnu`](platform-support/powerpc64le-unknown-linux-gnu.md) | PPC64LE Linux (kernel 3.10+, glibc 2.17) [`powerpc64le-unknown-linux-musl`](platform-support/powerpc64le-unknown-linux-musl.md) | PPC64LE Linux (kernel 4.19+, musl 1.2.3) [`riscv64gc-unknown-linux-gnu`](platform-support/riscv64gc-unknown-linux-gnu.md) | RISC-V Linux (kernel 4.20+, glibc 2.29) -[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20+, musl 1.2.3) [`s390x-unknown-linux-gnu`](platform-support/s390x-unknown-linux-gnu.md) | S390x Linux (kernel 3.2+, glibc 2.17) [`x86_64-apple-darwin`](platform-support/apple-darwin.md) | 64-bit macOS (10.12+, Sierra+) [`x86_64-pc-windows-gnullvm`](platform-support/windows-gnullvm.md) | 64-bit x86 MinGW (Windows 10+), LLVM ABI @@ -183,6 +182,7 @@ target | std | notes [`riscv32imac-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMAC ISA) [`riscv32imafc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMAFC ISA) [`riscv32imc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMC ISA) +[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20+, musl 1.2.3) `riscv64gc-unknown-none-elf` | * | Bare RISC-V (RV64IMAFDC ISA) `riscv64imac-unknown-none-elf` | * | Bare RISC-V (RV64IMAC ISA) `sparc64-unknown-linux-gnu` | ✓ | SPARC Linux (kernel 4.4+, glibc 2.23) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index bb28e3abbf3..25c929a1dba 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -196,7 +196,7 @@ to enable. ### Document keywords -This is for Rust compiler internal use only. +This is for internal use in the std library. Rust keywords are documented in the standard library (look for `match` for example). @@ -211,6 +211,23 @@ To do so, the `#[doc(keyword = "...")]` attribute is used. Example: mod empty_mod {} ``` +### Document builtin attributes + +This is for internal use in the std library. + +Rust builtin attributes are documented in the standard library (look for `repr` for example). + +To do so, the `#[doc(attribute = "...")]` attribute is used. Example: + +```rust +#![feature(rustdoc_internals)] +#![allow(internal_features)] + +/// Some documentation about the attribute. +#[doc(attribute = "repr")] +mod empty_mod {} +``` + ### Use the Rust logo as the crate logo This is for official Rust project use only. diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 5d36ffc2d3a..2985971a053 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -12,20 +12,20 @@ path = "lib.rs" arrayvec = { version = "0.7", default-features = false } askama = { version = "0.14", default-features = false, features = ["alloc", "config", "derive"] } base64 = "0.21.7" -indexmap = "2" -itertools = "0.12" +indexmap.workspace = true +itertools.workspace = true minifier = { version = "0.3.5", default-features = false } pulldown-cmark-escape = { version = "0.11.0", features = ["simd"] } regex = "1" rustdoc-json-types = { path = "../rustdoc-json-types" } serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +serde_json.workspace = true smallvec = "1.8.1" stringdex = { version = "0.0.1-alpha4" } -tempfile = "3" +tempfile.workspace = true threadpool = "1.8.1" -tracing = "0.1" tracing-tree = "0.3.0" +tracing.workspace = true unicode-segmentation = "1.9" # tidy-alphabetical-end diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 0d98c64bbde..8461e15c6c3 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -572,30 +572,30 @@ pub(crate) fn build_impl( super::build_deref_target_impls(cx, &trait_items, ret); } - // Return if the trait itself or any types of the generic parameters are doc(hidden). - let mut stack: Vec<&Type> = vec![&for_]; + if !document_hidden { + // Return if the trait itself or any types of the generic parameters are doc(hidden). + let mut stack: Vec<&Type> = vec![&for_]; - if let Some(did) = trait_.as_ref().map(|t| t.def_id()) - && !document_hidden - && tcx.is_doc_hidden(did) - { - return; - } - - if let Some(generics) = trait_.as_ref().and_then(|t| t.generics()) { - stack.extend(generics); - } - - while let Some(ty) = stack.pop() { - if let Some(did) = ty.def_id(&cx.cache) - && !document_hidden + if let Some(did) = trait_.as_ref().map(|t| t.def_id()) && tcx.is_doc_hidden(did) { return; } - if let Some(generics) = ty.generics() { + + if let Some(generics) = trait_.as_ref().and_then(|t| t.generics()) { stack.extend(generics); } + + while let Some(ty) = stack.pop() { + if let Some(did) = ty.def_id(&cx.cache) + && tcx.is_doc_hidden(did) + { + return; + } + if let Some(generics) = ty.generics() { + stack.extend(generics); + } + } } if let Some(did) = trait_.as_ref().map(|t| t.def_id()) { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 92bd4a498ca..fcff15650ce 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -226,15 +226,28 @@ impl ExternalCrate { } pub(crate) fn keywords(&self, tcx: TyCtxt<'_>) -> impl Iterator<Item = (DefId, Symbol)> { - fn as_keyword(did: DefId, tcx: TyCtxt<'_>) -> Option<(DefId, Symbol)> { + self.retrieve_keywords_or_documented_attributes(tcx, sym::keyword) + } + pub(crate) fn documented_attributes( + &self, + tcx: TyCtxt<'_>, + ) -> impl Iterator<Item = (DefId, Symbol)> { + self.retrieve_keywords_or_documented_attributes(tcx, sym::attribute) + } + + fn retrieve_keywords_or_documented_attributes( + &self, + tcx: TyCtxt<'_>, + name: Symbol, + ) -> impl Iterator<Item = (DefId, Symbol)> { + let as_target = move |did: DefId, tcx: TyCtxt<'_>| -> Option<(DefId, Symbol)> { tcx.get_attrs(did, sym::doc) .flat_map(|attr| attr.meta_item_list().unwrap_or_default()) - .filter(|meta| meta.has_name(sym::keyword)) + .filter(|meta| meta.has_name(name)) .find_map(|meta| meta.value_str()) .map(|value| (did, value)) - } - - self.mapped_root_modules(tcx, as_keyword) + }; + self.mapped_root_modules(tcx, as_target) } pub(crate) fn primitives( @@ -592,6 +605,20 @@ impl Item { pub(crate) fn is_keyword(&self) -> bool { self.type_() == ItemType::Keyword } + pub(crate) fn is_attribute(&self) -> bool { + self.type_() == ItemType::Attribute + } + /// Returns `true` if the item kind is one of the following: + /// + /// * `ItemType::Primitive` + /// * `ItemType::Keyword` + /// * `ItemType::Attribute` + /// + /// They are considered fake because they only exist thanks to their + /// `#[doc(primitive|keyword|attribute)]` attribute. + pub(crate) fn is_fake_item(&self) -> bool { + matches!(self.type_(), ItemType::Primitive | ItemType::Keyword | ItemType::Attribute) + } pub(crate) fn is_stripped(&self) -> bool { match self.kind { StrippedItem(..) => true, @@ -735,7 +762,9 @@ impl Item { // Primitives and Keywords are written in the source code as private modules. // The modules need to be private so that nobody actually uses them, but the // keywords and primitives that they are documenting are public. - ItemKind::KeywordItem | ItemKind::PrimitiveItem(_) => return Some(Visibility::Public), + ItemKind::KeywordItem | ItemKind::PrimitiveItem(_) | ItemKind::AttributeItem => { + return Some(Visibility::Public); + } // Variant fields inherit their enum's visibility. StructFieldItem(..) if is_field_vis_inherited(tcx, def_id) => { return None; @@ -942,7 +971,12 @@ pub(crate) enum ItemKind { AssocTypeItem(Box<TypeAlias>, Vec<GenericBound>), /// An item that has been stripped by a rustdoc pass StrippedItem(Box<ItemKind>), + /// This item represents a module with a `#[doc(keyword = "...")]` attribute which is used + /// to generate documentation for Rust keywords. KeywordItem, + /// This item represents a module with a `#[doc(attribute = "...")]` attribute which is used + /// to generate documentation for Rust builtin attributes. + AttributeItem, } impl ItemKind { @@ -983,7 +1017,8 @@ impl ItemKind { | RequiredAssocTypeItem(..) | AssocTypeItem(..) | StrippedItem(_) - | KeywordItem => [].iter(), + | KeywordItem + | AttributeItem => [].iter(), } } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 813fdee57e1..6fc1e43c724 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -60,6 +60,7 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate { let local_crate = ExternalCrate { crate_num: LOCAL_CRATE }; let primitives = local_crate.primitives(cx.tcx); let keywords = local_crate.keywords(cx.tcx); + let documented_attributes = local_crate.documented_attributes(cx.tcx); { let ItemKind::ModuleItem(m) = &mut module.inner.kind else { unreachable!() }; m.items.extend(primitives.map(|(def_id, prim)| { @@ -73,6 +74,9 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate { m.items.extend(keywords.map(|(def_id, kw)| { Item::from_def_id_and_parts(def_id, Some(kw), ItemKind::KeywordItem, cx) })); + m.items.extend(documented_attributes.into_iter().map(|(def_id, kw)| { + Item::from_def_id_and_parts(def_id, Some(kw), ItemKind::AttributeItem, cx) + })); } Crate { module, external_traits: Box::new(mem::take(&mut cx.external_traits)) } diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index c03d16ad081..ee5f260615d 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -96,7 +96,8 @@ pub(crate) trait DocFolder: Sized { | ImplAssocConstItem(..) | RequiredAssocTypeItem(..) | AssocTypeItem(..) - | KeywordItem => kind, + | KeywordItem + | AttributeItem => kind, } } diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index cb6837dd614..29b4c4caaf8 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -372,7 +372,8 @@ impl DocFolder for CacheBuilder<'_, '_> { | clean::RequiredAssocTypeItem(..) | clean::AssocTypeItem(..) | clean::StrippedItem(..) - | clean::KeywordItem => { + | clean::KeywordItem + | clean::AttributeItem => { // FIXME: Do these need handling? // The person writing this comment doesn't know. // So would rather leave them to an expert, diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index 142a9d7d8af..e94ef517309 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -57,6 +57,7 @@ pub(crate) enum ItemType { TraitAlias = 25, // This number is reserved for use in JavaScript // Generic = 26, + Attribute = 27, } impl Serialize for ItemType { @@ -148,6 +149,7 @@ impl<'a> From<&'a clean::Item> for ItemType { clean::RequiredAssocTypeItem(..) | clean::AssocTypeItem(..) => ItemType::AssocType, clean::ForeignTypeItem => ItemType::ForeignType, clean::KeywordItem => ItemType::Keyword, + clean::AttributeItem => ItemType::Attribute, clean::TraitAliasItem(..) => ItemType::TraitAlias, clean::ProcMacroItem(mac) => match mac.kind { MacroKind::Bang => ItemType::Macro, @@ -236,6 +238,7 @@ impl ItemType { ItemType::ProcAttribute => "attr", ItemType::ProcDerive => "derive", ItemType::TraitAlias => "traitalias", + ItemType::Attribute => "attribute", } } pub(crate) fn is_method(&self) -> bool { diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index faaecaf0cbb..5f92ab2fada 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -218,7 +218,7 @@ impl<'tcx> Context<'tcx> { } else { it.name.as_ref().unwrap().as_str() }; - if !it.is_primitive() && !it.is_keyword() { + if !it.is_fake_item() { if !is_module { title.push_str(" in "); } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 673947ad308..6db90c9bf2a 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2535,6 +2535,7 @@ pub(crate) enum ItemSection { AssociatedConstants, ForeignTypes, Keywords, + Attributes, AttributeMacros, DeriveMacros, TraitAliases, @@ -2567,6 +2568,7 @@ impl ItemSection { AssociatedConstants, ForeignTypes, Keywords, + Attributes, AttributeMacros, DeriveMacros, TraitAliases, @@ -2596,6 +2598,7 @@ impl ItemSection { Self::AssociatedConstants => "associated-consts", Self::ForeignTypes => "foreign-types", Self::Keywords => "keywords", + Self::Attributes => "attributes", Self::AttributeMacros => "attributes", Self::DeriveMacros => "derives", Self::TraitAliases => "trait-aliases", @@ -2625,6 +2628,7 @@ impl ItemSection { Self::AssociatedConstants => "Associated Constants", Self::ForeignTypes => "Foreign Types", Self::Keywords => "Keywords", + Self::Attributes => "Attributes", Self::AttributeMacros => "Attribute Macros", Self::DeriveMacros => "Derive Macros", Self::TraitAliases => "Trait Aliases", @@ -2655,6 +2659,7 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection { ItemType::AssocConst => ItemSection::AssociatedConstants, ItemType::ForeignType => ItemSection::ForeignTypes, ItemType::Keyword => ItemSection::Keywords, + ItemType::Attribute => ItemSection::Attributes, ItemType::ProcAttribute => ItemSection::AttributeMacros, ItemType::ProcDerive => ItemSection::DeriveMacros, ItemType::TraitAlias => ItemSection::TraitAliases, diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index b86a2c94697..afa438f2596 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -173,6 +173,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item) -> impl fmt::Disp clean::ConstantItem(..) => "Constant ", clean::ForeignTypeItem => "Foreign Type ", clean::KeywordItem => "Keyword ", + clean::AttributeItem => "Attribute ", clean::TraitAliasItem(..) => "Trait Alias ", _ => { // We don't generate pages for any other type. @@ -193,7 +194,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item) -> impl fmt::Disp let src_href = if cx.info.include_sources && !item.is_primitive() { cx.src_href(item) } else { None }; - let path_components = if item.is_primitive() || item.is_keyword() { + let path_components = if item.is_fake_item() { vec![] } else { let cur = &cx.current; @@ -252,7 +253,9 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item) -> impl fmt::Disp clean::ForeignTypeItem => { write!(buf, "{}", item_foreign_type(cx, item)) } - clean::KeywordItem => write!(buf, "{}", item_keyword(cx, item)), + clean::KeywordItem | clean::AttributeItem => { + write!(buf, "{}", item_keyword_or_attribute(cx, item)) + } clean::TraitAliasItem(ta) => { write!(buf, "{}", item_trait_alias(cx, item, ta)) } @@ -2151,7 +2154,7 @@ fn item_foreign_type(cx: &Context<'_>, it: &clean::Item) -> impl fmt::Display { }) } -fn item_keyword(cx: &Context<'_>, it: &clean::Item) -> impl fmt::Display { +fn item_keyword_or_attribute(cx: &Context<'_>, it: &clean::Item) -> impl fmt::Display { document(cx, it, None, HeadingOffset::H2) } diff --git a/src/librustdoc/html/static/css/noscript.css b/src/librustdoc/html/static/css/noscript.css index a3c6bf98161..5c02e2eb26a 100644 --- a/src/librustdoc/html/static/css/noscript.css +++ b/src/librustdoc/html/static/css/noscript.css @@ -75,6 +75,7 @@ nav.sub { --function-link-color: #ad7c37; --macro-link-color: #068000; --keyword-link-color: #3873ad; + --attribute-link-color: #3873ad; --mod-link-color: #3873ad; --link-color: #3873ad; --sidebar-link-color: #356da4; @@ -180,6 +181,7 @@ nav.sub { --function-link-color: #2bab63; --macro-link-color: #09bd00; --keyword-link-color: #d2991d; + --attribute-link-color: #d2991d; --mod-link-color: #d2991d; --link-color: #d2991d; --sidebar-link-color: #fdbf35; diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 86f1a42bc01..09d289d570c 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -400,6 +400,10 @@ span.keyword, a.keyword { color: var(--keyword-link-color); } +span.attribute, a.attribute { + color: var(--attribute-link-color); +} + a { color: var(--link-color); text-decoration: none; @@ -3190,6 +3194,7 @@ by default. --function-link-color: #ad7c37; --macro-link-color: #068000; --keyword-link-color: #3873ad; + --attribute-link-color: #3873ad; --mod-link-color: #3873ad; --link-color: #3873ad; --sidebar-link-color: #356da4; @@ -3294,6 +3299,7 @@ by default. --function-link-color: #2bab63; --macro-link-color: #09bd00; --keyword-link-color: #d2991d; + --attribute-link-color: #d2991d; --mod-link-color: #d2991d; --link-color: #d2991d; --sidebar-link-color: #fdbf35; @@ -3407,6 +3413,7 @@ Original by Dempfi (https://github.com/dempfi/ayu) --function-link-color: #fdd687; --macro-link-color: #a37acc; --keyword-link-color: #39afd7; + --attribute-link-color: #39afd7; --mod-link-color: #39afd7; --link-color: #39afd7; --sidebar-link-color: #53b1db; diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 4fcba5f120b..75febd6f737 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -790,6 +790,7 @@ function preLoadCss(cssUrl) { //block("associatedconstant", "associated-consts", "Associated Constants"); block("foreigntype", "foreign-types", "Foreign Types"); block("keyword", "keywords", "Keywords"); + block("attribute", "attributes", "Attributes"); block("attr", "attributes", "Attribute Macros"); block("derive", "derives", "Derive Macros"); block("traitalias", "trait-aliases", "Trait Aliases"); diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 3fb4db3a89c..b003bcc7bf9 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -119,6 +119,7 @@ const itemTypes = [ "derive", "traitalias", // 25 "generic", + "attribute", ]; // used for special search precedence @@ -2058,7 +2059,7 @@ class DocSearch { displayPath = item.modulePath + "::"; href = this.rootPath + item.modulePath.replace(/::/g, "/") + "/index.html#reexport." + name; - } else if (type === "primitive" || type === "keyword") { + } else if (type === "primitive" || type === "keyword" || type === "attribute") { displayPath = ""; exactPath = ""; href = this.rootPath + path.replace(/::/g, "/") + @@ -4560,6 +4561,8 @@ const longItemTypes = [ "attribute macro", "derive macro", "trait alias", + "", + "attribute", ]; // @ts-expect-error let currentResults; diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 5fab8ad2a4b..f0520716228 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -52,7 +52,7 @@ impl JsonRenderer<'_> { let clean::ItemInner { name, item_id, .. } = *item.inner; let id = self.id_from_item(item); let inner = match item.kind { - clean::KeywordItem => return None, + clean::KeywordItem | clean::AttributeItem => return None, clean::StrippedItem(ref inner) => { match &**inner { // We document stripped modules as with `Module::is_stripped` set to @@ -85,7 +85,7 @@ impl JsonRenderer<'_> { fn ids(&self, items: &[clean::Item]) -> Vec<Id> { items .iter() - .filter(|i| !i.is_stripped() && !i.is_keyword()) + .filter(|i| !i.is_stripped() && !i.is_keyword() && !i.is_attribute()) .map(|i| self.id_from_item(i)) .collect() } @@ -93,7 +93,10 @@ impl JsonRenderer<'_> { fn ids_keeping_stripped(&self, items: &[clean::Item]) -> Vec<Option<Id>> { items .iter() - .map(|i| (!i.is_stripped() && !i.is_keyword()).then(|| self.id_from_item(i))) + .map(|i| { + (!i.is_stripped() && !i.is_keyword() && !i.is_attribute()) + .then(|| self.id_from_item(i)) + }) .collect() } } @@ -332,8 +335,8 @@ fn from_clean_item(item: &clean::Item, renderer: &JsonRenderer<'_>) -> ItemEnum bounds: b.into_json(renderer), type_: Some(t.item_type.as_ref().unwrap_or(&t.type_).into_json(renderer)), }, - // `convert_item` early returns `None` for stripped items and keywords. - KeywordItem => unreachable!(), + // `convert_item` early returns `None` for stripped items, keywords and attributes. + KeywordItem | AttributeItem => unreachable!(), StrippedItem(inner) => { match inner.as_ref() { ModuleItem(m) => ItemEnum::Module(Module { @@ -887,6 +890,7 @@ impl FromClean<ItemType> for ItemKind { AssocType => ItemKind::AssocType, ForeignType => ItemKind::ExternType, Keyword => ItemKind::Keyword, + Attribute => ItemKind::Attribute, TraitAlias => ItemKind::TraitAlias, ProcAttribute => ItemKind::ProcAttribute, ProcDerive => ItemKind::ProcDerive, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index e2682045ab4..f62eba4b3c1 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -1,4 +1,5 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(round_char_boundary))] #![doc( html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/" @@ -13,7 +14,6 @@ #![feature(if_let_guard)] #![feature(iter_advance_by)] #![feature(iter_intersperse)] -#![feature(round_char_boundary)] #![feature(rustc_private)] #![feature(test)] #![warn(rustc::internal)] @@ -760,7 +760,9 @@ fn run_renderer< tcx.dcx().struct_fatal(format!("couldn't generate documentation: {}", e.error)); let file = e.file.display().to_string(); if !file.is_empty() { - msg.note(format!("failed to create or modify \"{file}\"")); + msg.note(format!("failed to create or modify {e}")); + } else { + msg.note(format!("failed to create or modify file: {e}")); } msg.emit(); } diff --git a/src/librustdoc/passes/check_doc_test_visibility.rs b/src/librustdoc/passes/check_doc_test_visibility.rs index 8028afea363..e0ea760cf3b 100644 --- a/src/librustdoc/passes/check_doc_test_visibility.rs +++ b/src/librustdoc/passes/check_doc_test_visibility.rs @@ -67,6 +67,7 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) - | clean::ImportItem(_) | clean::PrimitiveItem(_) | clean::KeywordItem + | clean::AttributeItem | clean::ModuleItem(_) | clean::TraitAliasItem(_) | clean::ForeignFunctionItem(..) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index bad51d7f5b2..719b7c6ab89 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -19,7 +19,7 @@ use rustc_hir::{Mutability, Safety}; use rustc_middle::ty::{Ty, TyCtxt}; use rustc_middle::{bug, span_bug, ty}; use rustc_resolve::rustdoc::{ - MalformedGenerics, has_primitive_or_keyword_docs, prepare_to_doc_link_resolution, + MalformedGenerics, has_primitive_or_keyword_or_attribute_docs, prepare_to_doc_link_resolution, source_span_for_markdown_range, strip_generics_from_path, }; use rustc_session::config::CrateType; @@ -1073,7 +1073,7 @@ impl LinkCollector<'_, '_> { && let Some(def_id) = item.item_id.as_def_id() && let Some(def_id) = def_id.as_local() && !self.cx.tcx.effective_visibilities(()).is_exported(def_id) - && !has_primitive_or_keyword_docs(&item.attrs.other_attrs) + && !has_primitive_or_keyword_or_attribute_docs(&item.attrs.other_attrs) { // Skip link resolution for non-exported items. return; diff --git a/src/librustdoc/passes/propagate_stability.rs b/src/librustdoc/passes/propagate_stability.rs index 14ec58702e3..5139ca301dd 100644 --- a/src/librustdoc/passes/propagate_stability.rs +++ b/src/librustdoc/passes/propagate_stability.rs @@ -106,7 +106,8 @@ impl DocFolder for StabilityPropagator<'_, '_> { | ItemKind::RequiredAssocTypeItem(..) | ItemKind::AssocTypeItem(..) | ItemKind::PrimitiveItem(..) - | ItemKind::KeywordItem => own_stability, + | ItemKind::KeywordItem + | ItemKind::AttributeItem => own_stability, ItemKind::StrippedItem(..) => unreachable!(), } diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index eedbbca0f8d..99d22526f85 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -133,6 +133,8 @@ impl DocFolder for Stripper<'_, '_> { // Keywords are never stripped clean::KeywordItem => {} + // Attributes are never stripped + clean::AttributeItem => {} } let fastreturn = match i.kind { diff --git a/src/librustdoc/visit.rs b/src/librustdoc/visit.rs index b8b619514aa..4d31409afe8 100644 --- a/src/librustdoc/visit.rs +++ b/src/librustdoc/visit.rs @@ -49,7 +49,8 @@ pub(crate) trait DocVisitor<'a>: Sized { | ImplAssocConstItem(..) | RequiredAssocTypeItem(..) | AssocTypeItem(..) - | KeywordItem => {} + | KeywordItem + | AttributeItem => {} } } diff --git a/src/llvm-project b/src/llvm-project -Subproject 9a1f898064f52269bc94675dcbd620b46d45d17 +Subproject 19f0a49c5c3f4ba88b5e7ac620b9a0d8574c09c diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 40f89009a43..658d3791d25 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -37,8 +37,8 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc // will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line // are deliberately not in a doc comment, because they need not be in public docs.) // -// Latest feature: Add Attribute::MacroUse -pub const FORMAT_VERSION: u32 = 55; +// Latest feature: Add `ItemKind::Attribute`. +pub const FORMAT_VERSION: u32 = 56; /// The root of the emitted JSON blob. /// @@ -552,6 +552,11 @@ pub enum ItemKind { /// [`Item`]s of this kind only come from the come library and exist solely /// to carry documentation for the respective keywords. Keyword, + /// An attribute declaration. + /// + /// [`Item`]s of this kind only come from the core library and exist solely + /// to carry documentation for the respective builtin attributes. + Attribute, } /// Specific fields of an item. diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index efa99f181b3..05d5f21c12c 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] toml = "0.7" serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +serde_json.workspace = true anyhow = "1.0.32" flate2 = "1.0.26" xz2 = "0.1.7" diff --git a/src/tools/cargo b/src/tools/cargo -Subproject 623d536836b4cde09ce38609232a024d5b25da8 +Subproject a6c58d43051d01d83f55a3e61ef5f5b2b0dd6bd diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index d468993e744..c8594cf35e2 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -7,7 +7,7 @@ #![feature(iter_intersperse)] #![feature(iter_partition_in_place)] #![feature(never_type)] -#![feature(round_char_boundary)] +#![cfg_attr(bootstrap, feature(round_char_boundary))] #![feature(rustc_private)] #![feature(stmt_expr_attributes)] #![feature(unwrap_infallible)] diff --git a/src/tools/clippy/tests/ui/char_indices_as_byte_indices.fixed b/src/tools/clippy/tests/ui/char_indices_as_byte_indices.fixed index 04c8f6782c5..375a101c2e3 100644 --- a/src/tools/clippy/tests/ui/char_indices_as_byte_indices.fixed +++ b/src/tools/clippy/tests/ui/char_indices_as_byte_indices.fixed @@ -1,4 +1,3 @@ -#![feature(round_char_boundary)] #![warn(clippy::char_indices_as_byte_indices)] trait StrExt { diff --git a/src/tools/clippy/tests/ui/char_indices_as_byte_indices.rs b/src/tools/clippy/tests/ui/char_indices_as_byte_indices.rs index 773a4fc65f1..eebc39962a2 100644 --- a/src/tools/clippy/tests/ui/char_indices_as_byte_indices.rs +++ b/src/tools/clippy/tests/ui/char_indices_as_byte_indices.rs @@ -1,4 +1,3 @@ -#![feature(round_char_boundary)] #![warn(clippy::char_indices_as_byte_indices)] trait StrExt { diff --git a/src/tools/clippy/tests/ui/char_indices_as_byte_indices.stderr b/src/tools/clippy/tests/ui/char_indices_as_byte_indices.stderr index e2b4c1db78c..fae81fd772d 100644 --- a/src/tools/clippy/tests/ui/char_indices_as_byte_indices.stderr +++ b/src/tools/clippy/tests/ui/char_indices_as_byte_indices.stderr @@ -1,12 +1,12 @@ error: indexing into a string with a character position where a byte index is expected - --> tests/ui/char_indices_as_byte_indices.rs:13:24 + --> tests/ui/char_indices_as_byte_indices.rs:12:24 | LL | let _ = prim[..idx]; | ^^^ | = note: a character can take up more than one byte, so they are not interchangeable note: position comes from the enumerate iterator - --> tests/ui/char_indices_as_byte_indices.rs:12:10 + --> tests/ui/char_indices_as_byte_indices.rs:11:10 | LL | for (idx, _) in prim.chars().enumerate() { | ^^^ ^^^^^^^^^^^ @@ -19,14 +19,14 @@ LL + for (idx, _) in prim.char_indices() { | error: passing a character position to a method that expects a byte index - --> tests/ui/char_indices_as_byte_indices.rs:15:23 + --> tests/ui/char_indices_as_byte_indices.rs:14:23 | LL | prim.split_at(idx); | ^^^ | = note: a character can take up more than one byte, so they are not interchangeable note: position comes from the enumerate iterator - --> tests/ui/char_indices_as_byte_indices.rs:12:10 + --> tests/ui/char_indices_as_byte_indices.rs:11:10 | LL | for (idx, _) in prim.chars().enumerate() { | ^^^ ^^^^^^^^^^^ @@ -37,14 +37,14 @@ LL + for (idx, _) in prim.char_indices() { | error: passing a character position to a method that expects a byte index - --> tests/ui/char_indices_as_byte_indices.rs:19:49 + --> tests/ui/char_indices_as_byte_indices.rs:18:49 | LL | let _ = prim[..prim.floor_char_boundary(idx)]; | ^^^ | = note: a character can take up more than one byte, so they are not interchangeable note: position comes from the enumerate iterator - --> tests/ui/char_indices_as_byte_indices.rs:12:10 + --> tests/ui/char_indices_as_byte_indices.rs:11:10 | LL | for (idx, _) in prim.chars().enumerate() { | ^^^ ^^^^^^^^^^^ @@ -55,14 +55,14 @@ LL + for (idx, _) in prim.char_indices() { | error: indexing into a string with a character position where a byte index is expected - --> tests/ui/char_indices_as_byte_indices.rs:29:24 + --> tests/ui/char_indices_as_byte_indices.rs:28:24 | LL | let _ = prim[..c.0]; | ^^^ | = note: a character can take up more than one byte, so they are not interchangeable note: position comes from the enumerate iterator - --> tests/ui/char_indices_as_byte_indices.rs:28:9 + --> tests/ui/char_indices_as_byte_indices.rs:27:9 | LL | for c in prim.chars().enumerate() { | ^ ^^^^^^^^^^^ @@ -73,14 +73,14 @@ LL + for c in prim.char_indices() { | error: passing a character position to a method that expects a byte index - --> tests/ui/char_indices_as_byte_indices.rs:31:23 + --> tests/ui/char_indices_as_byte_indices.rs:30:23 | LL | prim.split_at(c.0); | ^^^ | = note: a character can take up more than one byte, so they are not interchangeable note: position comes from the enumerate iterator - --> tests/ui/char_indices_as_byte_indices.rs:28:9 + --> tests/ui/char_indices_as_byte_indices.rs:27:9 | LL | for c in prim.chars().enumerate() { | ^ ^^^^^^^^^^^ @@ -91,14 +91,14 @@ LL + for c in prim.char_indices() { | error: indexing into a string with a character position where a byte index is expected - --> tests/ui/char_indices_as_byte_indices.rs:36:26 + --> tests/ui/char_indices_as_byte_indices.rs:35:26 | LL | let _ = string[..idx]; | ^^^ | = note: a character can take up more than one byte, so they are not interchangeable note: position comes from the enumerate iterator - --> tests/ui/char_indices_as_byte_indices.rs:35:10 + --> tests/ui/char_indices_as_byte_indices.rs:34:10 | LL | for (idx, _) in string.chars().enumerate() { | ^^^ ^^^^^^^^^^^ @@ -109,14 +109,14 @@ LL + for (idx, _) in string.char_indices() { | error: passing a character position to a method that expects a byte index - --> tests/ui/char_indices_as_byte_indices.rs:38:25 + --> tests/ui/char_indices_as_byte_indices.rs:37:25 | LL | string.split_at(idx); | ^^^ | = note: a character can take up more than one byte, so they are not interchangeable note: position comes from the enumerate iterator - --> tests/ui/char_indices_as_byte_indices.rs:35:10 + --> tests/ui/char_indices_as_byte_indices.rs:34:10 | LL | for (idx, _) in string.chars().enumerate() { | ^^^ ^^^^^^^^^^^ diff --git a/src/tools/collect-license-metadata/Cargo.toml b/src/tools/collect-license-metadata/Cargo.toml index edf9e5c5393..7f2e57ced05 100644 --- a/src/tools/collect-license-metadata/Cargo.toml +++ b/src/tools/collect-license-metadata/Cargo.toml @@ -8,5 +8,5 @@ license = "MIT OR Apache-2.0" [dependencies] anyhow = "1.0.65" serde = { version = "1.0.147", features = ["derive"] } -serde_json = "1.0.85" +serde_json.workspace = true spdx-rs = "0.5.1" diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index cdada5a2230..fb71275b03c 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -20,22 +20,22 @@ diff = "0.1.10" getopts = "0.2" glob = "0.3.0" home = "0.5.5" -indexmap = "2.0.0" +indexmap.workspace = true miropt-test-tools = { path = "../miropt-test-tools" } rayon = "1.10.0" regex = "1.0" rustfix = "0.8.1" semver = { version = "1.0.23", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -tracing = "0.1" +serde_json.workspace = true tracing-subscriber = { version = "0.3.3", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec"] } +tracing.workspace = true unified-diff = "0.2.1" walkdir = "2" # tidy-alphabetical-end [target.'cfg(unix)'.dependencies] -libc = "0.2" +libc.workspace = true [target.'cfg(windows)'.dependencies] miow = "0.6" diff --git a/src/tools/compiletest/src/bin/main.rs b/src/tools/compiletest/src/bin/main.rs index 1f777e71cf9..8fac6ccdc58 100644 --- a/src/tools/compiletest/src/bin/main.rs +++ b/src/tools/compiletest/src/bin/main.rs @@ -2,7 +2,7 @@ use std::env; use std::io::IsTerminal; use std::sync::Arc; -use compiletest::{early_config_check, log_config, parse_config, run_tests}; +use compiletest::{early_config_check, parse_config, run_tests}; fn main() { tracing_subscriber::fmt::init(); @@ -19,6 +19,5 @@ fn main() { early_config_check(&config); - log_config(&config); run_tests(config); } diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 7fc80c1edb1..b72c0b7ed20 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -8,7 +8,7 @@ use camino::{Utf8Path, Utf8PathBuf}; use semver::Version; use serde::de::{Deserialize, Deserializer, Error as _}; -use crate::executor::{ColorConfig, OutputFormat}; +use crate::executor::ColorConfig; use crate::fatal; use crate::util::{Utf8PathBufExt, add_dylib_path, string_enum}; @@ -565,13 +565,6 @@ pub struct Config { /// FIXME: this is *way* too coarse; the user can't select *which* info to verbosely dump. pub verbose: bool, - /// (Useless) Adjust libtest output format. - /// - /// FIXME: the hand-rolled executor does not support non-JSON output, because `compiletest` need - /// to package test outcome as `libtest`-esque JSON that `bootstrap` can intercept *anyway*. - /// However, now that we don't use the `libtest` executor, this is useless. - pub format: OutputFormat, - /// Whether to use colors in test output. /// /// Note: the exact control mechanism is delegated to [`colored`]. @@ -768,7 +761,6 @@ impl Config { adb_device_status: Default::default(), lldb_python_dir: Default::default(), verbose: Default::default(), - format: Default::default(), color: Default::default(), remote_test_client: Default::default(), compare_mode: Default::default(), diff --git a/src/tools/compiletest/src/executor.rs b/src/tools/compiletest/src/executor.rs index df64f12784f..fdd7155c21f 100644 --- a/src/tools/compiletest/src/executor.rs +++ b/src/tools/compiletest/src/executor.rs @@ -1,5 +1,9 @@ //! This module contains a reimplementation of the subset of libtest //! functionality needed by compiletest. +//! +//! FIXME(Zalathar): Much of this code was originally designed to mimic libtest +//! as closely as possible, for ease of migration. Now that libtest is no longer +//! used, we can potentially redesign things to be a better fit for compiletest. use std::borrow::Cow; use std::collections::HashMap; @@ -207,7 +211,7 @@ impl TestOutcome { /// /// Adapted from `filter_tests` in libtest. /// -/// FIXME(#139660): After the libtest dependency is removed, redesign the whole filtering system to +/// FIXME(#139660): Now that libtest has been removed, redesign the whole filtering system to /// do a better job of understanding and filtering _paths_, instead of being tied to libtest's /// substring/exact matching behaviour. fn filter_tests(opts: &Config, tests: Vec<CollectedTest>) -> Vec<CollectedTest> { @@ -249,7 +253,7 @@ fn get_concurrency() -> usize { } } -/// Information needed to create a `test::TestDescAndFn`. +/// Information that was historically needed to create a libtest `TestDescAndFn`. pub(crate) struct CollectedTest { pub(crate) desc: CollectedTestDesc, pub(crate) config: Arc<Config>, @@ -257,7 +261,7 @@ pub(crate) struct CollectedTest { pub(crate) revision: Option<String>, } -/// Information needed to create a `test::TestDesc`. +/// Information that was historically needed to create a libtest `TestDesc`. pub(crate) struct CollectedTestDesc { pub(crate) name: String, pub(crate) ignore: bool, @@ -274,18 +278,6 @@ pub enum ColorConfig { NeverColor, } -/// Format of the test results output. -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] -pub enum OutputFormat { - /// Verbose output - Pretty, - /// Quiet output - #[default] - Terse, - /// JSON output - Json, -} - /// Whether test is expected to panic or not. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub(crate) enum ShouldPanic { diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 469dd68207e..8737fec80bb 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -9,7 +9,6 @@ mod tests; pub mod common; -pub mod compute_diff; mod debuggers; pub mod diagnostics; pub mod directives; @@ -43,8 +42,7 @@ use crate::common::{ expected_output_path, output_base_dir, output_relative_path, }; use crate::directives::DirectivesCache; -use crate::executor::{CollectedTest, ColorConfig, OutputFormat}; -use crate::util::logv; +use crate::executor::{CollectedTest, ColorConfig}; /// Creates the `Config` instance for this invocation of compiletest. /// @@ -137,9 +135,7 @@ pub fn parse_config(args: Vec<String>) -> Config { "overwrite stderr/stdout files instead of complaining about a mismatch", ) .optflag("", "fail-fast", "stop as soon as possible after any test fails") - .optflag("", "quiet", "print one character per test instead of one line") .optopt("", "color", "coloring: auto, always, never", "WHEN") - .optflag("", "json", "emit json output instead of plaintext output") .optopt("", "target", "the target to build for", "TARGET") .optopt("", "host", "the host to build for", "HOST") .optopt("", "cdb", "path to CDB to use for CDB debuginfo tests", "PATH") @@ -203,7 +199,6 @@ pub fn parse_config(args: Vec<String>) -> Config { "COMMAND", ) .reqopt("", "minicore-path", "path to minicore aux library", "PATH") - .optflag("N", "no-new-executor", "disables the new test executor, and uses libtest instead") .optopt( "", "debugger", @@ -436,12 +431,6 @@ pub fn parse_config(args: Vec<String>) -> Config { && !opt_str2(matches.opt_str("adb-test-dir")).is_empty(), lldb_python_dir: matches.opt_str("lldb-python-dir"), verbose: matches.opt_present("verbose"), - format: match (matches.opt_present("quiet"), matches.opt_present("json")) { - (true, true) => panic!("--quiet and --json are incompatible"), - (true, false) => OutputFormat::Terse, - (false, true) => OutputFormat::Json, - (false, false) => OutputFormat::Pretty, - }, only_modified: matches.opt_present("only-modified"), color, remote_test_client: matches.opt_str("remote-test-client").map(Utf8PathBuf::from), @@ -486,52 +475,6 @@ pub fn parse_config(args: Vec<String>) -> Config { } } -pub fn log_config(config: &Config) { - let c = config; - logv(c, "configuration:".to_string()); - logv(c, format!("compile_lib_path: {}", config.compile_lib_path)); - logv(c, format!("run_lib_path: {}", config.run_lib_path)); - logv(c, format!("rustc_path: {}", config.rustc_path)); - logv(c, format!("cargo_path: {:?}", config.cargo_path)); - logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path)); - - logv(c, format!("src_root: {}", config.src_root)); - logv(c, format!("src_test_suite_root: {}", config.src_test_suite_root)); - - logv(c, format!("build_root: {}", config.build_root)); - logv(c, format!("build_test_suite_root: {}", config.build_test_suite_root)); - - logv(c, format!("sysroot_base: {}", config.sysroot_base)); - - logv(c, format!("stage: {}", config.stage)); - logv(c, format!("stage_id: {}", config.stage_id)); - logv(c, format!("mode: {}", config.mode)); - logv(c, format!("run_ignored: {}", config.run_ignored)); - logv(c, format!("filters: {:?}", config.filters)); - logv(c, format!("skip: {:?}", config.skip)); - logv(c, format!("filter_exact: {}", config.filter_exact)); - logv( - c, - format!("force_pass_mode: {}", opt_str(&config.force_pass_mode.map(|m| format!("{}", m))),), - ); - logv(c, format!("runner: {}", opt_str(&config.runner))); - logv(c, format!("host-rustcflags: {:?}", config.host_rustcflags)); - logv(c, format!("target-rustcflags: {:?}", config.target_rustcflags)); - logv(c, format!("target: {}", config.target)); - logv(c, format!("host: {}", config.host)); - logv(c, format!("android-cross-path: {}", config.android_cross_path)); - logv(c, format!("adb_path: {}", config.adb_path)); - logv(c, format!("adb_test_dir: {}", config.adb_test_dir)); - logv(c, format!("adb_device_status: {}", config.adb_device_status)); - logv(c, format!("ar: {}", config.ar)); - logv(c, format!("target-linker: {:?}", config.target_linker)); - logv(c, format!("host-linker: {:?}", config.host_linker)); - logv(c, format!("verbose: {}", config.verbose)); - logv(c, format!("format: {:?}", config.format)); - logv(c, format!("minicore_path: {}", config.minicore_path)); - logv(c, "\n".to_string()); -} - pub fn opt_str(maybestr: &Option<String>) -> &str { match *maybestr { None => "(none)", @@ -548,6 +491,8 @@ pub fn opt_str2(maybestr: Option<String>) -> String { /// Called by `main` after the config has been parsed. pub fn run_tests(config: Arc<Config>) { + debug!(?config, "run_tests"); + // If we want to collect rustfix coverage information, // we first make sure that the coverage file does not exist. // It will be created later on. @@ -601,7 +546,7 @@ pub fn run_tests(config: Arc<Config>) { configs.push(config.clone()); }; - // Discover all of the tests in the test suite directory, and build a libtest + // Discover all of the tests in the test suite directory, and build a `CollectedTest` // structure for each test (or each revision of a multi-revision test). let mut tests = Vec::new(); for c in configs { @@ -613,50 +558,35 @@ pub fn run_tests(config: Arc<Config>) { // Delegate to the executor to filter and run the big list of test structures // created during test discovery. When the executor decides to run a test, // it will return control to the rest of compiletest by calling `runtest::run`. - // FIXME(Zalathar): Once we're confident that we won't need to revert the - // removal of the libtest-based executor, remove this Result and other - // remnants of the old executor. - let res: io::Result<bool> = Ok(executor::run_tests(&config, tests)); - - // Check the outcome reported by libtest. - match res { - Ok(true) => {} - Ok(false) => { - // We want to report that the tests failed, but we also want to give - // some indication of just what tests we were running. Especially on - // CI, where there can be cross-compiled tests for a lot of - // architectures, without this critical information it can be quite - // easy to miss which tests failed, and as such fail to reproduce - // the failure locally. - - let mut msg = String::from("Some tests failed in compiletest"); - write!(msg, " suite={}", config.suite).unwrap(); - - if let Some(compare_mode) = config.compare_mode.as_ref() { - write!(msg, " compare_mode={}", compare_mode).unwrap(); - } + let ok = executor::run_tests(&config, tests); + + // Check the outcome reported by the executor. + if !ok { + // We want to report that the tests failed, but we also want to give + // some indication of just what tests we were running. Especially on + // CI, where there can be cross-compiled tests for a lot of + // architectures, without this critical information it can be quite + // easy to miss which tests failed, and as such fail to reproduce + // the failure locally. + + let mut msg = String::from("Some tests failed in compiletest"); + write!(msg, " suite={}", config.suite).unwrap(); + + if let Some(compare_mode) = config.compare_mode.as_ref() { + write!(msg, " compare_mode={}", compare_mode).unwrap(); + } - if let Some(pass_mode) = config.force_pass_mode.as_ref() { - write!(msg, " pass_mode={}", pass_mode).unwrap(); - } + if let Some(pass_mode) = config.force_pass_mode.as_ref() { + write!(msg, " pass_mode={}", pass_mode).unwrap(); + } - write!(msg, " mode={}", config.mode).unwrap(); - write!(msg, " host={}", config.host).unwrap(); - write!(msg, " target={}", config.target).unwrap(); + write!(msg, " mode={}", config.mode).unwrap(); + write!(msg, " host={}", config.host).unwrap(); + write!(msg, " target={}", config.target).unwrap(); - println!("{msg}"); + println!("{msg}"); - std::process::exit(1); - } - Err(e) => { - // We don't know if tests passed or not, but if there was an error - // during testing we don't want to just succeed (we may not have - // tested something), so fail. - // - // This should realistically "never" happen, so don't try to make - // this a pretty error message. - panic!("I/O failure during tests: {:?}", e); - } + std::process::exit(1); } } @@ -691,7 +621,11 @@ impl TestCollector { /// /// This always inspects _all_ test files in the suite (e.g. all 17k+ ui tests), /// regardless of whether any filters/tests were specified on the command-line, -/// because filtering is handled later by libtest. +/// because filtering is handled later by code that was copied from libtest. +/// +/// FIXME(Zalathar): Now that we no longer rely on libtest, try to overhaul +/// test discovery to take into account the filters/tests specified on the +/// command-line, instead of having to enumerate everything. pub(crate) fn collect_and_make_tests(config: Arc<Config>) -> Vec<CollectedTest> { debug!("making tests from {}", config.src_test_suite_root); let common_inputs_stamp = common_inputs_stamp(&config); @@ -805,7 +739,7 @@ fn modified_tests(config: &Config, dir: &Utf8Path) -> Result<Vec<Utf8PathBuf>, S } /// Recursively scans a directory to find test files and create test structures -/// that will be handed over to libtest. +/// that will be handed over to the executor. fn collect_tests_from_dir( cx: &TestCollectorCx, dir: &Utf8Path, @@ -871,7 +805,7 @@ fn collect_tests_from_dir( if is_test(file_name) && (!cx.config.only_modified || cx.modified_tests.contains(&file_path)) { - // We found a test file, so create the corresponding libtest structures. + // We found a test file, so create the corresponding test structures. debug!(%file_path, "found test file"); // Record the stem of the test file, to check for overlaps later. @@ -915,7 +849,7 @@ pub fn is_test(file_name: &str) -> bool { } /// For a single test file, creates one or more test structures (one per revision) that can be -/// handed over to libtest to run, possibly in parallel. +/// handed over to the executor to run, possibly in parallel. fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &TestPaths) { // For run-make tests, each "test file" is actually a _directory_ containing an `rmake.rs`. But // for the purposes of directive parsing, we want to look at that recipe file, not the directory @@ -929,7 +863,7 @@ fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &Te // Scan the test file to discover its revisions, if any. let early_props = EarlyProps::from_file(&cx.config, &test_path); - // Normally we create one libtest structure per revision, with two exceptions: + // Normally we create one structure per revision, with two exceptions: // - If a test doesn't use revisions, create a dummy revision (None) so that // the test can still run. // - Incremental tests inherently can't run their revisions in parallel, so @@ -944,12 +878,12 @@ fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &Te // For each revision (or the sole dummy revision), create and append a // `CollectedTest` that can be handed over to the test executor. collector.tests.extend(revisions.into_iter().map(|revision| { - // Create a test name and description to hand over to libtest. + // Create a test name and description to hand over to the executor. let src_file = fs::File::open(&test_path).expect("open test file to parse ignores"); let test_name = make_test_name(&cx.config, testpaths, revision); - // Create a libtest description for the test/revision. + // Create a description struct for the test/revision. // This is where `ignore-*`/`only-*`/`needs-*` directives are handled, - // because they need to set the libtest ignored flag. + // because they historically needed to set the libtest ignored flag. let mut desc = make_test_description( &cx.config, &cx.cache, @@ -961,10 +895,12 @@ fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &Te ); // If a test's inputs haven't changed since the last time it ran, - // mark it as ignored so that libtest will skip it. + // mark it as ignored so that the executor will skip it. if !cx.config.force_rerun && is_up_to_date(cx, testpaths, &early_props, revision) { desc.ignore = true; // Keep this in sync with the "up-to-date" message detected by bootstrap. + // FIXME(Zalathar): Now that we are no longer tied to libtest, we could + // find a less fragile way to communicate this status to bootstrap. desc.ignore_message = Some("up-to-date".into()); } @@ -1104,7 +1040,7 @@ impl Stamp { } } -/// Creates a name for this test/revision that can be handed over to libtest. +/// Creates a name for this test/revision that can be handed over to the executor. fn make_test_name(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> String { // Print the name of the file, relative to the sources root. let path = testpaths.file.strip_prefix(&config.src_root).unwrap(); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index c533293e791..867624cc8fa 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -7,7 +7,7 @@ use std::io::prelude::*; use std::io::{self, BufReader}; use std::process::{Child, Command, ExitStatus, Output, Stdio}; use std::sync::Arc; -use std::{env, iter, str}; +use std::{env, fmt, iter, str}; use build_helper::fs::remove_and_create_dir_all; use camino::{Utf8Path, Utf8PathBuf}; @@ -21,15 +21,13 @@ use crate::common::{ UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name, output_testname_unique, }; -use crate::compute_diff::{DiffLine, make_diff, write_diff, write_filtered_diff}; use crate::directives::TestProps; use crate::errors::{Error, ErrorKind, load_errors}; use crate::read2::{Truncated, read2_abbreviated}; -use crate::util::{Utf8PathBufExt, add_dylib_path, logv, static_regex}; +use crate::runtest::compute_diff::{DiffLine, make_diff, write_diff, write_filtered_diff}; +use crate::util::{Utf8PathBufExt, add_dylib_path, static_regex}; use crate::{ColorConfig, help, json, stamp_file_path, warning}; -mod debugger; - // Helper modules that implement test running logic for each test suite. // tidy-alphabetical-start mod assembly; @@ -48,6 +46,8 @@ mod rustdoc_json; mod ui; // tidy-alphabetical-end +mod compute_diff; +mod debugger; #[cfg(test)] mod tests; @@ -1459,7 +1459,7 @@ impl<'test> TestCx<'test> { ) -> ProcRes { let cmdline = { let cmdline = self.make_cmdline(&command, lib_path); - logv(self.config, format!("executing {}", cmdline)); + self.logv(format_args!("executing {cmdline}")); cmdline }; @@ -2006,6 +2006,18 @@ impl<'test> TestCx<'test> { output_base_name(self.config, self.testpaths, self.safe_revision()) } + /// Prints a message to (captured) stdout if `config.verbose` is true. + /// The message is also logged to `tracing::debug!` regardles of verbosity. + /// + /// Use `format_args!` as the argument to perform formatting if required. + fn logv(&self, message: impl fmt::Display) { + debug!("{message}"); + if self.config.verbose { + // Note: `./x test ... --verbose --no-capture` is needed to see this print. + println!("{message}"); + } + } + /// Prefix to print before error messages. Normally just `error`, but also /// includes the revision name for tests that use revisions. #[must_use] @@ -2222,7 +2234,7 @@ impl<'test> TestCx<'test> { .env("PAGER", "") .stdin(File::open(&diff_filename).unwrap()) // Capture output and print it explicitly so it will in turn be - // captured by libtest. + // captured by output-capture. .output() .unwrap(); assert!(output.status.success()); @@ -2666,8 +2678,8 @@ impl<'test> TestCx<'test> { // // It's not possible to detect paths in the error messages generally, but this is a // decent enough heuristic. - static_regex!( - r#"(?x) + let re = static_regex!( + r#"(?x) (?: # Match paths that don't include spaces. (?:\\[\pL\pN\.\-_']+)+\.\pL+ @@ -2675,11 +2687,8 @@ impl<'test> TestCx<'test> { # If the path starts with a well-known root, then allow spaces and no file extension. \$(?:DIR|SRC_DIR|TEST_BUILD_DIR|BUILD_DIR|LIB_DIR)(?:\\[\pL\pN\.\-_'\ ]+)+ )"# - ) - .replace_all(&output, |caps: &Captures<'_>| { - println!("{}", &caps[0]); - caps[0].replace(r"\", "/") - }) + ); + re.replace_all(&output, |caps: &Captures<'_>| caps[0].replace(r"\", "/")) .replace("\r\n", "\n") } diff --git a/src/tools/compiletest/src/compute_diff.rs b/src/tools/compiletest/src/runtest/compute_diff.rs index 509e7e11703..509e7e11703 100644 --- a/src/tools/compiletest/src/compute_diff.rs +++ b/src/tools/compiletest/src/runtest/compute_diff.rs diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index 6114afdc9df..88d022b8bba 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -10,7 +10,6 @@ use super::debugger::DebuggerCommands; use super::{Debugger, Emit, ProcRes, TestCx, Truncated, WillExecute}; use crate::common::Config; use crate::debuggers::{extract_gdb_version, is_android_gdb_target}; -use crate::util::logv; impl TestCx<'_> { pub(super) fn run_debuginfo_test(&self) { @@ -234,7 +233,7 @@ impl TestCx<'_> { gdb.args(debugger_opts); // FIXME(jieyouxu): don't pass an empty Path let cmdline = self.make_cmdline(&gdb, Utf8Path::new("")); - logv(self.config, format!("executing {}", cmdline)); + self.logv(format_args!("executing {cmdline}")); cmdline }; @@ -395,6 +394,35 @@ impl TestCx<'_> { // We don't want to hang when calling `quit` while the process is still running let mut script_str = String::from("settings set auto-confirm true\n"); + // macOS has a system for restricting access to files and peripherals + // called Transparency, Consent, and Control (TCC), which can be + // configured using the "Security & Privacy" tab in your settings. + // + // This system is provenance-based: if Terminal.app is given access to + // your Desktop, and you launch a binary within Terminal.app, the new + // binary also has access to the files on your Desktop. + // + // By default though, LLDB launches binaries in very isolated + // contexts. This includes resetting any TCC grants that might + // otherwise have been inherited. + // + // In effect, this means that if the developer has placed the rust + // repository under one of the system-protected folders, they will get + // a pop-up _for each binary_ asking for permissions to access the + // folder - quite annoying. + // + // To avoid this, we tell LLDB to spawn processes with TCC grants + // inherited from the parent process. + // + // Setting this also avoids unnecessary overhead from XprotectService + // when running with the Developer Tool grant. + // + // TIP: If you want to allow launching `lldb ~/Desktop/my_binary` + // without being prompted, you can put this in your `~/.lldbinit` too. + if self.config.host.contains("darwin") { + script_str.push_str("settings set target.inherit-tcc true\n"); + } + // Make LLDB emit its version, so we have it documented in the test output script_str.push_str("version\n"); diff --git a/src/tools/compiletest/src/runtest/mir_opt.rs b/src/tools/compiletest/src/runtest/mir_opt.rs index efdb131bf14..55043bf4bc2 100644 --- a/src/tools/compiletest/src/runtest/mir_opt.rs +++ b/src/tools/compiletest/src/runtest/mir_opt.rs @@ -6,7 +6,7 @@ use miropt_test_tools::{MiroptTest, MiroptTestFile, files_for_miropt_test}; use tracing::debug; use super::{Emit, TestCx, WillExecute}; -use crate::compute_diff::write_diff; +use crate::runtest::compute_diff::write_diff; impl TestCx<'_> { pub(super) fn run_mir_opt_test(&self) { diff --git a/src/tools/compiletest/src/runtest/pretty.rs b/src/tools/compiletest/src/runtest/pretty.rs index e3b07f1d63d..26557727233 100644 --- a/src/tools/compiletest/src/runtest/pretty.rs +++ b/src/tools/compiletest/src/runtest/pretty.rs @@ -1,14 +1,13 @@ use std::fs; use super::{ProcRes, ReadFrom, TestCx}; -use crate::util::logv; impl TestCx<'_> { pub(super) fn run_pretty_test(&self) { if self.props.pp_exact.is_some() { - logv(self.config, "testing for exact pretty-printing".to_owned()); + self.logv("testing for exact pretty-printing"); } else { - logv(self.config, "testing for converging pretty-printing".to_owned()); + self.logv("testing for converging pretty-printing"); } let rounds = match self.props.pp_exact { @@ -21,10 +20,7 @@ impl TestCx<'_> { let mut round = 0; while round < rounds { - logv( - self.config, - format!("pretty-printing round {} revision {:?}", round, self.revision), - ); + self.logv(format_args!("pretty-printing round {round} revision {:?}", self.revision)); let read_from = if round == 0 { ReadFrom::Path } else { ReadFrom::Stdin(srcs[round].to_owned()) }; diff --git a/src/tools/compiletest/src/runtest/run_make.rs b/src/tools/compiletest/src/runtest/run_make.rs index c8d5190c039..8a0e45cf8ca 100644 --- a/src/tools/compiletest/src/runtest/run_make.rs +++ b/src/tools/compiletest/src/runtest/run_make.rs @@ -308,7 +308,7 @@ impl TestCx<'_> { let stdout = String::from_utf8_lossy(&stdout).into_owned(); let stderr = String::from_utf8_lossy(&stderr).into_owned(); // This conditions on `status.success()` so we don't print output twice on error. - // NOTE: this code is called from a libtest thread, so it's hidden by default unless --nocapture is passed. + // NOTE: this code is called from an executor thread, so it's hidden by default unless --no-capture is passed. self.dump_output(status.success(), &cmd.get_program().to_string_lossy(), &stdout, &stderr); if !status.success() { let res = ProcRes { status, stdout, stderr, truncated, cmdline: format!("{:?}", cmd) }; diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index fb047548c45..1f16a672a98 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -2,9 +2,6 @@ use std::env; use std::process::Command; use camino::{Utf8Path, Utf8PathBuf}; -use tracing::*; - -use crate::common::Config; #[cfg(test)] mod tests; @@ -26,14 +23,6 @@ fn path_div() -> &'static str { ";" } -pub fn logv(config: &Config, s: String) { - debug!("{}", s); - if config.verbose { - // Note: `./x test ... --verbose --no-capture` is needed to see this print. - println!("{}", s); - } -} - pub trait Utf8PathBufExt { /// Append an extension to the path, even if it already has one. fn with_extra_extension(&self, extension: &str) -> Utf8PathBuf; diff --git a/src/tools/coverage-dump/Cargo.toml b/src/tools/coverage-dump/Cargo.toml index 36a66f16030..e491804c257 100644 --- a/src/tools/coverage-dump/Cargo.toml +++ b/src/tools/coverage-dump/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" [dependencies] anyhow = "1.0.71" -itertools = "0.12" +itertools.workspace = true leb128 = "0.2.5" md5 = { package = "md-5" , version = "0.10.5" } miniz_oxide = "0.8.8" regex = "1.8.4" -rustc-demangle = "0.1.23" +rustc-demangle.workspace = true diff --git a/src/tools/features-status-dump/Cargo.toml b/src/tools/features-status-dump/Cargo.toml index b2976f14a01..d72555da486 100644 --- a/src/tools/features-status-dump/Cargo.toml +++ b/src/tools/features-status-dump/Cargo.toml @@ -8,5 +8,5 @@ edition = "2021" anyhow = { version = "1" } clap = { version = "4", features = ["derive"] } serde = { version = "1.0.125", features = [ "derive" ] } -serde_json = "1.0.59" +serde_json.workspace = true tidy = { path = "../tidy", features = ["build-metrics"] } diff --git a/src/tools/generate-copyright/Cargo.toml b/src/tools/generate-copyright/Cargo.toml index bcb3165de45..5edf1f3d88b 100644 --- a/src/tools/generate-copyright/Cargo.toml +++ b/src/tools/generate-copyright/Cargo.toml @@ -11,5 +11,5 @@ anyhow = "1.0.65" askama = "0.14.0" cargo_metadata = "0.21" serde = { version = "1.0.147", features = ["derive"] } -serde_json = "1.0.85" +serde_json.workspace = true thiserror = "1" diff --git a/src/tools/jsondocck/Cargo.toml b/src/tools/jsondocck/Cargo.toml index 80fc26cbe66..92fde363882 100644 --- a/src/tools/jsondocck/Cargo.toml +++ b/src/tools/jsondocck/Cargo.toml @@ -8,5 +8,5 @@ jsonpath-rust = "1.0.0" getopts = "0.2" regex = "1.4" shlex = "1.0" -serde_json = "1.0" +serde_json.workspace = true fs-err = "2.5.0" diff --git a/src/tools/jsondoclint/Cargo.toml b/src/tools/jsondoclint/Cargo.toml index cc8ecefd530..44beaf2ddfd 100644 --- a/src/tools/jsondoclint/Cargo.toml +++ b/src/tools/jsondoclint/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0.62" clap = { version = "4.0.15", features = ["derive"] } fs-err = "2.8.1" -rustc-hash = "2.0.0" +rustc-hash.workspace = true rustdoc-json-types = { version = "0.1.0", path = "../../rustdoc-json-types" } serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0.85" +serde_json.workspace = true diff --git a/src/tools/jsondoclint/src/item_kind.rs b/src/tools/jsondoclint/src/item_kind.rs index 51146831efa..e2738636a14 100644 --- a/src/tools/jsondoclint/src/item_kind.rs +++ b/src/tools/jsondoclint/src/item_kind.rs @@ -26,6 +26,7 @@ pub(crate) enum Kind { AssocType, Primitive, Keyword, + Attribute, // Not in ItemKind ProcMacro, } @@ -53,6 +54,7 @@ impl Kind { ExternType => true, // FIXME(adotinthevoid): I'm not sure if these are correct + Attribute => false, Keyword => false, ProcAttribute => false, ProcDerive => false, @@ -109,6 +111,7 @@ impl Kind { Kind::Primitive => false, Kind::Keyword => false, Kind::ProcMacro => false, + Kind::Attribute => false, } } @@ -163,6 +166,7 @@ impl Kind { match s.kind { ItemKind::AssocConst => AssocConst, ItemKind::AssocType => AssocType, + ItemKind::Attribute => Attribute, ItemKind::Constant => Constant, ItemKind::Enum => Enum, ItemKind::ExternCrate => ExternCrate, diff --git a/src/tools/lint-docs/Cargo.toml b/src/tools/lint-docs/Cargo.toml index 6e1ab84ed18..acafe17cb0c 100644 --- a/src/tools/lint-docs/Cargo.toml +++ b/src/tools/lint-docs/Cargo.toml @@ -8,6 +8,6 @@ description = "A script to extract the lint documentation for the rustc book." [dependencies] rustc-literal-escaper = "0.0.5" -serde_json = "1.0.57" -tempfile = "3.1.0" +serde_json.workspace = true +tempfile.workspace = true walkdir = "2.3.1" diff --git a/src/tools/llvm-bitcode-linker/Cargo.toml b/src/tools/llvm-bitcode-linker/Cargo.toml index a9210b562f3..f78f8b618d3 100644 --- a/src/tools/llvm-bitcode-linker/Cargo.toml +++ b/src/tools/llvm-bitcode-linker/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] anyhow = "1.0" -tracing = "0.1" -tracing-subscriber = {version = "0.3.0", features = ["std"] } +tracing.workspace = true +tracing-subscriber = { version = "0.3.0", features = ["std"] } clap = { version = "4.3", features = ["derive"] } thiserror = "1.0.24" diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 5e833540002..695959e2e68 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -269d5b56bcfdf2be82213e72ef9a2e4c592a8c6b +e004014d1bf4c29928a0f0f9f7d0964d43606cbd diff --git a/src/tools/miri/tests/pass/atomic.rs b/src/tools/miri/tests/pass/atomic.rs index 3de34e570c7..d8ac5114f27 100644 --- a/src/tools/miri/tests/pass/atomic.rs +++ b/src/tools/miri/tests/pass/atomic.rs @@ -2,7 +2,6 @@ //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-strict-provenance -#![feature(strict_provenance_atomic_ptr)] // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] diff --git a/src/tools/opt-dist/Cargo.toml b/src/tools/opt-dist/Cargo.toml index f4051ae67d7..b2833a9d7f1 100644 --- a/src/tools/opt-dist/Cargo.toml +++ b/src/tools/opt-dist/Cargo.toml @@ -15,9 +15,9 @@ fs_extra = "1" camino = "1" tar = "0.4" xz = { version = "0.1", package = "xz2" } -serde_json = "1" +serde_json.workspace = true glob = "0.3" -tempfile = "3.5" +tempfile.workspace = true derive_builder = "0.20" clap = { version = "4", features = ["derive"] } tabled = { version = "0.15", default-features = false, features = ["std"] } diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index 250e0f65a9f..86ac4b9d7b4 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -12,10 +12,10 @@ edition = "2024" # tidy-alphabetical-start bstr = "1.12" gimli = "0.32" -libc = "0.2" +libc.workspace = true object = "0.37" regex = "1.11" -serde_json = "1.0" +serde_json.workspace = true similar = "2.7" wasmparser = { version = "0.236", default-features = false, features = ["std", "features", "validate"] } # tidy-alphabetical-end diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index c1f27de7ed4..f43733665ed 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -14,7 +14,7 @@ ignore = "0.4.18" semver = "1.0" serde = { version = "1.0.125", features = ["derive"], optional = true } termcolor = "1.1.3" -rustc-hash = "2.0.0" +rustc-hash.workspace = true fluent-syntax = "0.12" similar = "2.5.0" toml = "0.7.8" diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 18d97a748ba..6974ede624a 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -287,14 +287,12 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "gimli", "gsgdt", "hashbrown", + "icu_collections", "icu_list", - "icu_list_data", - "icu_locid", - "icu_locid_transform", - "icu_locid_transform_data", + "icu_locale", + "icu_locale_core", + "icu_locale_data", "icu_provider", - "icu_provider_adapters", - "icu_provider_macros", "ident_case", "indexmap", "intl-memoizer", @@ -332,6 +330,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "polonius-engine", "portable-atomic", // dependency for platforms doesn't support `AtomicU64` in std "portable-atomic-util", + "potential_utf", "ppv-lite86", "proc-macro-hack", "proc-macro2", @@ -447,6 +446,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "zerocopy-derive", "zerofrom", "zerofrom-derive", + "zerotrie", "zerovec", "zerovec-derive", // tidy-alphabetical-end diff --git a/src/tools/tidy/src/unit_tests.rs b/src/tools/tidy/src/unit_tests.rs index 3d14a467319..7396310ed37 100644 --- a/src/tools/tidy/src/unit_tests.rs +++ b/src/tools/tidy/src/unit_tests.rs @@ -61,6 +61,7 @@ pub fn check(root_path: &Path, stdlib: bool, bad: &mut bool) { || path.ends_with("library/alloc/src/collections/linked_list/tests.rs") || path.ends_with("library/alloc/src/collections/vec_deque/tests.rs") || path.ends_with("library/alloc/src/raw_vec/tests.rs") + || path.ends_with("library/alloc/src/wtf8/tests.rs") } }; |
