@@ -520,9 +520,7 @@ impl Token {
520520 PathSep | // global path
521521 Lifetime ( ..) | // labeled loop
522522 Pound => true , // expression attributes
523- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
524- NtExpr ( ..) |
525- NtBlock ( ..) ) ,
523+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtExpr ( ..) ) ,
526524 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
527525 NonterminalKind :: Block |
528526 NonterminalKind :: Expr |
@@ -549,7 +547,7 @@ impl Token {
549547 | DotDot | DotDotDot | DotDotEq // ranges
550548 | Lt | BinOp ( Shl ) // associated path
551549 | PathSep => true , // global path
552- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtBlock ( .. ) ) ,
550+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) ) ,
553551 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
554552 NonterminalKind :: Block |
555553 NonterminalKind :: PatParam { .. } |
@@ -590,7 +588,7 @@ impl Token {
590588 pub fn can_begin_const_arg ( & self ) -> bool {
591589 match self . kind {
592590 OpenDelim ( Delimiter :: Brace ) => true ,
593- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtBlock ( .. ) | NtLiteral ( ..) ) ,
591+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtLiteral ( ..) ) ,
594592 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
595593 NonterminalKind :: Expr | NonterminalKind :: Block | NonterminalKind :: Literal ,
596594 ) ) ) => true ,
@@ -727,26 +725,22 @@ impl Token {
727725 pub fn is_whole_expr ( & self ) -> bool {
728726 // njn: nothing needed, just deal with NtExpr/NtLiteral/NtPath/NtBlock later
729727 if let Interpolated ( nt) = & self . kind
730- && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _ ) = & nt. 0
728+ && let NtExpr ( _) | NtLiteral ( _) = & nt. 0
731729 {
732730 true
733- } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
731+ } else if matches ! (
732+ self . is_metavar_seq( ) ,
733+ Some ( NonterminalKind :: Block | NonterminalKind :: Path )
734+ ) {
734735 true
735736 } else {
736737 false
737738 }
738739 }
739740
740- /// Is the token an interpolated block (`$b:block`)?
741- pub fn is_whole_block ( & self ) -> bool {
742- // njn: nothing needed, just deal with NtBlock later
743- if let Interpolated ( nt) = & self . kind
744- && let NtBlock ( ..) = & nt. 0
745- {
746- return true ;
747- }
748-
749- false
741+ /// Are we at a block from a metavar (`$b:block`)?
742+ pub fn is_metavar_block ( & self ) -> bool {
743+ matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Block ) )
750744 }
751745
752746 /// Returns `true` if the token is either the `mut` or `const` keyword.
@@ -910,7 +904,6 @@ impl PartialEq<TokenKind> for Token {
910904#[ derive( Clone , Encodable , Decodable ) ]
911905/// For interpolation during macro expansion.
912906pub enum Nonterminal {
913- NtBlock ( P < ast:: Block > ) ,
914907 NtExpr ( P < ast:: Expr > ) ,
915908 NtIdent ( Ident , IdentIsRaw ) ,
916909 NtLifetime ( Ident ) ,
@@ -998,15 +991,13 @@ impl fmt::Display for NonterminalKind {
998991impl Nonterminal {
999992 pub fn use_span ( & self ) -> Span {
1000993 match self {
1001- NtBlock ( block) => block. span ,
1002994 NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
1003995 NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
1004996 }
1005997 }
1006998
1007999 pub fn descr ( & self ) -> & ' static str {
10081000 match self {
1009- NtBlock ( ..) => "block" ,
10101001 NtExpr ( ..) => "expression" ,
10111002 NtLiteral ( ..) => "literal" ,
10121003 NtIdent ( ..) => "identifier" ,
@@ -1034,7 +1025,6 @@ impl PartialEq for Nonterminal {
10341025impl fmt:: Debug for Nonterminal {
10351026 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
10361027 match * self {
1037- NtBlock ( ..) => f. pad ( "NtBlock(..)" ) ,
10381028 NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
10391029 NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
10401030 NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
0 commit comments