File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
naga/src/front/wgsl/parse Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -2121,7 +2121,7 @@ impl Parser {
2121
2121
let _ = lexer. next ( ) ;
2122
2122
this. pop_rule_span ( lexer) ;
2123
2123
}
2124
- ( Token :: Paren ( '{' ) | Token :: Attribute , _) => {
2124
+ ( token , _) if is_start_of_compound_statement ( token ) => {
2125
2125
let ( inner, span) = this. block ( lexer, ctx, brace_nesting_level) ?;
2126
2126
block. stmts . push ( ast:: Statement {
2127
2127
kind : ast:: StatementKind :: Block ( inner) ,
@@ -2288,13 +2288,10 @@ impl Parser {
2288
2288
let value = this. switch_value ( lexer, ctx) ?;
2289
2289
if lexer. skip ( Token :: Separator ( ',' ) ) {
2290
2290
// list of values ends with ':' or a compound statement
2291
- // indicated by an attribute or '{'
2292
- if matches ! (
2293
- lexer. peek( ) . 0 ,
2294
- Token :: Separator ( ':' )
2295
- | Token :: Attribute
2296
- | Token :: Paren ( '{' )
2297
- ) {
2291
+ let next_token = lexer. peek ( ) . 0 ;
2292
+ if next_token == Token :: Separator ( ':' )
2293
+ || is_start_of_compound_statement ( next_token)
2294
+ {
2298
2295
break value;
2299
2296
}
2300
2297
} else {
@@ -3252,3 +3249,7 @@ impl Parser {
3252
3249
} )
3253
3250
}
3254
3251
}
3252
+
3253
+ const fn is_start_of_compound_statement < ' a > ( token : Token < ' a > ) -> bool {
3254
+ matches ! ( token, Token :: Attribute | Token :: Paren ( '{' ) )
3255
+ }
You can’t perform that action at this time.
0 commit comments