summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/crates/ide-assists/src/handlers/desugar_doc_comment.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/rust-analyzer/crates/ide-assists/src/handlers/desugar_doc_comment.rs')
-rw-r--r--src/tools/rust-analyzer/crates/ide-assists/src/handlers/desugar_doc_comment.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/desugar_doc_comment.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/desugar_doc_comment.rs
index ddc8a50ed..c859e9852 100644
--- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/desugar_doc_comment.rs
+++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/desugar_doc_comment.rs
@@ -33,9 +33,7 @@ pub(crate) fn desugar_doc_comment(acc: &mut Assists, ctx: &AssistContext<'_>) ->
// Only allow comments which are alone on their line
if let Some(prev) = comment.syntax().prev_token() {
- if Whitespace::cast(prev).filter(|w| w.text().contains('\n')).is_none() {
- return None;
- }
+ Whitespace::cast(prev).filter(|w| w.text().contains('\n'))?;
}
let indentation = IndentLevel::from_token(comment.syntax()).to_string();
@@ -50,7 +48,7 @@ pub(crate) fn desugar_doc_comment(acc: &mut Assists, ctx: &AssistContext<'_>) ->
(
TextRange::new(
comments[0].syntax().text_range().start(),
- comments.last().unwrap().syntax().text_range().end(),
+ comments.last()?.syntax().text_range().end(),
),
Either::Right(comments),
)
@@ -71,9 +69,11 @@ pub(crate) fn desugar_doc_comment(acc: &mut Assists, ctx: &AssistContext<'_>) ->
.map(|l| l.strip_prefix(&indentation).unwrap_or(l))
.join("\n")
}
- Either::Right(comments) => {
- comments.into_iter().map(|c| line_comment_text(IndentLevel(0), c)).join("\n")
- }
+ Either::Right(comments) => comments
+ .into_iter()
+ .map(|cm| line_comment_text(IndentLevel(0), cm))
+ .collect::<Vec<_>>()
+ .join("\n"),
};
let hashes = "#".repeat(required_hashes(&text));