@@ -163,13 +163,18 @@ pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContex
163
163
edit. insert ( then_arm_end, format ! ( "\n {}{} => " , spaces, match_pat) ) ;
164
164
match & else_block. tail_expr ( ) {
165
165
Some ( else_expr) if else_only_expr => {
166
+ cov_mark:: hit!( move_guard_ifelse_expr_only) ;
166
167
edit. insert ( then_arm_end, else_expr. syntax ( ) . text ( ) ) ;
167
168
edit. insert ( then_arm_end, "," ) ;
168
169
}
169
170
_ if replace_node != * if_expr. syntax ( ) => {
171
+ cov_mark:: hit!( move_guard_ifelse_in_block) ;
170
172
edit. insert ( then_arm_end, else_block. dedent ( 1 . into ( ) ) . syntax ( ) . text ( ) ) ;
171
173
}
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
+ }
173
178
}
174
179
}
175
180
} ,
@@ -441,6 +446,7 @@ fn main() {
441
446
442
447
#[ test]
443
448
fn move_arm_cond_to_match_guard_with_else_block_works ( ) {
449
+ cov_mark:: check!( move_guard_ifelse_expr_only) ;
444
450
check_assist (
445
451
move_arm_cond_to_match_guard,
446
452
r#"
@@ -527,6 +533,40 @@ fn main() {
527
533
528
534
#[ test]
529
535
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) ;
530
570
check_assist (
531
571
move_arm_cond_to_match_guard,
532
572
r#"
0 commit comments