From 99bca6e8c9e147c884200230ea7eaea5d55dfdae Mon Sep 17 00:00:00 2001 From: Kevin Yap Date: Fri, 12 May 2017 00:16:52 -0700 Subject: [PATCH] Add tidy check to detect empty files Addresses #18439. --- src/tools/tidy/src/style.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 28a55a8763c..8bf683de870 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -107,6 +107,11 @@ pub fn check(path: &Path, bad: &mut bool) { contents.truncate(0); t!(t!(File::open(file), file).read_to_string(&mut contents)); + + if contents.is_empty() { + tidy_error!(bad, "{}: empty file", file.display()); + } + let skip_cr = contents.contains("ignore-tidy-cr"); let skip_tab = contents.contains("ignore-tidy-tab"); let skip_length = contents.contains("ignore-tidy-linelength");