@@ -520,9 +520,7 @@ impl Token {
520
520
PathSep | // global path
521
521
Lifetime ( ..) | // labeled loop
522
522
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 ( ..) ) ,
526
524
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
527
525
NonterminalKind :: Block |
528
526
NonterminalKind :: Expr |
@@ -549,7 +547,7 @@ impl Token {
549
547
| DotDot | DotDotDot | DotDotEq // ranges
550
548
| Lt | BinOp ( Shl ) // associated path
551
549
| PathSep => true , // global path
552
- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) | NtBlock ( .. ) ) ,
550
+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) ) ,
553
551
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
554
552
NonterminalKind :: Block |
555
553
NonterminalKind :: PatParam { .. } |
@@ -590,7 +588,7 @@ impl Token {
590
588
pub fn can_begin_const_arg ( & self ) -> bool {
591
589
match self . kind {
592
590
OpenDelim ( Delimiter :: Brace ) => true ,
593
- Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtBlock ( .. ) | NtLiteral ( ..) ) ,
591
+ Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtLiteral ( ..) ) ,
594
592
OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
595
593
NonterminalKind :: Expr | NonterminalKind :: Block | NonterminalKind :: Literal ,
596
594
) ) ) => true ,
@@ -727,26 +725,22 @@ impl Token {
727
725
pub fn is_whole_expr ( & self ) -> bool {
728
726
// njn: nothing needed, just deal with NtExpr/NtLiteral/NtPath/NtBlock later
729
727
if let Interpolated ( nt) = & self . kind
730
- && let NtExpr ( _) | NtLiteral ( _) | NtBlock ( _ ) = & nt. 0
728
+ && let NtExpr ( _) | NtLiteral ( _) = & nt. 0
731
729
{
732
730
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
+ ) {
734
735
true
735
736
} else {
736
737
false
737
738
}
738
739
}
739
740
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 ) )
750
744
}
751
745
752
746
/// Returns `true` if the token is either the `mut` or `const` keyword.
@@ -910,7 +904,6 @@ impl PartialEq<TokenKind> for Token {
910
904
#[ derive( Clone , Encodable , Decodable ) ]
911
905
/// For interpolation during macro expansion.
912
906
pub enum Nonterminal {
913
- NtBlock ( P < ast:: Block > ) ,
914
907
NtExpr ( P < ast:: Expr > ) ,
915
908
NtIdent ( Ident , IdentIsRaw ) ,
916
909
NtLifetime ( Ident ) ,
@@ -998,15 +991,13 @@ impl fmt::Display for NonterminalKind {
998
991
impl Nonterminal {
999
992
pub fn use_span ( & self ) -> Span {
1000
993
match self {
1001
- NtBlock ( block) => block. span ,
1002
994
NtExpr ( expr) | NtLiteral ( expr) => expr. span ,
1003
995
NtIdent ( ident, _) | NtLifetime ( ident) => ident. span ,
1004
996
}
1005
997
}
1006
998
1007
999
pub fn descr ( & self ) -> & ' static str {
1008
1000
match self {
1009
- NtBlock ( ..) => "block" ,
1010
1001
NtExpr ( ..) => "expression" ,
1011
1002
NtLiteral ( ..) => "literal" ,
1012
1003
NtIdent ( ..) => "identifier" ,
@@ -1034,7 +1025,6 @@ impl PartialEq for Nonterminal {
1034
1025
impl fmt:: Debug for Nonterminal {
1035
1026
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1036
1027
match * self {
1037
- NtBlock ( ..) => f. pad ( "NtBlock(..)" ) ,
1038
1028
NtExpr ( ..) => f. pad ( "NtExpr(..)" ) ,
1039
1029
NtIdent ( ..) => f. pad ( "NtIdent(..)" ) ,
1040
1030
NtLiteral ( ..) => f. pad ( "NtLiteral(..)" ) ,
0 commit comments