@@ -31,8 +31,8 @@ use crate::{
31
31
//
32
32
// fn handle(action: Action) {
33
33
// match action {
34
- // $0Action::Move { distance } => {}
35
- // Action::Stop => {}
34
+ // $0Action::Move { distance } => todo!(),
35
+ // Action::Stop => todo!(),
36
36
// }
37
37
// }
38
38
// ```
@@ -129,7 +129,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<
129
129
|builder| {
130
130
let new_match_arm_list = match_arm_list. clone_for_update ( ) ;
131
131
let missing_arms = missing_pats
132
- . map ( |pat| make:: match_arm ( iter:: once ( pat) , make:: expr_empty_block ( ) ) )
132
+ . map ( |pat| make:: match_arm ( iter:: once ( pat) , make:: ext :: expr_todo ( ) ) )
133
133
. map ( |it| it. clone_for_update ( ) ) ;
134
134
135
135
let catch_all_arm = new_match_arm_list
@@ -350,8 +350,8 @@ fn foo(a: bool) {
350
350
r#"
351
351
fn foo(a: bool) {
352
352
match a {
353
- $0true => {}
354
- false => {}
353
+ $0true => todo!(),
354
+ false => todo!(),
355
355
}
356
356
}
357
357
"# ,
@@ -373,7 +373,7 @@ fn foo(a: bool) {
373
373
fn foo(a: bool) {
374
374
match a {
375
375
true => {}
376
- $0false => {}
376
+ $0false => todo!(),
377
377
}
378
378
}
379
379
"# ,
@@ -410,10 +410,10 @@ fn foo(a: bool) {
410
410
r#"
411
411
fn foo(a: bool) {
412
412
match (a, a) {
413
- $0(true, true) => {}
414
- (true, false) => {}
415
- (false, true) => {}
416
- (false, false) => {}
413
+ $0(true, true) => todo!(),
414
+ (true, false) => todo!(),
415
+ (false, true) => todo!(),
416
+ (false, false) => todo!(),
417
417
}
418
418
}
419
419
"# ,
@@ -435,9 +435,9 @@ fn foo(a: bool) {
435
435
fn foo(a: bool) {
436
436
match (a, a) {
437
437
(false, true) => {}
438
- $0(true, true) => {}
439
- (true, false) => {}
440
- (false, false) => {}
438
+ $0(true, true) => todo!(),
439
+ (true, false) => todo!(),
440
+ (false, false) => todo!(),
441
441
}
442
442
}
443
443
"# ,
@@ -471,7 +471,7 @@ fn main() {
471
471
match A::As {
472
472
A::Bs { x, y: Some(_) } => {}
473
473
A::Cs(_, Some(_)) => {}
474
- $0A::As => {}
474
+ $0A::As => todo!(),
475
475
}
476
476
}
477
477
"# ,
@@ -499,7 +499,7 @@ use Option::*;
499
499
fn main() {
500
500
match None {
501
501
None => {}
502
- Some(${0:_}) => {}
502
+ Some(${0:_}) => todo!(),
503
503
}
504
504
}
505
505
"# ,
@@ -523,7 +523,7 @@ enum A { As, Bs, Cs(Option<i32>) }
523
523
fn main() {
524
524
match A::As {
525
525
A::Cs(_) | A::Bs => {}
526
- $0A::As => {}
526
+ $0A::As => todo!(),
527
527
}
528
528
}
529
529
"# ,
@@ -553,8 +553,8 @@ fn main() {
553
553
A::Bs if 0 < 1 => {}
554
554
A::Ds(_value) => { let x = 1; }
555
555
A::Es(B::Xs) => (),
556
- $0A::As => {}
557
- A::Cs => {}
556
+ $0A::As => todo!(),
557
+ A::Cs => todo!(),
558
558
}
559
559
}
560
560
"# ,
@@ -580,7 +580,7 @@ fn main() {
580
580
match A::As {
581
581
A::As(_) => {}
582
582
a @ A::Bs(_) => {}
583
- A::Cs(${0:_}) => {}
583
+ A::Cs(${0:_}) => todo!(),
584
584
}
585
585
}
586
586
"# ,
@@ -605,11 +605,11 @@ enum A { As, Bs, Cs(String), Ds(String, String), Es { x: usize, y: usize } }
605
605
fn main() {
606
606
let a = A::As;
607
607
match a {
608
- $0A::As => {}
609
- A::Bs => {}
610
- A::Cs(_) => {}
611
- A::Ds(_, _) => {}
612
- A::Es { x, y } => {}
608
+ $0A::As => todo!(),
609
+ A::Bs => todo!(),
610
+ A::Cs(_) => todo!(),
611
+ A::Ds(_, _) => todo!(),
612
+ A::Es { x, y } => todo!(),
613
613
}
614
614
}
615
615
"# ,
@@ -638,10 +638,10 @@ fn main() {
638
638
let a = A::One;
639
639
let b = B::One;
640
640
match (a, b) {
641
- $0(A::One, B::One) => {}
642
- (A::One, B::Two) => {}
643
- (A::Two, B::One) => {}
644
- (A::Two, B::Two) => {}
641
+ $0(A::One, B::One) => todo!(),
642
+ (A::One, B::Two) => todo!(),
643
+ (A::Two, B::One) => todo!(),
644
+ (A::Two, B::Two) => todo!(),
645
645
}
646
646
}
647
647
"# ,
@@ -670,10 +670,10 @@ fn main() {
670
670
let a = A::One;
671
671
let b = B::One;
672
672
match (&a, &b) {
673
- $0(A::One, B::One) => {}
674
- (A::One, B::Two) => {}
675
- (A::Two, B::One) => {}
676
- (A::Two, B::Two) => {}
673
+ $0(A::One, B::One) => todo!(),
674
+ (A::One, B::Two) => todo!(),
675
+ (A::Two, B::One) => todo!(),
676
+ (A::Two, B::Two) => todo!(),
677
677
}
678
678
}
679
679
"# ,
@@ -705,9 +705,9 @@ fn main() {
705
705
let b = B::One;
706
706
match (a, b) {
707
707
(A::Two, B::One) => {}
708
- $0(A::One, B::One) => {}
709
- (A::One, B::Two) => {}
710
- (A::Two, B::Two) => {}
708
+ $0(A::One, B::One) => todo!(),
709
+ (A::One, B::Two) => todo!(),
710
+ (A::Two, B::Two) => todo!(),
711
711
}
712
712
}
713
713
"# ,
@@ -736,7 +736,7 @@ fn main() {
736
736
match (a, b) {
737
737
(Some(_), _) => {}
738
738
(None, Some(_)) => {}
739
- $0(None, None) => {}
739
+ $0(None, None) => todo!(),
740
740
}
741
741
}
742
742
"# ,
@@ -801,8 +801,8 @@ enum A { One, Two }
801
801
fn main() {
802
802
let a = A::One;
803
803
match (a, ) {
804
- $0(A::One,) => {}
805
- (A::Two,) => {}
804
+ $0(A::One,) => todo!(),
805
+ (A::Two,) => todo!(),
806
806
}
807
807
}
808
808
"# ,
@@ -826,7 +826,7 @@ enum A { As }
826
826
827
827
fn foo(a: &A) {
828
828
match a {
829
- $0A::As => {}
829
+ $0A::As => todo!(),
830
830
}
831
831
}
832
832
"# ,
@@ -851,7 +851,7 @@ enum A {
851
851
852
852
fn foo(a: &mut A) {
853
853
match a {
854
- $0A::Es { x, y } => {}
854
+ $0A::Es { x, y } => todo!(),
855
855
}
856
856
}
857
857
"# ,
@@ -891,8 +891,8 @@ enum E { X, Y }
891
891
892
892
fn main() {
893
893
match E::X {
894
- $0E::X => {}
895
- E::Y => {}
894
+ $0E::X => todo!(),
895
+ E::Y => todo!(),
896
896
}
897
897
}
898
898
"# ,
@@ -919,8 +919,8 @@ use foo::E::X;
919
919
920
920
fn main() {
921
921
match X {
922
- $0X => {}
923
- foo::E::Y => {}
922
+ $0X => todo!(),
923
+ foo::E::Y => todo!(),
924
924
}
925
925
}
926
926
"# ,
@@ -947,7 +947,7 @@ fn foo(a: A) {
947
947
match a {
948
948
// foo bar baz
949
949
A::One => {}
950
- $0A::Two => {}
950
+ $0A::Two => todo!(),
951
951
// This is where the rest should be
952
952
}
953
953
}
@@ -971,8 +971,8 @@ fn foo(a: A) {
971
971
enum A { One, Two }
972
972
fn foo(a: A) {
973
973
match a {
974
- $0A::One => {}
975
- A::Two => {}
974
+ $0A::One => todo!(),
975
+ A::Two => todo!(),
976
976
// foo bar baz
977
977
}
978
978
}
@@ -996,8 +996,8 @@ fn foo(a: A) {
996
996
enum A { One, Two, }
997
997
fn foo(a: A) {
998
998
match a {
999
- $0A::One => {}
1000
- A::Two => {}
999
+ $0A::One => todo!(),
1000
+ A::Two => todo!(),
1001
1001
}
1002
1002
}
1003
1003
"# ,
@@ -1021,8 +1021,8 @@ fn foo(opt: Option<i32>) {
1021
1021
r#"
1022
1022
fn foo(opt: Option<i32>) {
1023
1023
match opt {
1024
- Some(${0:_}) => {}
1025
- None => {}
1024
+ Some(${0:_}) => todo!(),
1025
+ None => todo!(),
1026
1026
}
1027
1027
}
1028
1028
"# ,
@@ -1054,9 +1054,9 @@ enum Test {
1054
1054
1055
1055
fn foo(t: Test) {
1056
1056
m!(match t {
1057
- $0Test::A => {}
1058
- Test::B => {}
1059
- Test::C => {}
1057
+ $0Test::A => todo!(),
1058
+ Test::B => todo!(),
1059
+ Test::C => todo!(),
1060
1060
});
1061
1061
}"# ,
1062
1062
) ;
@@ -1076,4 +1076,44 @@ fn foo(tuple: (A, A)) {
1076
1076
"# ,
1077
1077
) ;
1078
1078
}
1079
+
1080
+ #[ test]
1081
+ fn adds_comma_before_new_arms ( ) {
1082
+ check_assist (
1083
+ fill_match_arms,
1084
+ r#"
1085
+ fn foo(t: bool) {
1086
+ match $0t {
1087
+ true => 1 + 2
1088
+ }
1089
+ }"# ,
1090
+ r#"
1091
+ fn foo(t: bool) {
1092
+ match t {
1093
+ true => 1 + 2,
1094
+ $0false => todo!(),
1095
+ }
1096
+ }"# ,
1097
+ ) ;
1098
+ }
1099
+
1100
+ #[ test]
1101
+ fn does_not_add_extra_comma ( ) {
1102
+ check_assist (
1103
+ fill_match_arms,
1104
+ r#"
1105
+ fn foo(t: bool) {
1106
+ match $0t {
1107
+ true => 1 + 2,
1108
+ }
1109
+ }"# ,
1110
+ r#"
1111
+ fn foo(t: bool) {
1112
+ match t {
1113
+ true => 1 + 2,
1114
+ $0false => todo!(),
1115
+ }
1116
+ }"# ,
1117
+ ) ;
1118
+ }
1079
1119
}
0 commit comments