Combine expr_closure and expr_unstable_async_closure
diff --git a/src/expr.rs b/src/expr.rs
index 7910cf7..a4dc9b7 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1612,8 +1612,6 @@
|
call!(expr_closure, allow_struct)
|
- call!(expr_unstable_async_closure, allow_struct) => { Expr::Verbatim }
- |
cond_reduce!(allow_block, syn!(ExprBlock)) => { Expr::Block }
|
// NOTE: This is the prefix-form of range
@@ -2095,8 +2093,10 @@
#[cfg(feature = "full")]
named!(expr_closure(allow_struct: bool) -> Expr, do_parse!(
+ begin: call!(verbatim::grab_cursor) >>
attrs: many0!(Attribute::parse_outer) >>
- movability: option!(keyword!(static)) >>
+ asyncness: option!(keyword!(async)) >>
+ movability: option!(cond_reduce!(asyncness.is_none(), keyword!(static))) >>
capture: option!(keyword!(move)) >>
or1: punct!(|) >>
inputs: call!(Punctuated::parse_terminated_with, fn_arg) >>
@@ -2115,45 +2115,26 @@
|
map!(ambiguous_expr!(allow_struct), |e| (ReturnType::Default, e))
) >>
- (ExprClosure {
- attrs: attrs,
- movability: movability,
- capture: capture,
- or1_token: or1,
- inputs: inputs,
- or2_token: or2,
- output: ret_and_body.0,
- body: Box::new(ret_and_body.1),
- }.into())
- ));
-
- #[cfg(feature = "full")]
- named!(expr_unstable_async_closure(allow_struct: bool) -> ExprVerbatim, do_parse!(
- begin: call!(verbatim::grab_cursor) >>
- _attrs: many0!(Attribute::parse_outer) >>
- _asyncness: keyword!(async) >>
- _movability: option!(keyword!(static)) >>
- _capture: option!(keyword!(move)) >>
- _or1: punct!(|) >>
- _inputs: call!(Punctuated::<FnArg, Token![,]>::parse_terminated_with, fn_arg) >>
- _or2: punct!(|) >>
- _ret_and_body: alt!(
- do_parse!(
- arrow: punct!(->) >>
- ty: syn!(Type) >>
- body: syn!(Block) >>
- (ReturnType::Type(arrow, Box::new(ty)),
- Expr::Block(ExprBlock {
- attrs: Vec::new(),
- block: body,
- }))
- )
- |
- map!(ambiguous_expr!(allow_struct), |e| (ReturnType::Default, e))
- ) >>
end: call!(verbatim::grab_cursor) >>
- (ExprVerbatim {
- tts: verbatim::token_range(begin..end),
+ ({
+ if asyncness.is_some() {
+ // TODO: include asyncness in ExprClosure
+ // https://github.com/dtolnay/syn/issues/396
+ Expr::Verbatim(ExprVerbatim {
+ tts: verbatim::token_range(begin..end),
+ })
+ } else {
+ Expr::Closure(ExprClosure {
+ attrs: attrs,
+ movability: movability,
+ capture: capture,
+ or1_token: or1,
+ inputs: inputs,
+ or2_token: or2,
+ output: ret_and_body.0,
+ body: Box::new(ret_and_body.1),
+ })
+ }
})
));