@@ -289,16 +289,16 @@ item_const
289
289
;
290
290
291
291
item_macro
292
- : path_expr '!' maybe_ident parens_delimited_token_trees ';'
293
- | path_expr '!' maybe_ident braces_delimited_token_trees
294
- | path_expr '!' maybe_ident brackets_delimited_token_trees ';'
292
+ : path_expr '!' maybe_ident parens_delimited_token_trees ';' { $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
293
+ | path_expr '!' maybe_ident braces_delimited_token_trees { $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
294
+ | path_expr '!' maybe_ident brackets_delimited_token_trees ';'{ $$ = mk_node("ItemMacro", 3, $1, $3, $4); }
295
295
;
296
296
297
297
view_item
298
298
: use_item
299
299
| extern_fn_item
300
300
| EXTERN CRATE ident ';' { $$ = mk_node("ViewItemExternCrate", 1, $3); }
301
- | EXTERN CRATE str AS ident ';' { $$ = mk_node("ViewItemExternCrate", 2, $3, $5); }
301
+ | EXTERN CRATE ident AS ident ';' { $$ = mk_node("ViewItemExternCrate", 2, $3, $5); }
302
302
;
303
303
304
304
extern_fn_item
@@ -312,8 +312,11 @@ use_item
312
312
view_path
313
313
: path_no_types_allowed { $$ = mk_node("ViewPathSimple", 1, $1); }
314
314
| path_no_types_allowed MOD_SEP '{' '}' { $$ = mk_node("ViewPathList", 2, $1, mk_atom("ViewPathListEmpty")); }
315
+ | MOD_SEP '{' '}' { $$ = mk_node("ViewPathList", 1, mk_atom("ViewPathListEmpty")); }
315
316
| path_no_types_allowed MOD_SEP '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 2, $1, $4); }
317
+ | MOD_SEP '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 1, $3); }
316
318
| path_no_types_allowed MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 2, $1, $4); }
319
+ | MOD_SEP '{' idents_or_self ',' '}' { $$ = mk_node("ViewPathList", 1, $3); }
317
320
| path_no_types_allowed MOD_SEP '*' { $$ = mk_node("ViewPathGlob", 1, $1); }
318
321
| '{' '}' { $$ = mk_atom("ViewPathListEmpty"); }
319
322
| '{' idents_or_self '}' { $$ = mk_node("ViewPathList", 1, $2); }
@@ -333,7 +336,7 @@ block_item
333
336
;
334
337
335
338
maybe_ty_ascription
336
- : ':' ty { $$ = $2; }
339
+ : ':' ty_sum { $$ = $2; }
337
340
| %empty { $$ = mk_none(); }
338
341
;
339
342
@@ -511,7 +514,7 @@ trait_item
511
514
;
512
515
513
516
trait_const
514
- : maybe_outer_attrs CONST ident maybe_const_default ';' { $$ = mk_node("ConstTraitItem", 3 , $1, $3, $4); }
517
+ : maybe_outer_attrs CONST ident maybe_ty_ascription maybe_const_default ';' { $$ = mk_node("ConstTraitItem", 4 , $1, $3, $4, $5 ); }
515
518
;
516
519
517
520
maybe_const_default
@@ -590,11 +593,11 @@ item_impl
590
593
{
591
594
$$ = mk_node("ItemImpl", 6, $1, $3, 5, $6, $9, $10);
592
595
}
593
- | maybe_unsafe IMPL generic_params trait_ref FOR ty maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
596
+ | maybe_unsafe IMPL generic_params trait_ref FOR ty_sum maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
594
597
{
595
598
$$ = mk_node("ItemImpl", 6, $3, $4, $6, $7, $9, $10);
596
599
}
597
- | maybe_unsafe IMPL generic_params '!' trait_ref FOR ty maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
600
+ | maybe_unsafe IMPL generic_params '!' trait_ref FOR ty_sum maybe_where_clause '{' maybe_inner_attrs maybe_impl_items '}'
598
601
{
599
602
$$ = mk_node("ItemImplNeg", 7, $1, $3, $5, $7, $8, $10, $11);
600
603
}
@@ -620,7 +623,7 @@ impl_items
620
623
621
624
impl_item
622
625
: impl_method
623
- | item_macro
626
+ | attrs_and_vis item_macro { $$ = mk_node("ImplMacroItem", 2, $1, $2); }
624
627
| impl_const
625
628
| impl_type
626
629
;
@@ -698,7 +701,7 @@ params
698
701
;
699
702
700
703
param
701
- : pat ':' ty { $$ = mk_node("Arg", 2, $1, $3); }
704
+ : pat ':' ty_sum { $$ = mk_node("Arg", 2, $1, $3); }
702
705
;
703
706
704
707
inferrable_params
909
912
| ident '@' pat { $$ = mk_node("PatIdent", 3, mk_node("BindByValue", 1, mk_atom("MutImmutable")), $1, $3); }
910
913
| binding_mode ident '@' pat { $$ = mk_node("PatIdent", 3, $1, $2, $4); }
911
914
| BOX pat { $$ = mk_node("PatUniq", 1, $2); }
915
+ | '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("PatQualifiedPath", 3, $2, $3, $6); }
916
+ | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
917
+ {
918
+ $$ = mk_node("PatQualifiedPath", 3, mk_node("PatQualifiedPath", 3, $2, $3, $6), $7, $10);
919
+ }
912
920
;
913
921
914
922
pats_or
@@ -981,11 +989,11 @@ pat_vec_elts
981
989
ty
982
990
: ty_prim
983
991
| ty_closure
984
- | '<' ty_sum AS trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, $2, $4 , $7 ); }
985
- | SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, mk_node("TyQualifiedPath", 3, $2, $4 , $7 ), $9 , $12 ); }
986
- | '(' ty_sums ')' { $$ = mk_node("TyTup", 1, $2); }
987
- | '(' ty_sums ',' ')' { $$ = mk_node("TyTup", 1, $2); }
988
- | '(' ')' { $$ = mk_atom("TyNil"); }
992
+ | '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, $2, $3 , $6 ); }
993
+ | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident { $$ = mk_node("TyQualifiedPath", 3, mk_node("TyQualifiedPath", 3, $2, $3 , $6 ), $7 , $10 ); }
994
+ | '(' ty_sums ')' { $$ = mk_node("TyTup", 1, $2); }
995
+ | '(' ty_sums ',' ')' { $$ = mk_node("TyTup", 1, $2); }
996
+ | '(' ')' { $$ = mk_atom("TyNil"); }
989
997
;
990
998
991
999
ty_prim
@@ -1551,11 +1559,7 @@ nonblock_prefix_expr
1551
1559
;
1552
1560
1553
1561
expr_qualified_path
1554
- : '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident
1555
- {
1556
- $$ = mk_node("ExprQualifiedPath", 3, $2, $3, $6);
1557
- }
1558
- | '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args
1562
+ : '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_qpath_params
1559
1563
{
1560
1564
$$ = mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7);
1561
1565
}
@@ -1576,6 +1580,11 @@ expr_qualified_path
1576
1580
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11, $12);
1577
1581
}
1578
1582
1583
+ maybe_qpath_params
1584
+ : MOD_SEP generic_args { $$ = $2; }
1585
+ | %empty { $$ = mk_none(); }
1586
+ ;
1587
+
1579
1588
maybe_as_trait_ref
1580
1589
: AS trait_ref { $$ = $2; }
1581
1590
| %empty { $$ = mk_none(); }
@@ -1666,8 +1675,10 @@ block_expr
1666
1675
1667
1676
full_block_expr
1668
1677
: block_expr
1669
- | full_block_expr '.' path_generic_args_with_colons { $$ = mk_node("ExprField", 2, $1, $3); }
1670
- | full_block_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
1678
+ | full_block_expr '.' path_generic_args_with_colons %prec IDENT { $$ = mk_node("ExprField", 2, $1, $3); }
1679
+ | full_block_expr '.' path_generic_args_with_colons '[' maybe_expr ']' { $$ = mk_node("ExprIndex", 3, $1, $3, $5); }
1680
+ | full_block_expr '.' path_generic_args_with_colons '(' maybe_exprs ')' { $$ = mk_node("ExprCall", 3, $1, $3, $5); }
1681
+ | full_block_expr '.' LIT_INTEGER { $$ = mk_node("ExprTupleIndex", 1, $1); }
1671
1682
;
1672
1683
1673
1684
expr_match
0 commit comments