@@ -516,9 +516,7 @@ impl Token {
516516 PathSep | // global path
517517 Lifetime ( ..) | // labeled loop
518518 Pound => true , // expression attributes
519- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
520- NtExpr ( ..) |
521- NtBlock ( ..) ) ,
519+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtExpr ( ..) ) ,
522520 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
523521 NonterminalKind :: Block |
524522 NonterminalKind :: Expr |
@@ -545,7 +543,7 @@ impl Token {
545543 | DotDot | DotDotDot | DotDotEq // ranges
546544 | Lt | BinOp ( Shl ) // associated path
547545 | PathSep => true , // global path
548- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtBlock ( .. ) ) ,
546+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) ) ,
549547 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
550548 NonterminalKind :: Block |
551549 NonterminalKind :: PatParam { .. } |
@@ -586,7 +584,7 @@ impl Token {
586584 pub fn can_begin_const_arg ( & self ) -> bool {
587585 match self . kind {
588586 OpenDelim ( Delimiter :: Brace ) => true ,
589- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtBlock ( .. ) | NtLiteral ( ..) ) ,
587+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtLiteral ( ..) ) ,
590588 OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
591589 NonterminalKind :: Expr | NonterminalKind :: Block | NonterminalKind :: Literal ,
592590 ) ) ) => true ,
@@ -719,25 +717,22 @@ impl Token {
719717 /// (which happens while parsing the result of macro expansion)?
720718 pub fn is_whole_expr ( & self ) -> bool {
721719 if let Interpolated ( nt) = & self . kind
722- && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _ ) = & nt. 0
720+ && let NtExpr ( _) | NtLiteral ( _) = & nt. 0
723721 {
724722 true
725- } else if matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Path ) ) {
723+ } else if matches ! (
724+ self . is_metavar_seq( ) ,
725+ Some ( NonterminalKind :: Block | NonterminalKind :: Path )
726+ ) {
726727 true
727728 } else {
728729 false
729730 }
730731 }
731732
732- /// Is the token an interpolated block (`$b:block`)?
733- pub fn is_whole_block ( & self ) -> bool {
734- if let Interpolated ( nt) = & self . kind
735- && let NtBlock ( ..) = & nt. 0
736- {
737- return true ;
738- }
739-
740- false
733+ /// Are we at a block from a metavar (`$b:block`)?
734+ pub fn is_metavar_block ( & self ) -> bool {
735+ matches ! ( self . is_metavar_seq( ) , Some ( NonterminalKind :: Block ) )
741736 }
742737
743738 /// Returns `true` if the token is either the `mut` or `const` keyword.
@@ -900,7 +895,6 @@ impl PartialEq<TokenKind> for Token {
900895#[ derive( Clone , Encodable , Decodable ) ]
901896/// For interpolation during macro expansion.
902897pub enum Nonterminal {
903- NtBlock ( P < ast:: Block > ) ,
904898 NtExpr ( P < ast:: Expr > ) ,
905899 NtIdent ( Ident , IdentIsRaw ) ,
906900 NtLifetime ( Ident ) ,
@@ -988,15 +982,13 @@ impl fmt::Display for NonterminalKind {
988982impl Nonterminal {
989983 pub fn use_span ( & self ) -> Span {
990984 match self {
991- NtBlock ( block) => block. span ,
992985 NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
993986 NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
994987 }
995988 }
996989
997990 pub fn descr ( & self ) -> & ' static str {
998991 match self {
999- NtBlock ( ..) => "block" ,
1000992 NtExpr ( ..) => "expression" ,
1001993 NtLiteral ( ..) => "literal" ,
1002994 NtIdent ( ..) => "identifier" ,
@@ -1024,7 +1016,6 @@ impl PartialEq for Nonterminal {
10241016impl fmt:: Debug for Nonterminal {
10251017 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
10261018 match * self {
1027- NtBlock ( ..) => f. pad ( "NtBlock(..)" ) ,
10281019 NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
10291020 NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
10301021 NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
0 commit comments