From 2ec1032b4bf224d652891d595354e92ca61b65c4 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 14 Sep 2024 20:50:53 +1000 Subject: [PATCH 1/3] Teach `src/tools/lint-docs` about some bootstrap conditionals --- src/tools/lint-docs/src/lib.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/tools/lint-docs/src/lib.rs b/src/tools/lint-docs/src/lib.rs index 532a27b22aa6f..a365a05d3c2f3 100644 --- a/src/tools/lint-docs/src/lib.rs +++ b/src/tools/lint-docs/src/lib.rs @@ -206,6 +206,15 @@ impl<'a> LintExtractor<'a> { None => return Ok(lints), } }; + + fn strip_prefix_and_suffix<'a>( + line: &'a str, + prefix: &str, + suffix: &str, + ) -> Option<&'a str> { + line.strip_prefix(prefix)?.strip_suffix(suffix) + } + // Read the lint. let mut doc_lines = Vec::new(); let (doc, name) = loop { @@ -216,6 +225,20 @@ impl<'a> LintExtractor<'a> { doc_lines.push(text.to_string()); } else if line == "///" { doc_lines.push("".to_string()); + } else if let Some(_) = strip_prefix_and_suffix( + line, + r##"#[cfg_attr(bootstrap, doc = ""##, + r##"")]"##, + ) { + // Ignore bootstrap-only parts of the doc comment. + continue; + } else if let Some(text) = strip_prefix_and_suffix( + line, + r##"#[cfg_attr(not(bootstrap), doc = ""##, + r##"")]"##, + ) { + // Include not-bootstrap parts of the doc comment. + doc_lines.push(text.to_string()) } else if line.starts_with("// ") { // Ignore comments. continue; From fedb84065aa7390b257b35d2b885856ae80e9289 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 14 Sep 2024 18:11:01 +1000 Subject: [PATCH 2/3] Ignore some doctests that are incompatible with current `--stage=0` These changes can be reverted during the next bootstrap bump. --- compiler/rustc_lint/src/if_let_rescope.rs | 4 +++- compiler/rustc_lint_defs/src/builtin.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 5b65541bea6e2..2ce057715f762 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -23,7 +23,9 @@ declare_lint! { /// /// ### Example /// - /// ```rust,edition2021 + #[cfg_attr(bootstrap, doc = "```ignore")] + #[cfg_attr(not(bootstrap), doc = "```rust,edition2021")] + // ``` // Trick tidy's backtick count. Remove on bootstrap bump. #[cfg(not(bootstrap))] /// #![feature(if_let_rescope)] /// #![warn(if_let_rescope)] /// #![allow(unused_variables)] diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 25d33126754af..78e1d32d23bb4 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1870,7 +1870,9 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail + #[cfg_attr(bootstrap, doc = "```ignore")] + #[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")] + // ``` // Trick tidy's backtick count. Remove on bootstrap bump. #[cfg(not(bootstrap))] /// #![deny(elided_named_lifetimes)] /// struct Foo; /// impl Foo { From 0e3cb541363ba9a792cd0ae56ff10ffa6c72cbef Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 14 Sep 2024 17:59:21 +1000 Subject: [PATCH 3/3] Propagate `rustc_use_parallel_compiler` in more crates This fixes `x test compiler` under `rust.parallel-compiler = true`. --- compiler/rustc_lint/Cargo.toml | 9 +++++++++ compiler/rustc_lint_defs/Cargo.toml | 8 ++++++++ compiler/rustc_middle/Cargo.toml | 8 +++++++- compiler/rustc_mir_transform/Cargo.toml | 9 +++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_lint/Cargo.toml b/compiler/rustc_lint/Cargo.toml index 232d4c18fa486..e118f19e94b04 100644 --- a/compiler/rustc_lint/Cargo.toml +++ b/compiler/rustc_lint/Cargo.toml @@ -27,3 +27,12 @@ rustc_type_ir = { path = "../rustc_type_ir" } tracing = "0.1" unicode-security = "0.1.0" # tidy-alphabetical-end + +[features] +# tidy-alphabetical-start +rustc_use_parallel_compiler = [ + 'rustc_data_structures/rustc_use_parallel_compiler', + 'rustc_errors/rustc_use_parallel_compiler', + 'rustc_middle/rustc_use_parallel_compiler', +] +# tidy-alphabetical-end diff --git a/compiler/rustc_lint_defs/Cargo.toml b/compiler/rustc_lint_defs/Cargo.toml index eb2a184ef84b1..55fae33f4459a 100644 --- a/compiler/rustc_lint_defs/Cargo.toml +++ b/compiler/rustc_lint_defs/Cargo.toml @@ -15,3 +15,11 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } serde = { version = "1.0.125", features = ["derive"] } # tidy-alphabetical-end + +[features] +# tidy-alphabetical-start +rustc_use_parallel_compiler = [ + 'rustc_data_structures/rustc_use_parallel_compiler', + 'rustc_error_messages/rustc_use_parallel_compiler', +] +# tidy-alphabetical-end diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index b23589afb5874..fa5feaa4d34d3 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -41,5 +41,11 @@ tracing = "0.1" [features] # tidy-alphabetical-start rustc_randomized_layouts = [] -rustc_use_parallel_compiler = ["dep:rustc-rayon-core"] +rustc_use_parallel_compiler = [ + "dep:rustc-rayon-core", + "rustc_data_structures/rustc_use_parallel_compiler", + "rustc_errors/rustc_use_parallel_compiler", + "rustc_error_messages/rustc_use_parallel_compiler", + "rustc_query_system/rustc_use_parallel_compiler", +] # tidy-alphabetical-end diff --git a/compiler/rustc_mir_transform/Cargo.toml b/compiler/rustc_mir_transform/Cargo.toml index 07ca51a67aefb..bdef8cb413e23 100644 --- a/compiler/rustc_mir_transform/Cargo.toml +++ b/compiler/rustc_mir_transform/Cargo.toml @@ -29,3 +29,12 @@ rustc_type_ir = { path = "../rustc_type_ir" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } tracing = "0.1" # tidy-alphabetical-end + +[features] +# tidy-alphabetical-start +rustc_use_parallel_compiler = [ + 'rustc_data_structures/rustc_use_parallel_compiler', + 'rustc_errors/rustc_use_parallel_compiler', + 'rustc_middle/rustc_use_parallel_compiler', +] +# tidy-alphabetical-end