@@ -1520,6 +1520,7 @@ impl<'a> Parser<'a> {
15201520 fn parse_restriction (
15211521 & mut self ,
15221522 kw : ExpKeywordPair ,
1523+ feature_gate : Option < Symbol > ,
15231524 action : & ' static str ,
15241525 description : & ' static str ,
15251526 fbt : FollowedByType ,
@@ -1531,6 +1532,13 @@ impl<'a> Parser<'a> {
15311532 return Ok ( Restriction :: implied ( ) . with_span ( self . token . span . shrink_to_lo ( ) ) ) ;
15321533 }
15331534
1535+ let gate = |span| {
1536+ if let Some ( feature_gate) = feature_gate {
1537+ self . psess . gated_spans . gate ( feature_gate, span) ;
1538+ }
1539+ span
1540+ } ;
1541+
15341542 let lo = self . prev_token . span ;
15351543
15361544 if self . check ( exp ! ( OpenParen ) ) {
@@ -1545,16 +1553,16 @@ impl<'a> Parser<'a> {
15451553 let path = self . parse_path ( PathStyle :: Mod ) ?; // `path`
15461554 self . expect ( exp ! ( CloseParen ) ) ?; // `)`
15471555 return Ok ( Restriction :: restricted ( P ( path) , ast:: DUMMY_NODE_ID , false )
1548- . with_span ( lo. to ( self . prev_token . span ) ) ) ;
1556+ . with_span ( gate ( lo. to ( self . prev_token . span ) ) ) ) ;
15491557 } else if self . look_ahead ( 2 , |t| t == & TokenKind :: CloseParen )
15501558 && self . is_keyword_ahead ( 1 , & [ kw:: Crate , kw:: Super , kw:: SelfLower ] )
15511559 {
15521560 // Parse `kw(crate)`, `kw(self)`, or `kw(super)`.
15531561 self . bump ( ) ; // `(`
15541562 let path = self . parse_path ( PathStyle :: Mod ) ?; // `crate`/`super`/`self`
15551563 self . expect ( exp ! ( CloseParen ) ) ?; // `)`
1556- return Ok ( Restriction :: restricted ( P ( path) , ast:: DUMMY_NODE_ID , false )
1557- . with_span ( lo. to ( self . prev_token . span ) ) ) ;
1564+ return Ok ( Restriction :: restricted ( P ( path) , ast:: DUMMY_NODE_ID , true )
1565+ . with_span ( gate ( lo. to ( self . prev_token . span ) ) ) ) ;
15581566 } else if let FollowedByType :: No = fbt {
15591567 // Provide this diagnostic if a type cannot follow;
15601568 // in particular, if this is not a tuple struct.
@@ -1563,7 +1571,7 @@ impl<'a> Parser<'a> {
15631571 }
15641572 }
15651573
1566- Ok ( Restriction :: unrestricted ( ) . with_span ( lo ) )
1574+ Ok ( Restriction :: unrestricted ( ) . with_span ( gate ( lo ) ) )
15671575 }
15681576
15691577 /// Recovery for e.g. `kw(something) fn ...` or `struct X { kw(something) y: Z }`
0 commit comments