about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2023-01-17 08:09:51 +0000
committerMaybe Waffle <waffle.lapkin@gmail.com>2023-01-17 08:09:51 +0000
commita49f57180d8a677e44abe30346d216c192e92fd4 (patch)
treeaf5eb861bd896fe304001416bc9e747609cdf56c
parent6a28fb42a8b8f1f67fe854c2206148171e434d73 (diff)
downloadrust-a49f57180d8a677e44abe30346d216c192e92fd4.tar.gz
rust-a49f57180d8a677e44abe30346d216c192e92fd4.zip
Add a tidy check to check for ". \w"
-rw-r--r--src/tools/tidy/src/style.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs
index 5c4ba869364..ae7e3d8d702 100644
--- a/src/tools/tidy/src/style.rs
+++ b/src/tools/tidy/src/style.rs
@@ -45,6 +45,9 @@ C++ code used llvm_unreachable, which triggers undefined behavior
 when executed when assertions are disabled.
 Use llvm::report_fatal_error for increased robustness.";
 
+const DOUBLE_SPACE_AFTER_DOT: &str = r"\
+Use a single space after dots in comments.";
+
 const ANNOTATIONS_TO_IGNORE: &[&str] = &[
     "// @!has",
     "// @has",
@@ -405,6 +408,19 @@ pub fn check(path: &Path, bad: &mut bool) {
             if filename.ends_with(".cpp") && line.contains("llvm_unreachable") {
                 err(LLVM_UNREACHABLE_INFO);
             }
+
+            // For now only enforce in compiler
+            let is_compiler = || file.components().any(|c| c.as_os_str() == "compiler");
+            if is_compiler()
+                && line.contains("//")
+                && line
+                    .chars()
+                    .collect::<Vec<_>>()
+                    .windows(4)
+                    .any(|cs| matches!(cs, ['.', ' ', ' ', last] if last.is_alphabetic()))
+            {
+                err(DOUBLE_SPACE_AFTER_DOT)
+            }
         }
         if leading_new_lines {
             let mut err = |_| {