@@ -60,6 +60,7 @@ pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext<'_>)
6060enum PathParent {
6161 PathExpr ( ast:: PathExpr ) ,
6262 RecordExpr ( ast:: RecordExpr ) ,
63+ PathPat ( ast:: PathPat ) ,
6364 UseTree ( ast:: UseTree ) ,
6465}
6566
@@ -68,6 +69,7 @@ impl PathParent {
6869 match self {
6970 PathParent :: PathExpr ( it) => it. syntax ( ) ,
7071 PathParent :: RecordExpr ( it) => it. syntax ( ) ,
72+ PathParent :: PathPat ( it) => it. syntax ( ) ,
7173 PathParent :: UseTree ( it) => it. syntax ( ) ,
7274 }
7375 }
@@ -84,7 +86,7 @@ impl PathParent {
8486 }
8587 }
8688 PathParent :: RecordExpr ( it) => make_record_field_list ( it, ctx, & scope) ,
87- PathParent :: UseTree ( _) => None ,
89+ PathParent :: UseTree ( _) | PathParent :: PathPat ( _ ) => None ,
8890 }
8991 }
9092}
@@ -96,6 +98,7 @@ fn path_parent(path: &ast::Path) -> Option<PathParent> {
9698 match parent {
9799 ast:: PathExpr ( it) => Some ( PathParent :: PathExpr ( it) ) ,
98100 ast:: RecordExpr ( it) => Some ( PathParent :: RecordExpr ( it) ) ,
101+ ast:: PathPat ( it) => Some ( PathParent :: PathPat ( it) ) ,
99102 ast:: UseTree ( it) => Some ( PathParent :: UseTree ( it) ) ,
100103 _ => None
101104 }
@@ -530,6 +533,31 @@ enum Foo {
530533 r"
531534enum Foo {}
532535impl 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+ }
533561" ,
534562 )
535563 }
0 commit comments