T!['('],
T!['{'],
T!['['],
- L_DOLLAR,
T![|],
T![move],
T![box],
LIFETIME_IDENT,
]));
-const EXPR_RECOVERY_SET: TokenSet = TokenSet::new(&[LET_KW, R_DOLLAR]);
+const EXPR_RECOVERY_SET: TokenSet = TokenSet::new(&[T![let]]);
pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
if let Some(m) = literal(p) {
let done = match p.current() {
T!['('] => tuple_expr(p),
T!['['] => array_expr(p),
- L_DOLLAR => meta_var_expr(p),
T![|] => closure_expr(p),
- T![move] if la == T![|] => closure_expr(p),
- T![async] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => closure_expr(p),
+ T![static] | T![async] | T![move] if la == T![|] => closure_expr(p),
+ T![static] | T![async] if la == T![move] && p.nth(2) == T![|] => closure_expr(p),
+ T![static] if la == T![async] && p.nth(2) == T![|] => closure_expr(p),
+ T![static] if la == T![async] && p.nth(2) == T![move] && p.nth(3) == T![|] => {
+ closure_expr(p)
+ }
T![if] => if_expr(p),
T![loop] => loop_expr(p, None),
// async || {};
// move || {};
// async move || {};
+// static || {};
+// static move || {};
+// static async || {};
+// static async move || {};
// }
fn closure_expr(p: &mut Parser) -> CompletedMarker {
assert!(
|| (p.at(T![move]) && p.nth(1) == T![|])
|| (p.at(T![async]) && p.nth(1) == T![|])
|| (p.at(T![async]) && p.nth(1) == T![move] && p.nth(2) == T![|])
+ || (p.at(T![static]) && p.nth(1) == T![|])
+ || (p.at(T![static]) && p.nth(1) == T![move] && p.nth(2) == T![|])
+ || (p.at(T![static]) && p.nth(1) == T![async] && p.nth(2) == T![|])
+ || (p.at(T![static])
+ && p.nth(1) == T![async]
+ && p.nth(2) == T![move]
+ && p.nth(3) == T![|])
);
let m = p.start();
+ p.eat(T![static]);
p.eat(T![async]);
p.eat(T![move]);
params::param_list_closure(p);
if p.at(T!['{']) {
match_arm_list(p);
} else {
- p.error("expected `{`")
+ p.error("expected `{`");
}
m.complete(p, MATCH_EXPR)
}
if p.at(T!['{']) {
stmt_list(p);
} else {
- p.error("expected a block")
+ p.error("expected a block");
}
m.complete(p, BLOCK_EXPR)
}
}
m.complete(p, BOX_EXPR)
}
-
-/// Expression from `$var` macro expansion, wrapped in dollars
-fn meta_var_expr(p: &mut Parser) -> CompletedMarker {
- assert!(p.at(L_DOLLAR));
- let m = p.start();
- p.bump(L_DOLLAR);
- let expr = expr_bp(p, None, Restrictions { forbid_structs: false, prefer_stmt: false }, 1);
-
- match (expr, p.current()) {
- (Some((cm, _)), R_DOLLAR) => {
- p.bump(R_DOLLAR);
- // FIXME: this leaves the dollar hanging in the air...
- m.abandon(p);
- cm
- }
- _ => {
- while !p.at(R_DOLLAR) {
- p.bump_any()
- }
- p.bump(R_DOLLAR);
- m.complete(p, ERROR)
- }
- }
-}