Skip to content

Commit 6a4def0

Browse files
committed
tidy: Fix a regression in #[test] detection in libcore
`contents` is the whole file rather than a single line.
1 parent c0df742 commit 6a4def0

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/tools/tidy/src/unit_tests.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ pub fn check(path: &Path, bad: &mut bool) {
1313
&mut |entry, contents| {
1414
let subpath = entry.path();
1515
if let Some("rs") = subpath.extension().and_then(|e| e.to_str()) {
16-
let contents = contents.trim();
17-
if !contents.starts_with("//") && contents.contains("#[test]") {
18-
tidy_error!(
19-
bad,
20-
"`{}` contains `#[test]`; libcore tests must be placed inside \
21-
`src/libcore/tests/`",
22-
subpath.display()
23-
);
16+
for line in contents.lines() {
17+
let line = line.trim();
18+
if !line.starts_with("//") && line.contains("#[test]") {
19+
tidy_error!(
20+
bad,
21+
"`{}` contains `#[test]`; libcore tests must be placed inside \
22+
`src/libcore/tests/`",
23+
subpath.display()
24+
);
25+
}
2426
}
2527
}
2628
},

0 commit comments

Comments
 (0)