From b6a14ce5b8d1081ea330a0b85733fc6b646dfa33 Mon Sep 17 00:00:00 2001 From: l1nxy Date: Mon, 1 Jan 2024 22:11:45 +0800 Subject: [PATCH] fix doc test. --- .../src/handlers/merge_nested_if.rs | 32 +++++++++---------- crates/ide-assists/src/tests/generated.rs | 14 ++++---- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/crates/ide-assists/src/handlers/merge_nested_if.rs b/crates/ide-assists/src/handlers/merge_nested_if.rs index 39db42faaea..206bc3e08be 100644 --- a/crates/ide-assists/src/handlers/merge_nested_if.rs +++ b/crates/ide-assists/src/handlers/merge_nested_if.rs @@ -8,22 +8,22 @@ use crate::{ assist_context::{AssistContext, Assists}, AssistId, AssistKind, }; -/// Assist: merge_nested_if -/// -/// This transforms if expressions of the form `if x { if y {A} }` into `if x && y {A}` -/// This assist can only be applied with the cursor on `if`. -/// -/// ``` -/// fn main() { -/// i$0f x == 3 { if y == 4 { 1 } } -/// } -/// ``` -/// -> -/// ``` -/// fn main() { -/// if x == 3 && y == 4 { 1 } -/// } -/// ``` +// Assist: merge_nested_if +// +// This transforms if expressions of the form `if x { if y {A} }` into `if x && y {A}` +// This assist can only be applied with the cursor on `if`. +// +// ``` +// fn main() { +// i$0f x == 3 { if y == 4 { 1 } } +// } +// ``` +// -> +// ``` +// fn main() { +// if x == 3 && y == 4 { 1 } +// } +// ``` pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> { let if_keyword = ctx.find_token_syntax_at_offset(T![if])?; let expr = ast::IfExpr::cast(if_keyword.parent()?)?; diff --git a/crates/ide-assists/src/tests/generated.rs b/crates/ide-assists/src/tests/generated.rs index 79958a2292f..d8b3b32a1ab 100644 --- a/crates/ide-assists/src/tests/generated.rs +++ b/crates/ide-assists/src/tests/generated.rs @@ -2056,13 +2056,15 @@ fn doctest_merge_nested_if() { check_doc_test( "merge_nested_if", r#####" - fn main() { - i$0f x == 3 { if y == 4 { 1 } } - }"#####, +fn main() { + i$0f x == 3 { if y == 4 { 1 } } +} +"#####, r#####" - fn main() { - if x == 3 && y == 4 { 1 } - }"#####, +fn main() { + if x == 3 && y == 4 { 1 } +} +"#####, ) }