Skip to content

Commit e6b6401

Browse files
committed
feat: allow generics in tuple struct patterns
1 parent 97b4e66 commit e6b6401

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

grammar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,7 @@ module.exports = grammar({
13641364
field('type', choice(
13651365
$.identifier,
13661366
$.scoped_identifier,
1367+
alias($.generic_type_with_turbofish, $.generic_type),
13671368
)),
13681369
'(',
13691370
sepBy(',', $._pattern),

test/corpus/patterns.txt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ match x {
7979
Person{name: adult_name, age: _} => ("adult", adult_name),
8080
}
8181

82+
match y {
83+
Bar::T1(_, Some::<isize>(x)) => println!("{x}"),
84+
}
85+
8286
--------------------------------------------------------------------------------
8387

8488
(source_file
@@ -113,7 +117,28 @@ match x {
113117
(tuple_expression
114118
(string_literal
115119
(string_content))
116-
(identifier)))))))
120+
(identifier))))))
121+
(expression_statement
122+
(match_expression
123+
(identifier)
124+
(match_block
125+
(match_arm
126+
(match_pattern
127+
(tuple_struct_pattern
128+
(scoped_identifier
129+
(identifier)
130+
(identifier))
131+
(tuple_struct_pattern
132+
(generic_type
133+
(type_identifier)
134+
(type_arguments
135+
(primitive_type)))
136+
(identifier))))
137+
(macro_invocation
138+
(identifier)
139+
(token_tree
140+
(string_literal
141+
(string_content)))))))))
117142

118143
================================================================================
119144
Ignored patterns

0 commit comments

Comments
 (0)