Skip to content

Commit e8d0742

Browse files
committed
Add coverage marks
1 parent 95a0de8 commit e8d0742

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

crates/ide_assists/src/handlers/move_guard.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,18 @@ pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContex
163163
edit.insert(then_arm_end, format!("\n{}{} => ", spaces, match_pat));
164164
match &else_block.tail_expr() {
165165
Some(else_expr) if else_only_expr => {
166+
cov_mark::hit!(move_guard_ifelse_expr_only);
166167
edit.insert(then_arm_end, else_expr.syntax().text());
167168
edit.insert(then_arm_end, ",");
168169
}
169170
_ if replace_node != *if_expr.syntax() => {
171+
cov_mark::hit!(move_guard_ifelse_in_block);
170172
edit.insert(then_arm_end, else_block.dedent(1.into()).syntax().text());
171173
}
172-
_ => edit.insert(then_arm_end, else_block.syntax().text()),
174+
_ => {
175+
cov_mark::hit!(move_guard_ifelse_else_block);
176+
edit.insert(then_arm_end, else_block.syntax().text());
177+
}
173178
}
174179
}
175180
},
@@ -441,6 +446,7 @@ fn main() {
441446

442447
#[test]
443448
fn move_arm_cond_to_match_guard_with_else_block_works() {
449+
cov_mark::check!(move_guard_ifelse_expr_only);
444450
check_assist(
445451
move_arm_cond_to_match_guard,
446452
r#"
@@ -527,6 +533,40 @@ fn main() {
527533

528534
#[test]
529535
fn move_arm_cond_to_match_guard_with_else_multiline_else_works() {
536+
cov_mark::check!(move_guard_ifelse_else_block);
537+
check_assist(
538+
move_arm_cond_to_match_guard,
539+
r#"
540+
fn main() {
541+
match 92 {
542+
x => if x > 10 {$0
543+
false
544+
} else {
545+
42;
546+
true
547+
}
548+
_ => true
549+
}
550+
}
551+
"#,
552+
r#"
553+
fn main() {
554+
match 92 {
555+
x if x > 10 => false,
556+
x => {
557+
42;
558+
true
559+
}
560+
_ => true
561+
}
562+
}
563+
"#,
564+
)
565+
}
566+
567+
#[test]
568+
fn move_arm_cond_to_match_guard_with_else_multiline_else_block_works() {
569+
cov_mark::check!(move_guard_ifelse_in_block);
530570
check_assist(
531571
move_arm_cond_to_match_guard,
532572
r#"

0 commit comments

Comments
 (0)