Skip to content

Commit 238ef54

Browse files
committed
Add tidy check to forbid 'CHECK: br' and 'CHECK-NOT: br' in new codegen tests
1 parent 9a8dc7e commit 238ef54

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/tools/tidy/src/style.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ pub fn check(path: &Path, tidy_ctx: TidyCtx) {
445445
let mut comment_block: Option<(usize, usize)> = None;
446446
let is_test = file.components().any(|c| c.as_os_str() == "tests")
447447
|| file.file_stem().unwrap() == "tests";
448+
let is_codegen_test = is_test && file.components().any(|c| c.as_os_str() == "codegen-llvm");
448449
let is_this_file = file.ends_with(this_file) || this_file.ends_with(file);
449450
let is_test_for_this_file =
450451
is_test && file.parent().unwrap().ends_with(this_file.with_extension(""));
@@ -488,6 +489,11 @@ pub fn check(path: &Path, tidy_ctx: TidyCtx) {
488489
)
489490
}
490491

492+
if is_codegen_test && trimmed.contains("CHECK") && trimmed.ends_with(": br") {
493+
err("`CHECK: br` and `CHECK-NOT: br` in codegen tests are fragile to false \
494+
positives in mangled symbols. Try using `br {{.*}}` instead.")
495+
}
496+
491497
if !under_rustfmt
492498
&& line.chars().count() > max_columns
493499
&& !long_line_is_ok(&extension, is_error_code, max_columns, line)

0 commit comments

Comments
 (0)