Skip to content

Commit bea18c7

Browse files
authored
Rollup merge of #69205 - JohnTitor:allow-whitespaces, r=Mark-Simulacrum
Allow whitespaces in revision flags Allow whitespaces in revision flags, like `// [foo]`. Fixes #69183
2 parents 8b93e67 + d1a7ae7 commit bea18c7

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

Diff for: src/tools/compiletest/src/header.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,6 @@ fn iter_header<R: Read>(testfile: &Path, cfg: Option<&str>, rdr: R, it: &mut dyn
631631

632632
let comment = if testfile.to_string_lossy().ends_with(".rs") { "//" } else { "#" };
633633

634-
// FIXME: would be nice to allow some whitespace between comment and brace :)
635-
// It took me like 2 days to debug why compile-flags weren’t taken into account for my test :)
636-
let comment_with_brace = comment.to_string() + "[";
637-
638634
let mut rdr = BufReader::new(rdr);
639635
let mut ln = String::new();
640636

@@ -650,7 +646,7 @@ fn iter_header<R: Read>(testfile: &Path, cfg: Option<&str>, rdr: R, it: &mut dyn
650646
let ln = ln.trim();
651647
if ln.starts_with("fn") || ln.starts_with("mod") {
652648
return;
653-
} else if ln.starts_with(&comment_with_brace) {
649+
} else if ln.starts_with(comment) && ln[comment.len()..].trim_start().starts_with('[') {
654650
// A comment like `//[foo]` is specific to revision `foo`
655651
if let Some(close_brace) = ln.find(']') {
656652
let open_brace = ln.find('[').unwrap();
@@ -663,10 +659,7 @@ fn iter_header<R: Read>(testfile: &Path, cfg: Option<&str>, rdr: R, it: &mut dyn
663659
it(ln[(close_brace + 1)..].trim_start());
664660
}
665661
} else {
666-
panic!(
667-
"malformed condition directive: expected `{}foo]`, found `{}`",
668-
comment_with_brace, ln
669-
)
662+
panic!("malformed condition directive: expected `{}[foo]`, found `{}`", comment, ln)
670663
}
671664
} else if ln.starts_with(comment) {
672665
it(ln[comment.len()..].trim_start());

0 commit comments

Comments
 (0)