Skip to content

Commit 6c3a50c

Browse files
committed
Improve handling of legacy style directives
1 parent 68a51a8 commit 6c3a50c

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/tools/compiletest/src/header.rs

+25-10
Original file line numberDiff line numberDiff line change
@@ -834,16 +834,31 @@ fn iter_header_extra(
834834

835835
for candidate in DIAGNOSTICS_DIRECTIVE_NAMES.iter() {
836836
if rest.starts_with(candidate) {
837-
// We have a comment that's *successfully* parsed as an legacy-style directive.
838-
// We emit an error here to warn the user.
839-
*poisoned = true;
840-
eprintln!(
841-
"error: detected legacy-style directives in ui test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
842-
testfile.display(),
843-
line_number,
844-
line_directive("//", ln),
845-
);
846-
return;
837+
let Some(prefix_removed) = rest.strip_prefix(candidate) else {
838+
// We have a comment that's *successfully* parsed as an legacy-style
839+
// directive. We emit an error here to warn the user.
840+
*poisoned = true;
841+
eprintln!(
842+
"error: detected legacy-style directives in ui test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
843+
testfile.display(),
844+
line_number,
845+
line_directive("//", ln),
846+
);
847+
return;
848+
};
849+
850+
if prefix_removed.starts_with([' ', ':']) {
851+
// We have a comment that's *successfully* parsed as an legacy-style
852+
// directive. We emit an error here to warn the user.
853+
*poisoned = true;
854+
eprintln!(
855+
"error: detected legacy-style directives in ui test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
856+
testfile.display(),
857+
line_number,
858+
line_directive("//", ln),
859+
);
860+
return;
861+
}
847862
}
848863
}
849864
}

0 commit comments

Comments
 (0)