@@ -31,6 +31,7 @@ use crate::tokenstream::TokenTree;
3131
3232use errors:: { Applicability , DiagnosticBuilder , Handler } ;
3333use rustc_data_structures:: fx:: FxHashMap ;
34+ use rustc_data_structures:: sync:: Lock ;
3435use rustc_target:: spec:: abi:: Abi ;
3536use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
3637use log:: debug;
@@ -573,6 +574,9 @@ declare_features! (
573574 // Allows `impl Trait` with multiple unrelated lifetimes.
574575 ( active, member_constraints, "1.37.0" , Some ( 61977 ) , None ) ,
575576
577+ // Allows `async || body` closures.
578+ ( active, async_closure, "1.37.0" , Some ( 62290 ) , None ) ,
579+
576580 // -------------------------------------------------------------------------
577581 // feature-group-end: actual feature gates
578582 // -------------------------------------------------------------------------
@@ -2225,9 +2229,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
22252229 "labels on blocks are unstable" ) ;
22262230 }
22272231 }
2228- ast:: ExprKind :: Closure ( _, ast:: IsAsync :: Async { .. } , ..) => {
2229- gate_feature_post ! ( & self , async_await, e. span, "async closures are unstable" ) ;
2230- }
22312232 ast:: ExprKind :: Async ( ..) => {
22322233 gate_feature_post ! ( & self , async_await, e. span, "async blocks are unstable" ) ;
22332234 }
@@ -2561,6 +2562,10 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
25612562 features
25622563}
25632564
2565+ fn for_each_in_lock < T > ( vec : & Lock < Vec < T > > , f : impl Fn ( & T ) ) {
2566+ vec. borrow ( ) . iter ( ) . for_each ( f) ;
2567+ }
2568+
25642569pub fn check_crate ( krate : & ast:: Crate ,
25652570 sess : & ParseSess ,
25662571 features : & Features ,
@@ -2573,27 +2578,26 @@ pub fn check_crate(krate: &ast::Crate,
25732578 plugin_attributes,
25742579 } ;
25752580
2576- sess
2577- . param_attr_spans
2578- . borrow ( )
2579- . iter ( )
2580- . for_each ( |span| gate_feature ! (
2581- & ctx,
2582- param_attrs,
2583- * span,
2584- "attributes on function parameters are unstable"
2585- ) ) ;
2586-
2587- sess
2588- . let_chains_spans
2589- . borrow ( )
2590- . iter ( )
2591- . for_each ( |span| gate_feature ! (
2592- & ctx,
2593- let_chains,
2594- * span,
2595- "`let` expressions in this position are experimental"
2596- ) ) ;
2581+ for_each_in_lock ( & sess. param_attr_spans , |span| gate_feature ! (
2582+ & ctx,
2583+ param_attrs,
2584+ * span,
2585+ "attributes on function parameters are unstable"
2586+ ) ) ;
2587+
2588+ for_each_in_lock ( & sess. let_chains_spans , |span| gate_feature ! (
2589+ & ctx,
2590+ let_chains,
2591+ * span,
2592+ "`let` expressions in this position are experimental"
2593+ ) ) ;
2594+
2595+ for_each_in_lock ( & sess. async_closure_spans , |span| gate_feature ! (
2596+ & ctx,
2597+ async_closure,
2598+ * span,
2599+ "async closures are unstable"
2600+ ) ) ;
25972601
25982602 let visitor = & mut PostExpansionVisitor {
25992603 context : & ctx,
0 commit comments