Display the name of the failed file in tidy/libcoretest · rust-lang/rust@16c088d (original) (raw)

Original file line number Diff line number Diff line change
@@ -22,14 +22,21 @@ pub fn check(path: &Path, bad: &mut bool) {
22 22 &libcore_path,
23 23 &mut |subpath
24 24 &mut |subpath
25 -if subpath.ends_with(".rs") {
26 -if t!(read_to_string(subpath)).contains("#[test]") {
27 -tidy_error!(
28 - bad,
29 -"{} contains #[test]; libcore tests must be placed inside \
30 - `src/libcore/tests/`",
31 - subpath.display()
32 -);
25 +if let Some("rs") = subpath.extension().and_then(|e
26 +match read_to_string(subpath) {
27 +Ok(contents) => {
28 +if contents.contains("#[test]") {
29 +tidy_error!(
30 + bad,
31 +"{} contains #[test]; libcore tests must be placed inside \
32 + `src/libcore/tests/`",
33 + subpath.display()
34 +);
35 +}
36 +}
37 +Err(err) => {
38 +panic!("failed to read file {:?}: {}", subpath, err);
39 +}
33 40 }
34 41 }
35 42 },