about summary refs log tree commit diff
diff options
context:
space:
mode:
authorl1nxy <l1nxy.zy@gmail.com>2024-01-01 22:11:45 +0800
committerl1nxy <l1nxy.zy@gmail.com>2024-01-01 22:11:45 +0800
commitb6a14ce5b8d1081ea330a0b85733fc6b646dfa33 (patch)
treefcef1c29c3d928c69ee3d82b4ab389392f5efa95
parentedb9ad21bd8f0a692d100f6d3282e2b442fabc64 (diff)
downloadrust-b6a14ce5b8d1081ea330a0b85733fc6b646dfa33.tar.gz
rust-b6a14ce5b8d1081ea330a0b85733fc6b646dfa33.zip
fix doc test.
-rw-r--r--crates/ide-assists/src/handlers/merge_nested_if.rs32
-rw-r--r--crates/ide-assists/src/tests/generated.rs14
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 }
+}
+"#####,
     )
 }