@@ -16,10 +16,10 @@ use crate::parse::token::{self, Token, TokenKind};
1616use crate :: print:: pprust;
1717use crate :: ptr:: P ;
1818use crate :: source_map:: { self , Span } ;
19- use crate :: symbol:: { kw, sym} ;
2019use crate :: util:: parser:: { AssocOp , Fixity , prec_let_scrutinee_needs_par} ;
2120
2221use errors:: Applicability ;
22+ use syntax_pos:: symbol:: { kw, sym} ;
2323use syntax_pos:: Symbol ;
2424use std:: mem;
2525use rustc_data_structures:: thin_vec:: ThinVec ;
@@ -252,7 +252,7 @@ impl<'a> Parser<'a> {
252252 self . last_type_ascription = Some ( ( self . prev_span , maybe_path) ) ;
253253
254254 lhs = self . parse_assoc_op_cast ( lhs, lhs_span, ExprKind :: Type ) ?;
255- self . sess . gated_spans . type_ascription . borrow_mut ( ) . push ( lhs. span ) ;
255+ self . sess . gated_spans . gate ( sym :: type_ascription , lhs. span ) ;
256256 continue
257257 } else if op == AssocOp :: DotDot || op == AssocOp :: DotDotEq {
258258 // If we didn’t have to handle `x..`/`x..=`, it would be pretty easy to
@@ -455,7 +455,7 @@ impl<'a> Parser<'a> {
455455 let e = self . parse_prefix_expr ( None ) ;
456456 let ( span, e) = self . interpolated_or_expr_span ( e) ?;
457457 let span = lo. to ( span) ;
458- self . sess . gated_spans . box_syntax . borrow_mut ( ) . push ( span) ;
458+ self . sess . gated_spans . gate ( sym :: box_syntax , span) ;
459459 ( span, ExprKind :: Box ( e) )
460460 }
461461 token:: Ident ( ..) if self . token . is_ident_named ( sym:: not) => {
@@ -1045,7 +1045,7 @@ impl<'a> Parser<'a> {
10451045 }
10461046
10471047 let span = lo. to ( hi) ;
1048- self . sess . gated_spans . yields . borrow_mut ( ) . push ( span) ;
1048+ self . sess . gated_spans . gate ( sym :: generators , span) ;
10491049 } else if self . eat_keyword ( kw:: Let ) {
10501050 return self . parse_let_expr ( attrs) ;
10511051 } else if is_span_rust_2018 && self . eat_keyword ( kw:: Await ) {
@@ -1264,7 +1264,7 @@ impl<'a> Parser<'a> {
12641264 outer_attrs : ThinVec < Attribute > ,
12651265 ) -> PResult < ' a , P < Expr > > {
12661266 if let Some ( label) = opt_label {
1267- self . sess . gated_spans . label_break_value . borrow_mut ( ) . push ( label. ident . span ) ;
1267+ self . sess . gated_spans . gate ( sym :: label_break_value , label. ident . span ) ;
12681268 }
12691269
12701270 self . expect ( & token:: OpenDelim ( token:: Brace ) ) ?;
@@ -1293,7 +1293,7 @@ impl<'a> Parser<'a> {
12931293 } ;
12941294 if asyncness. is_async ( ) {
12951295 // Feature-gate `async ||` closures.
1296- self . sess . gated_spans . async_closure . borrow_mut ( ) . push ( self . prev_span ) ;
1296+ self . sess . gated_spans . gate ( sym :: async_closure , self . prev_span ) ;
12971297 }
12981298
12991299 let capture_clause = self . parse_capture_clause ( ) ;
@@ -1415,8 +1415,7 @@ impl<'a> Parser<'a> {
14151415
14161416 if let ExprKind :: Let ( ..) = cond. kind {
14171417 // Remove the last feature gating of a `let` expression since it's stable.
1418- let last = self . sess . gated_spans . let_chains . borrow_mut ( ) . pop ( ) ;
1419- debug_assert_eq ! ( cond. span, last. unwrap( ) ) ;
1418+ self . sess . gated_spans . ungate_last ( sym:: let_chains, cond. span ) ;
14201419 }
14211420
14221421 Ok ( cond)
@@ -1433,7 +1432,7 @@ impl<'a> Parser<'a> {
14331432 |this| this. parse_assoc_expr_with ( 1 + prec_let_scrutinee_needs_par ( ) , None . into ( ) )
14341433 ) ?;
14351434 let span = lo. to ( expr. span ) ;
1436- self . sess . gated_spans . let_chains . borrow_mut ( ) . push ( span) ;
1435+ self . sess . gated_spans . gate ( sym :: let_chains , span) ;
14371436 Ok ( self . mk_expr ( span, ExprKind :: Let ( pat, expr) , attrs) )
14381437 }
14391438
@@ -1654,7 +1653,7 @@ impl<'a> Parser<'a> {
16541653 Err ( error)
16551654 } else {
16561655 let span = span_lo. to ( body. span ) ;
1657- self . sess . gated_spans . try_blocks . borrow_mut ( ) . push ( span) ;
1656+ self . sess . gated_spans . gate ( sym :: try_blocks , span) ;
16581657 Ok ( self . mk_expr ( span, ExprKind :: TryBlock ( body) , attrs) )
16591658 }
16601659 }
0 commit comments