@@ -16,10 +16,10 @@ use crate::parse::token::{self, Token, TokenKind};
16
16
use crate :: print:: pprust;
17
17
use crate :: ptr:: P ;
18
18
use crate :: source_map:: { self , Span } ;
19
- use crate :: symbol:: { kw, sym} ;
20
19
use crate :: util:: parser:: { AssocOp , Fixity , prec_let_scrutinee_needs_par} ;
21
20
22
21
use errors:: Applicability ;
22
+ use syntax_pos:: symbol:: { kw, sym} ;
23
23
use syntax_pos:: Symbol ;
24
24
use std:: mem;
25
25
use rustc_data_structures:: thin_vec:: ThinVec ;
@@ -252,7 +252,7 @@ impl<'a> Parser<'a> {
252
252
self . last_type_ascription = Some ( ( self . prev_span , maybe_path) ) ;
253
253
254
254
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 ) ;
256
256
continue
257
257
} else if op == AssocOp :: DotDot || op == AssocOp :: DotDotEq {
258
258
// If we didn’t have to handle `x..`/`x..=`, it would be pretty easy to
@@ -455,7 +455,7 @@ impl<'a> Parser<'a> {
455
455
let e = self . parse_prefix_expr ( None ) ;
456
456
let ( span, e) = self . interpolated_or_expr_span ( e) ?;
457
457
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) ;
459
459
( span, ExprKind :: Box ( e) )
460
460
}
461
461
token:: Ident ( ..) if self . token . is_ident_named ( sym:: not) => {
@@ -1045,7 +1045,7 @@ impl<'a> Parser<'a> {
1045
1045
}
1046
1046
1047
1047
let span = lo. to ( hi) ;
1048
- self . sess . gated_spans . yields . borrow_mut ( ) . push ( span) ;
1048
+ self . sess . gated_spans . gate ( sym :: generators , span) ;
1049
1049
} else if self . eat_keyword ( kw:: Let ) {
1050
1050
return self . parse_let_expr ( attrs) ;
1051
1051
} else if is_span_rust_2018 && self . eat_keyword ( kw:: Await ) {
@@ -1264,7 +1264,7 @@ impl<'a> Parser<'a> {
1264
1264
outer_attrs : ThinVec < Attribute > ,
1265
1265
) -> PResult < ' a , P < Expr > > {
1266
1266
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 ) ;
1268
1268
}
1269
1269
1270
1270
self . expect ( & token:: OpenDelim ( token:: Brace ) ) ?;
@@ -1293,7 +1293,7 @@ impl<'a> Parser<'a> {
1293
1293
} ;
1294
1294
if asyncness. is_async ( ) {
1295
1295
// 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 ) ;
1297
1297
}
1298
1298
1299
1299
let capture_clause = self . parse_capture_clause ( ) ;
@@ -1415,8 +1415,7 @@ impl<'a> Parser<'a> {
1415
1415
1416
1416
if let ExprKind :: Let ( ..) = cond. kind {
1417
1417
// 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 ) ;
1420
1419
}
1421
1420
1422
1421
Ok ( cond)
@@ -1433,7 +1432,7 @@ impl<'a> Parser<'a> {
1433
1432
|this| this. parse_assoc_expr_with ( 1 + prec_let_scrutinee_needs_par ( ) , None . into ( ) )
1434
1433
) ?;
1435
1434
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) ;
1437
1436
Ok ( self . mk_expr ( span, ExprKind :: Let ( pat, expr) , attrs) )
1438
1437
}
1439
1438
@@ -1654,7 +1653,7 @@ impl<'a> Parser<'a> {
1654
1653
Err ( error)
1655
1654
} else {
1656
1655
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) ;
1658
1657
Ok ( self . mk_expr ( span, ExprKind :: TryBlock ( body) , attrs) )
1659
1658
}
1660
1659
}
0 commit comments