@@ -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
// -------------------------------------------------------------------------
@@ -2225,9 +2229,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
2225
2229
"labels on blocks are unstable" ) ;
2226
2230
}
2227
2231
}
2228
- ast:: ExprKind :: Closure ( _, ast:: IsAsync :: Async { .. } , ..) => {
2229
- gate_feature_post ! ( & self , async_await, e. span, "async closures are unstable" ) ;
2230
- }
2231
2232
ast:: ExprKind :: Async ( ..) => {
2232
2233
gate_feature_post ! ( & self , async_await, e. span, "async blocks are unstable" ) ;
2233
2234
}
@@ -2561,6 +2562,10 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
2561
2562
features
2562
2563
}
2563
2564
2565
+ fn for_each_in_lock < T > ( vec : & Lock < Vec < T > > , f : impl Fn ( & T ) ) {
2566
+ vec. borrow ( ) . iter ( ) . for_each ( f) ;
2567
+ }
2568
+
2564
2569
pub fn check_crate ( krate : & ast:: Crate ,
2565
2570
sess : & ParseSess ,
2566
2571
features : & Features ,
@@ -2573,27 +2578,26 @@ pub fn check_crate(krate: &ast::Crate,
2573
2578
plugin_attributes,
2574
2579
} ;
2575
2580
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
+ ) ) ;
2597
2601
2598
2602
let visitor = & mut PostExpansionVisitor {
2599
2603
context : & ctx,
0 commit comments