@@ -31,6 +31,7 @@ use crate::tokenstream::TokenTree;
31
31
32
32
use errors:: { Applicability , DiagnosticBuilder , Handler } ;
33
33
use rustc_data_structures:: fx:: FxHashMap ;
34
+ use rustc_data_structures:: sync:: Lock ;
34
35
use rustc_target:: spec:: abi:: Abi ;
35
36
use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
36
37
use log:: debug;
@@ -573,6 +574,9 @@ declare_features! (
573
574
// Allows `impl Trait` with multiple unrelated lifetimes.
574
575
( active, member_constraints, "1.37.0" , Some ( 61977 ) , None ) ,
575
576
577
+ // Allows `async || body` closures.
578
+ ( active, async_closure, "1.37.0" , Some ( 62290 ) , None ) ,
579
+
576
580
// -------------------------------------------------------------------------
577
581
// feature-group-end: actual feature gates
578
582
// -------------------------------------------------------------------------
@@ -2191,9 +2195,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
2191
2195
"labels on blocks are unstable" ) ;
2192
2196
}
2193
2197
}
2194
- ast:: ExprKind :: Closure ( _, ast:: IsAsync :: Async { .. } , ..) => {
2195
- gate_feature_post ! ( & self , async_await, e. span, "async closures are unstable" ) ;
2196
- }
2197
2198
ast:: ExprKind :: Async ( ..) => {
2198
2199
gate_feature_post ! ( & self , async_await, e. span, "async blocks are unstable" ) ;
2199
2200
}
@@ -2527,6 +2528,10 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
2527
2528
features
2528
2529
}
2529
2530
2531
+ fn for_each_in_lock < T > ( vec : & Lock < Vec < T > > , f : impl Fn ( & T ) ) {
2532
+ vec. borrow ( ) . iter ( ) . for_each ( f) ;
2533
+ }
2534
+
2530
2535
pub fn check_crate ( krate : & ast:: Crate ,
2531
2536
sess : & ParseSess ,
2532
2537
features : & Features ,
@@ -2539,27 +2544,26 @@ pub fn check_crate(krate: &ast::Crate,
2539
2544
plugin_attributes,
2540
2545
} ;
2541
2546
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
+ ) ) ;
2563
2567
2564
2568
let visitor = & mut PostExpansionVisitor {
2565
2569
context : & ctx,
0 commit comments