@@ -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 // -------------------------------------------------------------------------
@@ -2191,9 +2195,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
21912195 "labels on blocks are unstable" ) ;
21922196 }
21932197 }
2194- ast:: ExprKind :: Closure ( _, ast:: IsAsync :: Async { .. } , ..) => {
2195- gate_feature_post ! ( & self , async_await, e. span, "async closures are unstable" ) ;
2196- }
21972198 ast:: ExprKind :: Async ( ..) => {
21982199 gate_feature_post ! ( & self , async_await, e. span, "async blocks are unstable" ) ;
21992200 }
@@ -2527,6 +2528,10 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
25272528 features
25282529}
25292530
2531+ fn for_each_in_lock < T > ( vec : & Lock < Vec < T > > , f : impl Fn ( & T ) ) {
2532+ vec. borrow ( ) . iter ( ) . for_each ( f) ;
2533+ }
2534+
25302535pub fn check_crate ( krate : & ast:: Crate ,
25312536 sess : & ParseSess ,
25322537 features : & Features ,
@@ -2539,27 +2544,26 @@ pub fn check_crate(krate: &ast::Crate,
25392544 plugin_attributes,
25402545 } ;
25412546
2542- sess
2543- . param_attr_spans
2544- . borrow ( )
2545- . iter ( )
2546- . for_each ( |span| gate_feature ! (
2547- & ctx,
2548- param_attrs,
2549- * span,
2550- "attributes on function parameters are unstable"
2551- ) ) ;
2552-
2553- sess
2554- . let_chains_spans
2555- . borrow ( )
2556- . iter ( )
2557- . for_each ( |span| gate_feature ! (
2558- & ctx,
2559- let_chains,
2560- * span,
2561- "`let` expressions in this position are experimental"
2562- ) ) ;
2547+ for_each_in_lock ( & sess. param_attr_spans , |span| gate_feature ! (
2548+ & ctx,
2549+ param_attrs,
2550+ * span,
2551+ "attributes on function parameters are unstable"
2552+ ) ) ;
2553+
2554+ for_each_in_lock ( & sess. let_chains_spans , |span| gate_feature ! (
2555+ & ctx,
2556+ let_chains,
2557+ * span,
2558+ "`let` expressions in this position are experimental"
2559+ ) ) ;
2560+
2561+ for_each_in_lock ( & sess. async_closure_spans , |span| gate_feature ! (
2562+ & ctx,
2563+ async_closure,
2564+ * span,
2565+ "async closures are unstable"
2566+ ) ) ;
25632567
25642568 let visitor = & mut PostExpansionVisitor {
25652569 context : & ctx,
0 commit comments