@@ -13,32 +13,19 @@ crate mod transcribe;
13
13
use metavar_expr::MetaVarExpr;
14
14
use rustc_ast::token::{self, NonterminalKind, Token, TokenKind};
15
15
use rustc_ast::tokenstream::DelimSpan;
16
- use rustc_data_structures::sync::Lrc;
17
16
use rustc_span::symbol::Ident;
18
17
use rustc_span::Span;
19
18
20
19
/// Contains the sub-token-trees of a "delimited" token tree such as `(a b c)`. The delimiters
21
20
/// might be `NoDelim`, but they are not represented explicitly.
22
- #[derive(Clone, PartialEq, Encodable, Decodable, Debug)]
21
+ #[derive(PartialEq, Encodable, Decodable, Debug)]
23
22
struct Delimited {
24
23
delim: token::DelimToken,
25
24
/// FIXME: #67062 has details about why this is sub-optimal.
26
25
tts: Vec<TokenTree>,
27
26
}
28
27
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)]
42
29
struct SequenceRepetition {
43
30
/// The sequence of token trees
44
31
tts: Vec<TokenTree>,
@@ -76,13 +63,13 @@ enum KleeneOp {
76
63
77
64
/// Similar to `tokenstream::TokenTree`, except that `Sequence`, `MetaVar`, `MetaVarDecl`, and
78
65
/// `MetaVarExpr` are "first-class" token trees. Useful for parsing macros.
79
- #[derive(Debug, Clone, PartialEq, Encodable, Decodable)]
66
+ #[derive(Debug, PartialEq, Encodable, Decodable)]
80
67
enum TokenTree {
81
68
Token(Token),
82
69
/// A delimited sequence, e.g. `($e:expr)` (RHS) or `{ $e }` (LHS).
83
- Delimited(DelimSpan, Lrc< Delimited> ),
70
+ Delimited(DelimSpan, Delimited),
84
71
/// A kleene-style repetition sequence, e.g. `$($e:expr)*` (RHS) or `$($e),*` (LHS).
85
- Sequence(DelimSpan, Lrc< SequenceRepetition> ),
72
+ Sequence(DelimSpan, SequenceRepetition),
86
73
/// e.g., `$var`.
87
74
MetaVar(Span, Ident),
88
75
/// e.g., `$var:expr`. Only appears on the LHS.
0 commit comments