@@ -171,11 +171,15 @@ import qualified Data.List.NonEmpty as N
171
171
172
172
-- Strict keywords used in the language
173
173
as { Spanned (IdentTok " as" ) _ }
174
+ async { Spanned (IdentTok " async" ) _ }
175
+ await { Spanned (IdentTok " await" ) _ }
174
176
box { Spanned (IdentTok " box" ) _ }
175
177
break { Spanned (IdentTok " break" ) _ }
176
178
const { Spanned (IdentTok " const" ) _ }
177
179
continue { Spanned (IdentTok " continue" ) _ }
178
180
crate { Spanned (IdentTok " crate" ) _ }
181
+ do { Spanned (IdentTok " do" ) _ }
182
+ dyn { Spanned (IdentTok " dyn" ) _ }
179
183
else { Spanned (IdentTok " else" ) _ }
180
184
enum { Spanned (IdentTok " enum" ) _ }
181
185
extern { Spanned (IdentTok " extern" ) _ }
@@ -201,12 +205,13 @@ import qualified Data.List.NonEmpty as N
201
205
super { Spanned (IdentTok " super" ) _ }
202
206
trait { Spanned (IdentTok " trait" ) _ }
203
207
true { Spanned (IdentTok " true" ) _ }
208
+ try { Spanned (IdentTok " try" ) _ }
204
209
type { Spanned (IdentTok " type" ) _ }
205
210
unsafe { Spanned (IdentTok " unsafe" ) _ }
206
211
use { Spanned (IdentTok " use" ) _ }
207
212
where { Spanned (IdentTok " where" ) _ }
208
213
while { Spanned (IdentTok " while" ) _ }
209
- do { Spanned (IdentTok " do " ) _ }
214
+ yield { Spanned (IdentTok " yield " ) _ }
210
215
211
216
-- Keywords reserved for future use
212
217
abstract { Spanned (IdentTok " abstract" ) _ }
@@ -227,10 +232,7 @@ import qualified Data.List.NonEmpty as N
227
232
-- Weak keywords, have special meaning only in specific contexts.
228
233
default { Spanned (IdentTok " default" ) _ }
229
234
union { Spanned (IdentTok " union" ) _ }
230
- catch { Spanned (IdentTok " catch" ) _ }
231
235
auto { Spanned (IdentTok " auto" ) _ }
232
- yield { Spanned (IdentTok " yield" ) _ }
233
- dyn { Spanned (IdentTok " dyn" ) _ }
234
236
235
237
-- Comments
236
238
outerDoc { Spanned (Doc _ Outer _) _ }
@@ -277,7 +279,7 @@ import qualified Data.List.NonEmpty as N
277
279
%nonassoc mut DEF EQ ' ::'
278
280
279
281
-- These are all identifiers of sorts (' union' and ' default' are " weak" keywords)
280
- %nonassoc IDENT ntIdent default union catch self Self super auto dyn crate
282
+ %nonassoc IDENT ntIdent default union self Self super auto crate
281
283
282
284
-- These are all very low precedence unary operators
283
285
%nonassoc box return yield break continue for IMPLTRAIT LAMBDA
@@ -325,17 +327,15 @@ import qualified Data.List.NonEmpty as N
325
327
%%
326
328
327
329
-- Unwraps the IdentTok into just an Ident
328
- -- For questionable reasons of backwards compatibility, ' union ' , ' default ' , and ' catch ' can be used
330
+ -- For questionable reasons of backwards compatibility, ' union ' , and ' default ' can be used
329
331
-- as identifiers, even if they are also keywords. They are "contextual" keywords.
330
332
--
331
333
-- Union' s RFC: https:// github.com/rust-lang/rfcs/blob/master/text/1444-union.md
332
334
ident :: { Spanned Ident }
333
335
: ntIdent { fmap (\(Interpolated (NtIdent i)) -> i) $1 }
334
336
| union { toIdent $1 }
335
337
| default { toIdent $1 }
336
- | catch { toIdent $1 }
337
338
| auto { toIdent $1 }
338
- | dyn { toIdent $1 }
339
339
| IDENT { toIdent $1 }
340
340
341
341
-- This should precede any ' >' token which could be absorbed in a ' >>' , ' >=' , or ' >>=' token. Its
@@ -554,7 +554,7 @@ path_segments_with_colons :: { Reversed NonEmpty (PathSegment Span) }
554
554
case (unsnoc $1 , unspan $3 ) of
555
555
((rst, PathSegment i Nothing x), (lts, tys, bds)) ->
556
556
let seg = PathSegment i (Just (AngleBracketed lts tys bds (spanOf $3 ))) (x # $3 )
557
- in pure $ snoc rst seg
557
+ in pure $ snoc rst seg
558
558
_ -> fail " invalid path segment in expression path"
559
559
}
560
560
@@ -1002,7 +1002,6 @@ left_gen_expression(lhs,rhs,rhs2) :: { Expr Span }
1002
1002
| lhs ' ...' rhs2 %prec INFIXRNG { Range [] (Just $1 ) (Just $3 ) Closed ($1 # $>) }
1003
1003
| lhs ' ..=' rhs2 %prec INFIXRNG { Range [] (Just $1 ) (Just $3 ) Closed ($1 # $>) }
1004
1004
-- assignment expressions
1005
- | lhs ' <-' rhs { InPlace [] $1 $3 ($1 # $>) }
1006
1005
| lhs ' =' rhs { Assign [] $1 $3 ($1 # $>) }
1007
1006
| lhs ' >>=' rhs { AssignOp [] ShrOp $1 $3 ($1 # $>) }
1008
1007
| lhs ' <<=' rhs { AssignOp [] ShlOp $1 $3 ($1 # $>) }
@@ -1155,11 +1154,13 @@ block_like_expr :: { Expr Span }
1155
1154
| match nostruct_expr ' {' arms ' }' { Match [] $2 $4 ($1 # $>) }
1156
1155
| match nostruct_expr ' {' inner_attrs arms ' }' { Match (toList $4 ) $2 $5 ($1 # $>) }
1157
1156
| expr_path ' !' ' {' token_stream ' }' { MacExpr [] (Mac $1 $4 ($1 # $>)) ($1 # $>) }
1158
- | do catch inner_attrs_block { let (as,b) = $> in Catch as b ($1 # b) }
1157
+ | try inner_attrs_block { let (as,b) = $> in TryBlock as b ($1 # b) }
1158
+ | async inner_attrs_block { let (as,b) = $> in Async as Ref b ($1 # b) }
1159
+ | async move inner_attrs_block { let (as,b) = $> in Async as Value b ($1 # b) }
1159
1160
1160
1161
-- ' if' expressions are a bit special since they can have an arbitrary number of ' else if' chains.
1161
1162
if_expr :: { Expr Span }
1162
- : if nostruct_expr block else_expr { If [] $2 $3 $4 ($1 # $3 # $>) }
1163
+ : if nostruct_expr block else_expr { If [] $2 $3 $4 ($1 # $3 # $>) }
1163
1164
| if let pats ' =' nostruct_expr block else_expr { IfLet [] $3 $5 $6 $7 ($1 # $6 # $>) }
1164
1165
1165
1166
else_expr :: { Maybe (Expr Span) }
@@ -1631,6 +1632,7 @@ token :: { Spanned Token }
1631
1632
| const { $1 }
1632
1633
| continue { $1 }
1633
1634
| crate { $1 }
1635
+ | dyn { $1 }
1634
1636
| else { $1 }
1635
1637
| enum { $1 }
1636
1638
| extern { $1 }
@@ -1656,11 +1658,13 @@ token :: { Spanned Token }
1656
1658
| super { $1 }
1657
1659
| trait { $1 }
1658
1660
| true { $1 }
1661
+ | try { $1 }
1659
1662
| type { $1 }
1660
1663
| unsafe { $1 }
1661
1664
| use { $1 }
1662
1665
| where { $1 }
1663
1666
| while { $1 }
1667
+ | yield { $1 }
1664
1668
-- Keywords reserved for future use
1665
1669
| abstract { $1 }
1666
1670
| alignof { $1 }
@@ -1680,10 +1684,7 @@ token :: { Spanned Token }
1680
1684
-- Weak keywords, have special meaning only in specific contexts.
1681
1685
| default { $1 }
1682
1686
| union { $1 }
1683
- | catch { $1 }
1684
1687
| auto { $1 }
1685
- | yield { $1 }
1686
- | dyn { $1 }
1687
1688
-- Comments
1688
1689
| outerDoc { $1 }
1689
1690
| innerDoc { $1 }
@@ -1808,7 +1809,7 @@ expParseError (Spanned t _, exps) = fail $ "Syntax error: unexpected `" ++ show
1808
1809
words " '||' '&&' '<<' '(' '[' '{' box break continue" ++
1809
1810
words " for if loop match move return Self self " ++
1810
1811
words " static super unsafe while do default union " ++
1811
- words " catch auto yield dyn "
1812
+ words " auto yield try async "
1812
1813
1813
1814
lit = boolLit ++ byteLit ++ charLit ++ intLit ++ floatLit ++ strLit ++
1814
1815
byteStrLit ++ rawStrLit ++ rawByteStrLit
@@ -1862,7 +1863,6 @@ macroItem as i mac x = MacItem as i mac x
1862
1863
-- | Add attributes to an expression
1863
1864
addAttrs :: [Attribute Span] -> Expr Span -> Expr Span
1864
1865
addAttrs as (Box as' e s) = Box (as ++ as' ) e s
1865
- addAttrs as (InPlace as' e1 e2 s) = InPlace (as ++ as' ) e1 e2 s
1866
1866
addAttrs as (Vec as' e s) = Vec (as ++ as' ) e s
1867
1867
addAttrs as (Call as' f es s) = Call (as ++ as' ) f es s
1868
1868
addAttrs as (MethodCall as' i s tys es s' ) = MethodCall (as ++ as' ) i s tys es s'
@@ -1881,7 +1881,8 @@ addAttrs as (Loop as' b l s) = Loop (as ++ as') b l s
1881
1881
addAttrs as (Match as' e a s) = Match (as ++ as' ) e a s
1882
1882
addAttrs as (Closure as' m c f e s) = Closure (as ++ as' ) m c f e s
1883
1883
addAttrs as (BlockExpr as' b s) = BlockExpr (as ++ as' ) b s
1884
- addAttrs as (Catch as' b s) = Catch (as ++ as' ) b s
1884
+ addAttrs as (TryBlock as' b s) = TryBlock (as ++ as' ) b s
1885
+ addAttrs as (Async as' c b s) = Async (as ++ as' ) c b s
1885
1886
addAttrs as (Assign as' e1 e2 s) = Assign (as ++ as' ) e1 e2 s
1886
1887
addAttrs as (AssignOp as' b e1 e2 s) = AssignOp (as ++ as' ) b e1 e2 s
1887
1888
addAttrs as (FieldAccess as' e i s) = FieldAccess (as ++ as' ) e i s
0 commit comments