@@ -152,6 +152,12 @@ extern char *yytext;
152
152
%precedence MOD_SEP
153
153
%precedence RARROW ':'
154
154
155
+ // In where clauses, "for" should have greater precedence when used as
156
+ // a higher ranked constraint than when used as the beginning of a
157
+ // for_in_type (which is a ty)
158
+ %precedence FORTYPE
159
+ %precedence FOR
160
+
155
161
// Binops & unops, and their precedences
156
162
%precedence BOX
157
163
%precedence BOXPLACE
@@ -582,6 +588,14 @@ item_impl
582
588
{
583
589
$$ = mk_node("ItemImplNeg", 7, $1, $3, $5, $7, $8, $10, $11);
584
590
}
591
+ | maybe_unsafe IMPL generic_params trait_ref FOR DOTDOT '{' '}'
592
+ {
593
+ $$ = mk_node("ItemImplDefault", 3, $1, $3, $4);
594
+ }
595
+ | maybe_unsafe IMPL generic_params '!' trait_ref FOR DOTDOT '{' '}'
596
+ {
597
+ $$ = mk_node("ItemImplDefaultNeg", 3, $1, $3, $4);
598
+ }
585
599
;
586
600
587
601
maybe_impl_items
@@ -769,10 +783,14 @@ where_predicates
769
783
;
770
784
771
785
where_predicate
772
- : lifetime ':' bounds { $$ = mk_node("WherePredicate", 2 , $1, $3 ); }
773
- | ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 2 , $1, $3 ); }
786
+ : maybe_for_lifetimes lifetime ':' bounds { $$ = mk_node("WherePredicate", 3 , $1, $2, $4 ); }
787
+ | maybe_for_lifetimes ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 3 , $1, $2, $4 ); }
774
788
;
775
789
790
+ maybe_for_lifetimes
791
+ : FOR '<' lifetimes '>' { $$ = mk_none(); }
792
+ | %prec FORTYPE %empty { $$ = mk_none(); }
793
+
776
794
ty_params
777
795
: ty_param { $$ = mk_node("TyParams", 1, $1); }
778
796
| ty_params ',' ty_param { $$ = ext_node($1, 1, $3); }
@@ -1024,7 +1042,8 @@ ty_qualified_path_and_generic_values
1024
1042
}
1025
1043
| ty_qualified_path ',' ty_sums maybe_bindings
1026
1044
{
1027
- $$ = mk_node("GenericValues", 3, mk_none(), ext_node(mk_node("TySums", 1, $1), 1, $3), $4); }
1045
+ $$ = mk_node("GenericValues", 3, mk_none(), mk_node("TySums", 2, $1, $3), $4);
1046
+ }
1028
1047
;
1029
1048
1030
1049
ty_qualified_path
@@ -1513,31 +1532,35 @@ nonblock_prefix_expr
1513
1532
;
1514
1533
1515
1534
expr_qualified_path
1516
- : '<' ty_sum AS trait_ref '>' MOD_SEP ident
1535
+ : '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident
1517
1536
{
1518
- $$ = mk_node("ExprQualifiedPath", 3, $2, $4 , $7 );
1537
+ $$ = mk_node("ExprQualifiedPath", 3, $2, $3 , $6 );
1519
1538
}
1520
- | '<' ty_sum AS trait_ref '>' MOD_SEP ident generic_args
1539
+ | '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args
1521
1540
{
1522
- $$ = mk_node("ExprQualifiedPath", 4, $2, $4 , $7 , $8 );
1541
+ $$ = mk_node("ExprQualifiedPath", 4, $2, $3 , $6 , $7 );
1523
1542
}
1524
- | SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident
1543
+ | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
1525
1544
{
1526
- $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $4 , $7 ), $9 , $12 );
1545
+ $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $3 , $6 ), $7 , $10 );
1527
1546
}
1528
- | SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident
1547
+ | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident
1529
1548
{
1530
- $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $4 , $7 , $8 ), $10 , $13 );
1549
+ $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $3 , $6 , $7 ), $8 , $11 );
1531
1550
}
1532
- | SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident generic_args
1551
+ | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident generic_args
1533
1552
{
1534
- $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $4 , $7 ), $9 , $12 , $13 );
1553
+ $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $3 , $6 ), $7 , $10 , $11 );
1535
1554
}
1536
- | SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident generic_args
1555
+ | SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident generic_args
1537
1556
{
1538
- $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $4 , $7 , $8 ), $10 , $13 , $14 );
1557
+ $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $3 , $6 , $7 ), $8 , $11 , $12 );
1539
1558
}
1540
1559
1560
+ maybe_as_trait_ref
1561
+ : AS trait_ref { $$ = $2; }
1562
+ | %empty { $$ = mk_none(); }
1563
+ ;
1541
1564
1542
1565
lambda_expr
1543
1566
: %prec LAMBDA
0 commit comments