@@ -30,7 +30,6 @@ use crate::tokenstream::TokenTree;
3030
3131use errors:: { Applicability , DiagnosticBuilder , Handler } ;
3232use rustc_data_structures:: fx:: FxHashMap ;
33- use rustc_data_structures:: sync:: Lock ;
3433use rustc_target:: spec:: abi:: Abi ;
3534use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
3635use log:: debug;
@@ -2422,10 +2421,6 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
24222421 features
24232422}
24242423
2425- fn for_each_in_lock < T > ( vec : & Lock < Vec < T > > , f : impl Fn ( & T ) ) {
2426- vec. borrow ( ) . iter ( ) . for_each ( f) ;
2427- }
2428-
24292424pub fn check_crate ( krate : & ast:: Crate ,
24302425 sess : & ParseSess ,
24312426 features : & Features ,
@@ -2438,33 +2433,16 @@ pub fn check_crate(krate: &ast::Crate,
24382433 plugin_attributes,
24392434 } ;
24402435
2441- for_each_in_lock ( & sess. param_attr_spans , |span| gate_feature ! (
2442- & ctx,
2443- param_attrs,
2444- * span,
2445- "attributes on function parameters are unstable"
2446- ) ) ;
2447-
2448- for_each_in_lock ( & sess. let_chains_spans , |span| gate_feature ! (
2449- & ctx,
2450- let_chains,
2451- * span,
2452- "`let` expressions in this position are experimental"
2453- ) ) ;
2454-
2455- for_each_in_lock ( & sess. async_closure_spans , |span| gate_feature ! (
2456- & ctx,
2457- async_closure,
2458- * span,
2459- "async closures are unstable"
2460- ) ) ;
2461-
2462- for_each_in_lock ( & sess. yield_spans , |span| gate_feature ! (
2463- & ctx,
2464- generators,
2465- * span,
2466- "yield syntax is experimental"
2467- ) ) ;
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" ) ;
24682446
24692447 let visitor = & mut PostExpansionVisitor {
24702448 context : & ctx,
0 commit comments