@@ -1521,6 +1521,7 @@ impl<'a> Parser<'a> {
15211521 fn parse_restriction (
15221522 & mut self ,
15231523 kw : ExpKeywordPair ,
1524+ feature_gate : Option < Symbol > ,
15241525 action : & ' static str ,
15251526 description : & ' static str ,
15261527 fbt : FollowedByType ,
@@ -1532,6 +1533,13 @@ impl<'a> Parser<'a> {
15321533 return Ok ( Restriction :: implied ( ) . with_span ( self . token . span . shrink_to_lo ( ) ) ) ;
15331534 }
15341535
1536+ let gate = |span| {
1537+ if let Some ( feature_gate) = feature_gate {
1538+ self . psess . gated_spans . gate ( feature_gate, span) ;
1539+ }
1540+ span
1541+ } ;
1542+
15351543 let lo = self . prev_token . span ;
15361544
15371545 if self . check ( exp ! ( OpenParen ) ) {
@@ -1546,16 +1554,16 @@ impl<'a> Parser<'a> {
15461554 let path = self . parse_path ( PathStyle :: Mod ) ?; // `path`
15471555 self . expect ( exp ! ( CloseParen ) ) ?; // `)`
15481556 return Ok ( Restriction :: restricted ( P ( path) , ast:: DUMMY_NODE_ID , false )
1549- . with_span ( lo. to ( self . prev_token . span ) ) ) ;
1557+ . with_span ( gate ( lo. to ( self . prev_token . span ) ) ) ) ;
15501558 } else if self . look_ahead ( 2 , |t| t == & TokenKind :: CloseParen )
15511559 && self . is_keyword_ahead ( 1 , & [ kw:: Crate , kw:: Super , kw:: SelfLower ] )
15521560 {
15531561 // Parse `kw(crate)`, `kw(self)`, or `kw(super)`.
15541562 self . bump ( ) ; // `(`
15551563 let path = self . parse_path ( PathStyle :: Mod ) ?; // `crate`/`super`/`self`
15561564 self . expect ( exp ! ( CloseParen ) ) ?; // `)`
1557- return Ok ( Restriction :: restricted ( P ( path) , ast:: DUMMY_NODE_ID , false )
1558- . with_span ( lo. to ( self . prev_token . span ) ) ) ;
1565+ return Ok ( Restriction :: restricted ( P ( path) , ast:: DUMMY_NODE_ID , true )
1566+ . with_span ( gate ( lo. to ( self . prev_token . span ) ) ) ) ;
15591567 } else if let FollowedByType :: No = fbt {
15601568 // Provide this diagnostic if a type cannot follow;
15611569 // in particular, if this is not a tuple struct.
@@ -1564,7 +1572,7 @@ impl<'a> Parser<'a> {
15641572 }
15651573 }
15661574
1567- Ok ( Restriction :: unrestricted ( ) . with_span ( lo ) )
1575+ Ok ( Restriction :: unrestricted ( ) . with_span ( gate ( lo ) ) )
15681576 }
15691577
15701578 /// Recovery for e.g. `kw(something) fn ...` or `struct X { kw(something) y: Z }`
0 commit comments