@@ -139,6 +139,7 @@ impl Lit {
139
139
match token. uninterpolate ( ) . kind {
140
140
Ident ( name, IdentIsRaw :: No ) if name. is_bool_lit ( ) => Some ( Lit :: new ( Bool , name, None ) ) ,
141
141
Literal ( token_lit) => Some ( token_lit) ,
142
+ // njn: deal with later, with NtExpr/NtLiteral
142
143
Interpolated ( ref nt)
143
144
if let NtExpr ( expr) | NtLiteral ( expr) = & nt. 0
144
145
&& let ast:: ExprKind :: Lit ( token_lit) = expr. kind =>
@@ -380,6 +381,7 @@ impl Clone for TokenKind {
380
381
// a copy. This is faster than the `derive(Clone)` version which has a
381
382
// separate path for every variant.
382
383
match self {
384
+ // njn: nothing needed here
383
385
Interpolated ( nt) => Interpolated ( nt. clone ( ) ) ,
384
386
_ => unsafe { std:: ptr:: read ( self ) } ,
385
387
}
@@ -470,6 +472,7 @@ impl Token {
470
472
/// if they keep spans or perform edition checks.
471
473
pub fn uninterpolated_span ( & self ) -> Span {
472
474
match & self . kind {
475
+ // njn: nothing needed here until Ident/Lifetime are done
473
476
Interpolated ( nt) => nt. 0 . use_span ( ) ,
474
477
_ => self . span ,
475
478
}
@@ -487,6 +490,7 @@ impl Token {
487
490
true
488
491
}
489
492
493
+ // njn: no change needed
490
494
OpenDelim ( ..) | CloseDelim ( ..) | Literal ( ..) | DocComment ( ..) | Ident ( ..)
491
495
| Lifetime ( ..) | Interpolated ( ..) | Eof => false ,
492
496
}
@@ -513,13 +517,19 @@ impl Token {
513
517
// DotDotDot is no longer supported, but we need some way to display the error
514
518
DotDot | DotDotDot | DotDotEq | // range notation
515
519
Lt | BinOp ( Shl ) | // associated path
516
- PathSep | // global path
520
+ PathSep | // global path
517
521
Lifetime ( ..) | // labeled loop
518
522
Pound => true , // expression attributes
519
523
Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
520
524
NtExpr ( ..) |
521
525
NtBlock ( ..) |
522
526
NtPath ( ..) ) ,
527
+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
528
+ NonterminalKind :: Block |
529
+ NonterminalKind :: Expr |
530
+ NonterminalKind :: Literal |
531
+ NonterminalKind :: Path
532
+ ) ) ) => true ,
523
533
_ => false ,
524
534
}
525
535
}
@@ -539,11 +549,18 @@ impl Token {
539
549
// DotDotDot is no longer supported
540
550
| DotDot | DotDotDot | DotDotEq // ranges
541
551
| Lt | BinOp ( Shl ) // associated path
542
- | PathSep => true , // global path
552
+ | PathSep => true , // global path
543
553
Interpolated ( ref nt) => matches ! ( & nt. 0 , NtLiteral ( ..) |
544
554
NtPat ( ..) |
545
555
NtBlock ( ..) |
546
556
NtPath ( ..) ) ,
557
+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
558
+ NonterminalKind :: Block |
559
+ NonterminalKind :: PatParam { .. } |
560
+ NonterminalKind :: PatWithOr |
561
+ NonterminalKind :: Path |
562
+ NonterminalKind :: Literal
563
+ ) ) ) => true ,
547
564
_ => false ,
548
565
}
549
566
}
@@ -564,6 +581,10 @@ impl Token {
564
581
Lt | BinOp ( Shl ) | // associated path
565
582
PathSep => true , // global path
566
583
Interpolated ( ref nt) => matches ! ( & nt. 0 , NtTy ( ..) | NtPath ( ..) ) ,
584
+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
585
+ NonterminalKind :: Ty |
586
+ NonterminalKind :: Path
587
+ ) ) ) => true ,
567
588
// For anonymous structs or unions, which only appear in specific positions
568
589
// (type of struct fields or union fields), we don't consider them as regular types
569
590
_ => false ,
@@ -575,6 +596,9 @@ impl Token {
575
596
match self . kind {
576
597
OpenDelim ( Delimiter :: Brace ) => true ,
577
598
Interpolated ( ref nt) => matches ! ( & nt. 0 , NtExpr ( ..) | NtBlock ( ..) | NtLiteral ( ..) ) ,
599
+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
600
+ NonterminalKind :: Expr | NonterminalKind :: Block | NonterminalKind :: Literal ,
601
+ ) ) ) => true ,
578
602
_ => self . can_begin_literal_maybe_minus ( ) ,
579
603
}
580
604
}
@@ -630,6 +654,10 @@ impl Token {
630
654
} ,
631
655
_ => false ,
632
656
} ,
657
+ // njn: too simple compared to what's above?
658
+ OpenDelim ( Delimiter :: Invisible ( InvisibleOrigin :: MetaVar (
659
+ NonterminalKind :: Literal | NonterminalKind :: Expr ,
660
+ ) ) ) => true ,
633
661
_ => false ,
634
662
}
635
663
}
@@ -640,6 +668,7 @@ impl Token {
640
668
/// otherwise returns the original token.
641
669
pub fn uninterpolate ( & self ) -> Cow < ' _ , Token > {
642
670
match & self . kind {
671
+ // njn: nothing needed here, just change when NtIdent is removed
643
672
Interpolated ( nt) => match & nt. 0 {
644
673
NtIdent ( ident, is_raw) => {
645
674
Cow :: Owned ( Token :: new ( Ident ( ident. name , * is_raw) , ident. span ) )
@@ -657,6 +686,7 @@ impl Token {
657
686
// We avoid using `Token::uninterpolate` here because it's slow.
658
687
match & self . kind {
659
688
& Ident ( name, is_raw) => Some ( ( Ident :: new ( name, self . span ) , is_raw) ) ,
689
+ // njn: nothing needed here, just change when NtIdent is removed
660
690
Interpolated ( nt) => match & nt. 0 {
661
691
NtIdent ( ident, is_raw) => Some ( ( * ident, * is_raw) ) ,
662
692
_ => None ,
@@ -671,6 +701,7 @@ impl Token {
671
701
// We avoid using `Token::uninterpolate` here because it's slow.
672
702
match & self . kind {
673
703
& Lifetime ( name) => Some ( Ident :: new ( name, self . span ) ) ,
704
+ // njn: nothing needed here, just change when NtLifetime is removed
674
705
Interpolated ( nt) => match & nt. 0 {
675
706
NtLifetime ( ident) => Some ( * ident) ,
676
707
_ => None ,
@@ -697,6 +728,7 @@ impl Token {
697
728
698
729
/// Returns `true` if the token is an interpolated path.
699
730
fn is_whole_path ( & self ) -> bool {
731
+ // njn: nothing needed, just deal with NtPath later
700
732
if let Interpolated ( nt) = & self . kind
701
733
&& let NtPath ( ..) = & nt. 0
702
734
{
@@ -710,6 +742,7 @@ impl Token {
710
742
/// That is, is this a pre-parsed expression dropped into the token stream
711
743
/// (which happens while parsing the result of macro expansion)?
712
744
pub fn is_whole_expr ( & self ) -> bool {
745
+ // njn: nothing needed, just deal with NtExpr/NtLiteral/NtPath/NtBlock later
713
746
if let Interpolated ( nt) = & self . kind
714
747
&& let NtExpr ( _) | NtLiteral ( _) | NtPath ( _) | NtBlock ( _) = & nt. 0
715
748
{
@@ -721,6 +754,7 @@ impl Token {
721
754
722
755
/// Is the token an interpolated block (`$b:block`)?
723
756
pub fn is_whole_block ( & self ) -> bool {
757
+ // njn: nothing needed, just deal with NtBlock later
724
758
if let Interpolated ( nt) = & self . kind
725
759
&& let NtBlock ( ..) = & nt. 0
726
760
{
@@ -861,6 +895,7 @@ impl Token {
861
895
_ => return None ,
862
896
} ,
863
897
898
+ // njn: nothing needed here
864
899
Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq ( ..) | At | DotDotDot
865
900
| DotDotEq | Comma | Semi | PathSep | RArrow | LArrow | FatArrow | Pound | Dollar
866
901
| Question | OpenDelim ( ..) | CloseDelim ( ..) | Literal ( ..) | Ident ( ..)
0 commit comments