about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThaqib <65588695+thaqibm@users.noreply.github.com>2023-02-01 22:26:12 -0500
committerGitHub <noreply@github.com>2023-02-01 21:26:12 -0600
commite2996a807b411218bb3dca0f2a0e420839cd3875 (patch)
treea8290002cb769d201f4c8022375c1bcc92a516aa
parent3f36c997bf45eb7b6f101885241ae59ce00e72d9 (diff)
downloadrust-e2996a807b411218bb3dca0f2a0e420839cd3875.tar.gz
rust-e2996a807b411218bb3dca0f2a0e420839cd3875.zip
Lists doc comments fix4041 (#5560)
* add + start of an itemized line

* add test

* fix format

* fix tests

* update doc comment
-rw-r--r--src/comment.rs5
-rw-r--r--tests/source/issue-4041.rs5
-rw-r--r--tests/target/issue-4041.rs6
3 files changed, 14 insertions, 2 deletions
diff --git a/src/comment.rs b/src/comment.rs
index 17b4af1717d..bc0e8774f49 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -432,7 +432,7 @@ impl CodeBlockAttribute {
 
 /// Block that is formatted as an item.
 ///
-/// An item starts with either a star `*` a dash `-` or a greater-than `>`.
+/// An item starts with either a star `*` a dash `-` a greater-than `>` or a plus '+'.
 /// Different level of indentation are handled by shrinking the shape accordingly.
 struct ItemizedBlock {
     /// the lines that are identified as part of an itemized block
@@ -449,7 +449,8 @@ impl ItemizedBlock {
     /// Returns `true` if the line is formatted as an item
     fn is_itemized_line(line: &str) -> bool {
         let trimmed = line.trim_start();
-        trimmed.starts_with("* ") || trimmed.starts_with("- ") || trimmed.starts_with("> ")
+        let itemized_start = ["* ", "- ", "> ", "+ "];
+        itemized_start.iter().any(|s| trimmed.starts_with(s))
     }
 
     /// Creates a new ItemizedBlock described with the given line.
diff --git a/tests/source/issue-4041.rs b/tests/source/issue-4041.rs
new file mode 100644
index 00000000000..274b80f1bc5
--- /dev/null
+++ b/tests/source/issue-4041.rs
@@ -0,0 +1,5 @@
+// rustfmt-wrap_comments: true
+//! List:
+//! - Sub list:
+//!   + very long #1 blah blah blah blah blah blah blah blah blah blah blah blah foo baar baxxxxxxxx long line 1231421230912i3091238192038 
+//!   + very long #2 blah blah blah blah blah blah blah blah blah blah blah blah
diff --git a/tests/target/issue-4041.rs b/tests/target/issue-4041.rs
new file mode 100644
index 00000000000..e9c693836f2
--- /dev/null
+++ b/tests/target/issue-4041.rs
@@ -0,0 +1,6 @@
+// rustfmt-wrap_comments: true
+//! List:
+//! - Sub list:
+//!   + very long #1 blah blah blah blah blah blah blah blah blah blah blah blah
+//!     foo baar baxxxxxxxx long line 1231421230912i3091238192038
+//!   + very long #2 blah blah blah blah blah blah blah blah blah blah blah blah