aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_syntax/src/ast/traits.rs10
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}