From 99e6438660d665c9aa4d2831560ba2287becb13f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 2 Apr 2019 10:34:34 +0300 Subject: allow empty doc comments --- crates/ra_syntax/src/ast/traits.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/ra_syntax') 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 { /// Returns the textual content of a doc comment block as a single string. /// That is, strips leading `///` (+ optional 1 character of whitespace) /// and joins lines. - fn doc_comment_text(&self) -> Option { + fn doc_comment_text(&self) -> Option { + let mut has_comments = false; let docs = self .doc_comments() .filter(|comment| comment.is_doc_comment()) .map(|comment| { + has_comments = true; let prefix_len = comment.prefix().len(); let line = comment.text().as_str(); @@ -128,10 +130,10 @@ pub trait DocCommentsOwner: AstNode { }) .join("\n"); - if docs.is_empty() { - None - } else { + if has_comments { Some(docs) + } else { + None } } } -- cgit v1.2.3