Repository: rust-lang/rustfmt (rust)

Issue:
`wrap_comments` removes spaces after leading dot
Is this expected? 
```diff
❯ cargo fmt --check
Diff in /private/tmp/tmp/src/main.rs at line 1:
 fn main() {
     // f   3    .
     // t   3    .
-    // .   .    3.5
-    // .   .    -4.3
-    // .   .    .
+    // . .    3.5
+    // . .    -4.3
+    // . .    .
 }
```

```
rustfmt 1.6.0-nightly (0e8e857b 2023-07-16)
```

Pull request:
fix: reject leading `.`, `)` without prefix as item marker
fix #5835

Patch:
diff --git a/src/comment.rs b/src/comment.rs
index a000d110..dec925e1 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -482,7 +482,9 @@ impl ItemizedBlock {
         // allowed.
         for suffix in [". ", ") "] {
             if let Some((prefix, _)) = trimmed.split_once(suffix) {
-                if prefix.len() <= 2 && prefix.chars().all(|c| char::is_ascii_digit(&c)) {
+                let has_leading_digits = (1..=2).contains(&prefix.len())
+                    && prefix.chars().all(|c| char::is_ascii_digit(&c));
+                if has_leading_digits {
                     return Some(prefix.len() + suffix.len());
                 }
             }
@@ -2126,6 +2128,9 @@ fn main() {
             // https://spec.commonmark.org/0.30 says: "A start number may not be negative":
             "-1. Not a list item.",
             "-1 Not a list item.",
+            // Marker without prefix are not recognized as item markers:
+            ".   Not a list item.",
+            ")   Not a list item.",
         ];
         for line in test_inputs.iter() {
             let maybe_block = ItemizedBlock::new(line);


Test patch:
diff --git a/tests/source/issue-5835.rs b/tests/source/issue-5835.rs
new file mode 100644
index 00000000..3e4da349
--- /dev/null
+++ b/tests/source/issue-5835.rs
@@ -0,0 +1,8 @@
+// rustfmt-wrap_comments: true
+
+/// .   a
+pub fn foo() {}
+
+pub fn main() {
+    // .   a
+}
diff --git a/tests/target/issue-5835.rs b/tests/target/issue-5835.rs
new file mode 100644
index 00000000..3e4da349
--- /dev/null
+++ b/tests/target/issue-5835.rs
@@ -0,0 +1,8 @@
+// rustfmt-wrap_comments: true
+
+/// .   a
+pub fn foo() {}
+
+pub fn main() {
+    // .   a
+}