diff options
author | Aleksey Kladov <[email protected]> | 2019-04-02 08:34:34 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-04-02 08:35:34 +0100 |
commit | 99e6438660d665c9aa4d2831560ba2287becb13f (patch) | |
tree | 1fc9d6dd5c916bba2735358c20b9a0de10977357 /crates | |
parent | ae282d8da63a82077361bc142b2b9a272a2eac64 (diff) |
allow empty doc comments
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index f9021d7bf..43d1509fa 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs | |||
@@ -107,11 +107,13 @@ pub trait DocCommentsOwner: AstNode { | |||
107 | /// Returns the textual content of a doc comment block as a single string. | 107 | /// Returns the textual content of a doc comment block as a single string. |
108 | /// That is, strips leading `///` (+ optional 1 character of whitespace) | 108 | /// That is, strips leading `///` (+ optional 1 character of whitespace) |
109 | /// and joins lines. | 109 | /// and joins lines. |
110 | fn doc_comment_text(&self) -> Option<std::string::String> { | 110 | fn doc_comment_text(&self) -> Option<String> { |
111 | let mut has_comments = false; | ||
111 | let docs = self | 112 | let docs = self |
112 | .doc_comments() | 113 | .doc_comments() |
113 | .filter(|comment| comment.is_doc_comment()) | 114 | .filter(|comment| comment.is_doc_comment()) |
114 | .map(|comment| { | 115 | .map(|comment| { |
116 | has_comments = true; | ||
115 | let prefix_len = comment.prefix().len(); | 117 | let prefix_len = comment.prefix().len(); |
116 | 118 | ||
117 | let line = comment.text().as_str(); | 119 | let line = comment.text().as_str(); |
@@ -128,10 +130,10 @@ pub trait DocCommentsOwner: AstNode { | |||
128 | }) | 130 | }) |
129 | .join("\n"); | 131 | .join("\n"); |
130 | 132 | ||
131 | if docs.is_empty() { | 133 | if has_comments { |
132 | None | ||
133 | } else { | ||
134 | Some(docs) | 134 | Some(docs) |
135 | } else { | ||
136 | None | ||
135 | } | 137 | } |
136 | } | 138 | } |
137 | } | 139 | } |