@@ -30,7 +30,6 @@ use crate::tokenstream::TokenTree;
30
30
31
31
use errors:: { Applicability , DiagnosticBuilder , Handler } ;
32
32
use rustc_data_structures:: fx:: FxHashMap ;
33
- use rustc_data_structures:: sync:: Lock ;
34
33
use rustc_target:: spec:: abi:: Abi ;
35
34
use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
36
35
use log:: debug;
@@ -2088,11 +2087,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
2088
2087
"type ascription is experimental" ) ;
2089
2088
}
2090
2089
}
2091
- ast:: ExprKind :: Yield ( ..) => {
2092
- gate_feature_post ! ( & self , generators,
2093
- e. span,
2094
- "yield syntax is experimental" ) ;
2095
- }
2096
2090
ast:: ExprKind :: TryBlock ( _) => {
2097
2091
gate_feature_post ! ( & self , try_blocks, e. span, "`try` expression is experimental" ) ;
2098
2092
}
@@ -2427,10 +2421,6 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
2427
2421
features
2428
2422
}
2429
2423
2430
- fn for_each_in_lock < T > ( vec : & Lock < Vec < T > > , f : impl Fn ( & T ) ) {
2431
- vec. borrow ( ) . iter ( ) . for_each ( f) ;
2432
- }
2433
-
2434
2424
pub fn check_crate ( krate : & ast:: Crate ,
2435
2425
sess : & ParseSess ,
2436
2426
features : & Features ,
@@ -2443,26 +2433,16 @@ pub fn check_crate(krate: &ast::Crate,
2443
2433
plugin_attributes,
2444
2434
} ;
2445
2435
2446
- for_each_in_lock ( & sess. param_attr_spans , |span| gate_feature ! (
2447
- & ctx,
2448
- param_attrs,
2449
- * span,
2450
- "attributes on function parameters are unstable"
2451
- ) ) ;
2452
-
2453
- for_each_in_lock ( & sess. let_chains_spans , |span| gate_feature ! (
2454
- & ctx,
2455
- let_chains,
2456
- * span,
2457
- "`let` expressions in this position are experimental"
2458
- ) ) ;
2459
-
2460
- for_each_in_lock ( & sess. async_closure_spans , |span| gate_feature ! (
2461
- & ctx,
2462
- async_closure,
2463
- * span,
2464
- "async closures are unstable"
2465
- ) ) ;
2436
+ macro_rules! gate_all {
2437
+ ( $spans: ident, $gate: ident, $msg: literal) => {
2438
+ for span in & * sess. $spans. borrow( ) { gate_feature!( & ctx, $gate, * span, $msg) ; }
2439
+ }
2440
+ }
2441
+
2442
+ gate_all ! ( param_attr_spans, param_attrs, "attributes on function parameters are unstable" ) ;
2443
+ gate_all ! ( let_chains_spans, let_chains, "`let` expressions in this position are experimental" ) ;
2444
+ gate_all ! ( async_closure_spans, async_closure, "async closures are unstable" ) ;
2445
+ gate_all ! ( yield_spans, generators, "yield syntax is experimental" ) ;
2466
2446
2467
2447
let visitor = & mut PostExpansionVisitor {
2468
2448
context : & ctx,
0 commit comments