Skip to content

Commit b6a14ce

Browse files
committed
fix doc test.
1 parent edb9ad2 commit b6a14ce

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

crates/ide-assists/src/handlers/merge_nested_if.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ use crate::{
88
assist_context::{AssistContext, Assists},
99
AssistId, AssistKind,
1010
};
11-
/// Assist: merge_nested_if
12-
///
13-
/// This transforms if expressions of the form `if x { if y {A} }` into `if x && y {A}`
14-
/// This assist can only be applied with the cursor on `if`.
15-
///
16-
/// ```
17-
/// fn main() {
18-
/// i$0f x == 3 { if y == 4 { 1 } }
19-
/// }
20-
/// ```
21-
/// ->
22-
/// ```
23-
/// fn main() {
24-
/// if x == 3 && y == 4 { 1 }
25-
/// }
26-
/// ```
11+
// Assist: merge_nested_if
12+
//
13+
// This transforms if expressions of the form `if x { if y {A} }` into `if x && y {A}`
14+
// This assist can only be applied with the cursor on `if`.
15+
//
16+
// ```
17+
// fn main() {
18+
// i$0f x == 3 { if y == 4 { 1 } }
19+
// }
20+
// ```
21+
// ->
22+
// ```
23+
// fn main() {
24+
// if x == 3 && y == 4 { 1 }
25+
// }
26+
// ```
2727
pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
2828
let if_keyword = ctx.find_token_syntax_at_offset(T![if])?;
2929
let expr = ast::IfExpr::cast(if_keyword.parent()?)?;

crates/ide-assists/src/tests/generated.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -2056,13 +2056,15 @@ fn doctest_merge_nested_if() {
20562056
check_doc_test(
20572057
"merge_nested_if",
20582058
r#####"
2059-
fn main() {
2060-
i$0f x == 3 { if y == 4 { 1 } }
2061-
}"#####,
2059+
fn main() {
2060+
i$0f x == 3 { if y == 4 { 1 } }
2061+
}
2062+
"#####,
20622063
r#####"
2063-
fn main() {
2064-
if x == 3 && y == 4 { 1 }
2065-
}"#####,
2064+
fn main() {
2065+
if x == 3 && y == 4 { 1 }
2066+
}
2067+
"#####,
20662068
)
20672069
}
20682070

0 commit comments

Comments
 (0)