T!['('] => tuple_expr(p),
T!['['] => array_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![let] => let_expr(p),
T![loop] => loop_expr(p, None),
T![box] => box_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);
assert!(p.at(T![if]));
let m = p.start();
p.bump(T![if]);
- condition(p);
+ expr_no_struct(p);
block_expr(p);
if p.at(T![else]) {
p.bump(T![else]);
assert!(p.at(T![while]));
let m = m.unwrap_or_else(|| p.start());
p.bump(T![while]);
- condition(p);
+ expr_no_struct(p);
block_expr(p);
m.complete(p, WHILE_EXPR)
}
m.complete(p, FOR_EXPR)
}
-// test cond
-// fn foo() { if let Some(_) = None {} }
-// fn bar() {
-// if let Some(_) | Some(_) = None {}
-// if let | Some(_) = None {}
-// while let Some(_) | Some(_) = None {}
-// while let | Some(_) = None {}
+// test let_expr
+// fn foo() {
+// if let Some(_) = None && true {}
+// while 1 == 5 && (let None = None) {}
// }
-fn condition(p: &mut Parser) {
+fn let_expr(p: &mut Parser) -> CompletedMarker {
let m = p.start();
- if p.eat(T![let]) {
- patterns::pattern_top(p);
- p.expect(T![=]);
- }
- expr_no_struct(p);
- m.complete(p, CONDITION);
+ p.bump(T![let]);
+ patterns::pattern_top(p);
+ p.expect(T![=]);
+ expr_let(p);
+ m.complete(p, LET_EXPR)
}
// test match_expr
assert!(p.at(T![if]));
let m = p.start();
p.bump(T![if]);
- if p.eat(T![let]) {
- patterns::pattern_top(p);
- p.expect(T![=]);
- }
expr(p);
m.complete(p, MATCH_GUARD)
}