Skip to content

Fix x test compiler unit tests under rust.parallel-compiler = true #130345

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/rustc_lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +31 to +38
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclosure: x test tidy doesn't seem to actually enforce alphabetical ordering of these sub-lists, so the alphabetical check only applies to the top-level features.

4 changes: 3 additions & 1 deletion compiler/rustc_lint/src/if_let_rescope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_lint_defs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,9 @@ declare_lint! {
///
/// ### Example
///
/// ```rust,compile_fail
#[cfg_attr(bootstrap, doc = "```ignore")]
#[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")]
Comment on lines +1873 to +1874
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to Boxy for helping me figure out how to actually do this. ✨

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we have multiple checks using hand-rolled parsers that don't understand this pattern, so I've had to “fix” one and trick the other.

// ``` // Trick tidy's backtick count. Remove on bootstrap bump. #[cfg(not(bootstrap))]
/// #![deny(elided_named_lifetimes)]
/// struct Foo;
/// impl Foo {
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions compiler/rustc_mir_transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions src/tools/lint-docs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
Loading