Skip to content

Commit 56144af

Browse files
committed
fix: allow inner attribute items in match arms
1 parent 016ee9f commit 56144af

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

grammar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ module.exports = grammar({
11901190
),
11911191

11921192
match_arm: $ => prec.right(seq(
1193-
repeat($.attribute_item),
1193+
repeat(choice($.attribute_item, $.inner_attribute_item)),
11941194
field('pattern', $.match_pattern),
11951195
'=>',
11961196
choice(
@@ -1200,7 +1200,7 @@ module.exports = grammar({
12001200
)),
12011201

12021202
last_match_arm: $ => seq(
1203-
repeat($.attribute_item),
1203+
repeat(choice($.attribute_item, $.inner_attribute_item)),
12041204
field('pattern', $.match_pattern),
12051205
'=>',
12061206
field('value', $._expression),

test/corpus/declarations.txt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,11 @@ mod macos_only {
11011101
#![cfg(target_os = "macos")]
11021102
}
11031103

1104+
match ty {
1105+
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
1106+
syn::Type::Array(ty) => self.visit_type(&ty.elem),
1107+
}
1108+
11041109
--------------------------------------------------------------------------------
11051110

11061111
(source_file
@@ -1112,7 +1117,41 @@ mod macos_only {
11121117
(identifier)
11131118
arguments: (token_tree
11141119
(identifier)
1115-
(string_literal)))))))
1120+
(string_literal
1121+
(string_content)))))))
1122+
(expression_statement
1123+
(match_expression
1124+
value: (identifier)
1125+
body: (match_block
1126+
(match_arm
1127+
(inner_attribute_item
1128+
(attribute
1129+
(identifier)
1130+
arguments: (token_tree
1131+
(identifier)
1132+
(token_tree
1133+
(identifier)
1134+
(identifier))
1135+
(identifier)
1136+
(token_tree
1137+
(identifier)))))
1138+
pattern: (match_pattern
1139+
(tuple_struct_pattern
1140+
type: (scoped_identifier
1141+
path: (scoped_identifier
1142+
path: (identifier)
1143+
name: (identifier))
1144+
name: (identifier))
1145+
(identifier)))
1146+
value: (call_expression
1147+
function: (field_expression
1148+
value: (self)
1149+
field: (field_identifier))
1150+
arguments: (arguments
1151+
(reference_expression
1152+
value: (field_expression
1153+
value: (identifier)
1154+
field: (field_identifier))))))))))
11161155

11171156
================================================================================
11181157
Key-Value Attribute Expressions

0 commit comments

Comments
 (0)