about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Arellano <ericarellano@me.com>2020-12-08 12:50:52 -0700
committerEric Arellano <ericarellano@me.com>2020-12-08 12:51:00 -0700
commit989edf4a5ffb0944e173ec23cb5614c252e8082e (patch)
treec6affa26eb5105501a3ecfbefa9151b0d9488bc1 /src
parenta3174de9ffaf2ea9213114a8457f880fbc727347 (diff)
downloadrust-989edf4a5ffb0944e173ec23cb5614c252e8082e.tar.gz
rust-989edf4a5ffb0944e173ec23cb5614c252e8082e.zip
Review feedback
* Use a match statement.
* Clarify why we can't use `file_stem()`.
* Error if the `:` is missing for Tidy error codes, rather than no-oping.
Diffstat (limited to 'src')
-rw-r--r--src/tools/tidy/src/error_codes_check.rs14
-rw-r--r--src/tools/tidy/src/ui_tests.rs3
2 files changed, 13 insertions, 4 deletions
diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs
index 1c175901be8..a7199fdfce6 100644
--- a/src/tools/tidy/src/error_codes_check.rs
+++ b/src/tools/tidy/src/error_codes_check.rs
@@ -85,10 +85,16 @@ fn extract_error_codes(
     for line in f.lines() {
         let s = line.trim();
         if !reached_no_explanation && s.starts_with('E') && s.contains("include_str!(\"") {
-            let err_code = match s.split_once(':') {
-                None => continue,
-                Some((err_code, _)) => err_code.to_owned(),
-            };
+            let err_code = s
+                .split_once(':')
+                .expect(
+                    format!(
+                        "Expected a line with the format `E0xxx: include_str!(\"..\")`, but got {} without a `:` delimiter",
+                        s,
+                    ).as_str()
+                )
+                .0
+                .to_owned();
             if !error_codes.contains_key(&err_code) {
                 error_codes.insert(err_code.clone(), false);
             }
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 4c8c1d58ed7..03f4efea983 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -19,6 +19,9 @@ pub fn check(path: &Path, bad: &mut bool) {
                     //
                     // For now, just make sure that there is a corresponding
                     // `$testname.rs` file.
+                    //
+                    // NB: We do not use file_stem() as some file names have multiple `.`s and we
+                    // must strip all of them.
                     let testname =
                         file_path.file_name().unwrap().to_str().unwrap().split_once('.').unwrap().0;
                     if !file_path.with_file_name(testname).with_extension("rs").exists() {