@@ -13,32 +13,19 @@ crate mod transcribe;
1313use metavar_expr:: MetaVarExpr ;
1414use rustc_ast:: token:: { self , NonterminalKind , Token , TokenKind } ;
1515use rustc_ast:: tokenstream:: DelimSpan ;
16- use rustc_data_structures:: sync:: Lrc ;
1716use rustc_span:: symbol:: Ident ;
1817use rustc_span:: Span ;
1918
2019/// Contains the sub-token-trees of a "delimited" token tree such as `(a b c)`. The delimiters
2120/// might be `NoDelim`, but they are not represented explicitly.
22- #[ derive( Clone , PartialEq , Encodable , Decodable , Debug ) ]
21+ #[ derive( PartialEq , Encodable , Decodable , Debug ) ]
2322struct Delimited {
2423 delim : token:: DelimToken ,
2524 /// FIXME: #67062 has details about why this is sub-optimal.
2625 tts : Vec < TokenTree > ,
2726}
2827
29- impl Delimited {
30- /// Returns a `self::TokenTree` with a `Span` corresponding to the opening delimiter.
31- fn open_tt ( & self , span : DelimSpan ) -> TokenTree {
32- TokenTree :: token ( token:: OpenDelim ( self . delim ) , span. open )
33- }
34-
35- /// Returns a `self::TokenTree` with a `Span` corresponding to the closing delimiter.
36- fn close_tt ( & self , span : DelimSpan ) -> TokenTree {
37- TokenTree :: token ( token:: CloseDelim ( self . delim ) , span. close )
38- }
39- }
40-
41- #[ derive( Clone , PartialEq , Encodable , Decodable , Debug ) ]
28+ #[ derive( PartialEq , Encodable , Decodable , Debug ) ]
4229struct SequenceRepetition {
4330 /// The sequence of token trees
4431 tts : Vec < TokenTree > ,
@@ -76,13 +63,13 @@ enum KleeneOp {
7663
7764/// Similar to `tokenstream::TokenTree`, except that `Sequence`, `MetaVar`, `MetaVarDecl`, and
7865/// `MetaVarExpr` are "first-class" token trees. Useful for parsing macros.
79- #[ derive( Debug , Clone , PartialEq , Encodable , Decodable ) ]
66+ #[ derive( Debug , PartialEq , Encodable , Decodable ) ]
8067enum TokenTree {
8168 Token ( Token ) ,
8269 /// A delimited sequence, e.g. `($e:expr)` (RHS) or `{ $e }` (LHS).
83- Delimited ( DelimSpan , Lrc < Delimited > ) ,
70+ Delimited ( DelimSpan , Delimited ) ,
8471 /// A kleene-style repetition sequence, e.g. `$($e:expr)*` (RHS) or `$($e),*` (LHS).
85- Sequence ( DelimSpan , Lrc < SequenceRepetition > ) ,
72+ Sequence ( DelimSpan , SequenceRepetition ) ,
8673 /// e.g., `$var`.
8774 MetaVar ( Span , Ident ) ,
8875 /// e.g., `$var:expr`. Only appears on the LHS.
0 commit comments