@@ -139,6 +139,7 @@ impl Lit {
139139 match token. uninterpolate ( ) . kind {
140140 Ident ( name, IdentIsRaw :: No ) if name. is_bool_lit ( ) => Some ( Lit :: new ( Bool , name, None ) ) ,
141141 Literal ( token_lit) => Some ( token_lit) ,
142+ // njn: deal with later, with NtExpr/NtLiteral
142143 Interpolated ( ref nt)
143144 if let NtExpr ( expr) | NtLiteral ( expr) = & nt. 0
144145 && let ast:: ExprKind :: Lit ( token_lit) = expr. kind =>
@@ -380,6 +381,7 @@ impl Clone for TokenKind {
380381 // a copy. This is faster than the `derive(Clone)` version which has a
381382 // separate path for every variant.
382383 match self {
384+ // njn: nothing needed here
383385 Interpolated ( nt) => Interpolated ( nt. clone ( ) ) ,
384386 _ => unsafe { std:: ptr:: read ( self ) } ,
385387 }
@@ -470,6 +472,7 @@ impl Token {
470472 /// if they keep spans or perform edition checks.
471473 pub fn uninterpolated_span ( & self ) -> Span {
472474 match & self . kind {
475+ // njn: nothing needed here until Ident/Lifetime are done
473476 Interpolated ( nt) => nt. 0 . use_span ( ) ,
474477 _ => self . span ,
475478 }
@@ -487,6 +490,7 @@ impl Token {
487490 true
488491 }
489492
493+ // njn: no change needed
490494 OpenDelim ( ..) | CloseDelim ( ..) | Literal ( ..) | DocComment ( ..) | Ident ( ..)
491495 | Lifetime ( ..) | Interpolated ( ..) | Eof => false ,
492496 }
@@ -513,13 +517,19 @@ impl Token {
513517 // DotDotDot is no longer supported, but we need some way to display the error
514518 DotDot | DotDotDot | DotDotEq | // range notation
515519 Lt | BinOp ( Shl ) | // associated path
516- PathSep | // global path
520+ PathSep | // global path
517521 Lifetime ( ..) | // labeled loop
518522 Pound => true , // expression attributes
519523 Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
520524 NtExpr ( ..) |
521525 NtBlock ( ..) |
522526 NtPath ( ..) ) ,
527+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
528+ NonterminalKind :: Block |
529+ NonterminalKind :: Expr |
530+ NonterminalKind :: Literal |
531+ NonterminalKind :: Path
532+ ) ) ) => true ,
523533 _ => false ,
524534 }
525535 }
@@ -539,11 +549,18 @@ impl Token {
539549 // DotDotDot is no longer supported
540550 | DotDot | DotDotDot | DotDotEq // ranges
541551 | Lt | BinOp ( Shl ) // associated path
542- | PathSep => true , // global path
552+ | PathSep => true , // global path
543553 Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
544554 NtPat ( ..) |
545555 NtBlock ( ..) |
546556 NtPath ( ..) ) ,
557+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
558+ NonterminalKind :: Block |
559+ NonterminalKind :: PatParam { .. } |
560+ NonterminalKind :: PatWithOr |
561+ NonterminalKind :: Path |
562+ NonterminalKind :: Literal
563+ ) ) ) => true ,
547564 _ => false ,
548565 }
549566 }
@@ -564,6 +581,10 @@ impl Token {
564581 Lt | BinOp ( Shl ) | // associated path
565582 PathSep => true , // global path
566583 Interpolated ( ref nt) => matches ! ( & nt. 0 , NtTy ( ..) | NtPath ( ..) ) ,
584+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
585+ NonterminalKind :: Ty |
586+ NonterminalKind :: Path
587+ ) ) ) => true ,
567588 // For anonymous structs or unions, which only appear in specific positions
568589 // (type of struct fields or union fields), we don't consider them as regular types
569590 _ => false ,
@@ -575,6 +596,9 @@ impl Token {
575596 match self . kind {
576597 OpenDelim ( Delimiter :: Brace ) => true ,
577598 Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtBlock ( ..) | NtLiteral ( ..) ) ,
599+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
600+ NonterminalKind :: Expr | NonterminalKind :: Block | NonterminalKind :: Literal ,
601+ ) ) ) => true ,
578602 _ => self . can_begin_literal_maybe_minus ( ) ,
579603 }
580604 }
@@ -630,6 +654,10 @@ impl Token {
630654 } ,
631655 _ => false ,
632656 } ,
657+ // njn: too simple compared to what's above?
658+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
659+ NonterminalKind :: Literal | NonterminalKind :: Expr ,
660+ ) ) ) => true ,
633661 _ => false ,
634662 }
635663 }
@@ -640,6 +668,7 @@ impl Token {
640668 /// otherwise returns the original token.
641669 pub fn uninterpolate ( & self ) -> Cow < ' _ , Token > {
642670 match & self . kind {
671+ // njn: nothing needed here, just change when NtIdent is removed
643672 Interpolated ( nt) => match & nt. 0 {
644673 NtIdent ( ident, is_raw) => {
645674 Cow :: Owned ( Token :: new ( Ident ( ident. name , * is_raw) , ident. span ) )
@@ -657,6 +686,7 @@ impl Token {
657686 // We avoid using `Token::uninterpolate` here because it's slow.
658687 match & self . kind {
659688 & Ident ( name, is_raw) => Some ( ( Ident :: new ( name, self . span ) , is_raw) ) ,
689+ // njn: nothing needed here, just change when NtIdent is removed
660690 Interpolated ( nt) => match & nt. 0 {
661691 NtIdent ( ident, is_raw) => Some ( ( * ident, * is_raw) ) ,
662692 _ => None ,
@@ -671,6 +701,7 @@ impl Token {
671701 // We avoid using `Token::uninterpolate` here because it's slow.
672702 match & self . kind {
673703 & Lifetime ( name) => Some ( Ident :: new ( name, self . span ) ) ,
704+ // njn: nothing needed here, just change when NtLifetime is removed
674705 Interpolated ( nt) => match & nt. 0 {
675706 NtLifetime ( ident) => Some ( * ident) ,
676707 _ => None ,
@@ -697,6 +728,7 @@ impl Token {
697728
698729 /// Returns `true` if the token is an interpolated path.
699730 fn is_whole_path ( & self ) -> bool {
731+ // njn: nothing needed, just deal with NtPath later
700732 if let Interpolated ( nt) = & self . kind
701733 && let NtPath ( ..) = & nt. 0
702734 {
@@ -710,6 +742,7 @@ impl Token {
710742 /// That is, is this a pre-parsed expression dropped into the token stream
711743 /// (which happens while parsing the result of macro expansion)?
712744 pub fn is_whole_expr ( & self ) -> bool {
745+ // njn: nothing needed, just deal with NtExpr/NtLiteral/NtPath/NtBlock later
713746 if let Interpolated ( nt) = & self . kind
714747 && let NtExpr ( _) | NtLiteral ( _) | NtPath ( _) | NtBlock ( _) = & nt. 0
715748 {
@@ -721,6 +754,7 @@ impl Token {
721754
722755 /// Is the token an interpolated block (`$b:block`)?
723756 pub fn is_whole_block ( & self ) -> bool {
757+ // njn: nothing needed, just deal with NtBlock later
724758 if let Interpolated ( nt) = & self . kind
725759 && let NtBlock ( ..) = & nt. 0
726760 {
@@ -861,6 +895,7 @@ impl Token {
861895 _ => return None ,
862896 } ,
863897
898+ // njn: nothing needed here
864899 Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq ( ..) | At | DotDotDot
865900 | DotDotEq | Comma | Semi | PathSep | RArrow | LArrow | FatArrow | Pound | Dollar
866901 | Question | OpenDelim ( ..) | CloseDelim ( ..) | Literal ( ..) | Ident ( ..)
0 commit comments