@@ -60,6 +60,7 @@ pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext<'_>)
60
60
enum PathParent {
61
61
PathExpr ( ast:: PathExpr ) ,
62
62
RecordExpr ( ast:: RecordExpr ) ,
63
+ PathPat ( ast:: PathPat ) ,
63
64
UseTree ( ast:: UseTree ) ,
64
65
}
65
66
@@ -68,6 +69,7 @@ impl PathParent {
68
69
match self {
69
70
PathParent :: PathExpr ( it) => it. syntax ( ) ,
70
71
PathParent :: RecordExpr ( it) => it. syntax ( ) ,
72
+ PathParent :: PathPat ( it) => it. syntax ( ) ,
71
73
PathParent :: UseTree ( it) => it. syntax ( ) ,
72
74
}
73
75
}
@@ -84,7 +86,7 @@ impl PathParent {
84
86
}
85
87
}
86
88
PathParent :: RecordExpr ( it) => make_record_field_list ( it, ctx, & scope) ,
87
- PathParent :: UseTree ( _) => None ,
89
+ PathParent :: UseTree ( _) | PathParent :: PathPat ( _ ) => None ,
88
90
}
89
91
}
90
92
}
@@ -96,6 +98,7 @@ fn path_parent(path: &ast::Path) -> Option<PathParent> {
96
98
match parent {
97
99
ast:: PathExpr ( it) => Some ( PathParent :: PathExpr ( it) ) ,
98
100
ast:: RecordExpr ( it) => Some ( PathParent :: RecordExpr ( it) ) ,
101
+ ast:: PathPat ( it) => Some ( PathParent :: PathPat ( it) ) ,
99
102
ast:: UseTree ( it) => Some ( PathParent :: UseTree ( it) ) ,
100
103
_ => None
101
104
}
@@ -530,6 +533,31 @@ enum Foo {
530
533
r"
531
534
enum Foo {}
532
535
impl Foo::Bar$0 {}
536
+ " ,
537
+ )
538
+ }
539
+
540
+ #[ test]
541
+ fn path_pat ( ) {
542
+ check_assist (
543
+ generate_enum_variant,
544
+ r"
545
+ enum Foo {}
546
+ fn foo(x: Foo) {
547
+ match x {
548
+ Foo::Bar$0 =>
549
+ }
550
+ }
551
+ " ,
552
+ r"
553
+ enum Foo {
554
+ Bar,
555
+ }
556
+ fn foo(x: Foo) {
557
+ match x {
558
+ Foo::Bar =>
559
+ }
560
+ }
533
561
" ,
534
562
)
535
563
}
0 commit comments