4
4
5
5
use crate :: ptr:: P ;
6
6
use crate :: token:: Nonterminal ;
7
- use crate :: tokenstream:: LazyTokenStream ;
7
+ use crate :: tokenstream:: LazyAttrTokenStream ;
8
8
use crate :: { Arm , Crate , ExprField , FieldDef , GenericParam , Param , PatField , Variant } ;
9
9
use crate :: { AssocItem , Expr , ForeignItem , Item , NodeId } ;
10
10
use crate :: { AttrItem , AttrKind , Block , Pat , Path , Ty , Visibility } ;
@@ -124,18 +124,18 @@ impl HasSpan for AttrItem {
124
124
125
125
/// A trait for AST nodes having (or not having) collected tokens.
126
126
pub trait HasTokens {
127
- fn tokens ( & self ) -> Option < & LazyTokenStream > ;
128
- fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyTokenStream > > ;
127
+ fn tokens ( & self ) -> Option < & LazyAttrTokenStream > ;
128
+ fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyAttrTokenStream > > ;
129
129
}
130
130
131
131
macro_rules! impl_has_tokens {
132
132
( $( $T: ty) ,+ $( , ) ?) => {
133
133
$(
134
134
impl HasTokens for $T {
135
- fn tokens( & self ) -> Option <& LazyTokenStream > {
135
+ fn tokens( & self ) -> Option <& LazyAttrTokenStream > {
136
136
self . tokens. as_ref( )
137
137
}
138
- fn tokens_mut( & mut self ) -> Option <& mut Option <LazyTokenStream >> {
138
+ fn tokens_mut( & mut self ) -> Option <& mut Option <LazyAttrTokenStream >> {
139
139
Some ( & mut self . tokens)
140
140
}
141
141
}
@@ -147,10 +147,10 @@ macro_rules! impl_has_tokens_none {
147
147
( $( $T: ty) ,+ $( , ) ?) => {
148
148
$(
149
149
impl HasTokens for $T {
150
- fn tokens( & self ) -> Option <& LazyTokenStream > {
150
+ fn tokens( & self ) -> Option <& LazyAttrTokenStream > {
151
151
None
152
152
}
153
- fn tokens_mut( & mut self ) -> Option <& mut Option <LazyTokenStream >> {
153
+ fn tokens_mut( & mut self ) -> Option <& mut Option <LazyAttrTokenStream >> {
154
154
None
155
155
}
156
156
}
@@ -162,25 +162,25 @@ impl_has_tokens!(AssocItem, AttrItem, Block, Expr, ForeignItem, Item, Pat, Path,
162
162
impl_has_tokens_none ! ( Arm , ExprField , FieldDef , GenericParam , Param , PatField , Variant ) ;
163
163
164
164
impl < T : AstDeref < Target : HasTokens > > HasTokens for T {
165
- fn tokens ( & self ) -> Option < & LazyTokenStream > {
165
+ fn tokens ( & self ) -> Option < & LazyAttrTokenStream > {
166
166
self . ast_deref ( ) . tokens ( )
167
167
}
168
- fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyTokenStream > > {
168
+ fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyAttrTokenStream > > {
169
169
self . ast_deref_mut ( ) . tokens_mut ( )
170
170
}
171
171
}
172
172
173
173
impl < T : HasTokens > HasTokens for Option < T > {
174
- fn tokens ( & self ) -> Option < & LazyTokenStream > {
174
+ fn tokens ( & self ) -> Option < & LazyAttrTokenStream > {
175
175
self . as_ref ( ) . and_then ( |inner| inner. tokens ( ) )
176
176
}
177
- fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyTokenStream > > {
177
+ fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyAttrTokenStream > > {
178
178
self . as_mut ( ) . and_then ( |inner| inner. tokens_mut ( ) )
179
179
}
180
180
}
181
181
182
182
impl HasTokens for StmtKind {
183
- fn tokens ( & self ) -> Option < & LazyTokenStream > {
183
+ fn tokens ( & self ) -> Option < & LazyAttrTokenStream > {
184
184
match self {
185
185
StmtKind :: Local ( local) => local. tokens . as_ref ( ) ,
186
186
StmtKind :: Item ( item) => item. tokens ( ) ,
@@ -189,7 +189,7 @@ impl HasTokens for StmtKind {
189
189
StmtKind :: MacCall ( mac) => mac. tokens . as_ref ( ) ,
190
190
}
191
191
}
192
- fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyTokenStream > > {
192
+ fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyAttrTokenStream > > {
193
193
match self {
194
194
StmtKind :: Local ( local) => Some ( & mut local. tokens ) ,
195
195
StmtKind :: Item ( item) => item. tokens_mut ( ) ,
@@ -201,24 +201,24 @@ impl HasTokens for StmtKind {
201
201
}
202
202
203
203
impl HasTokens for Stmt {
204
- fn tokens ( & self ) -> Option < & LazyTokenStream > {
204
+ fn tokens ( & self ) -> Option < & LazyAttrTokenStream > {
205
205
self . kind . tokens ( )
206
206
}
207
- fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyTokenStream > > {
207
+ fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyAttrTokenStream > > {
208
208
self . kind . tokens_mut ( )
209
209
}
210
210
}
211
211
212
212
impl HasTokens for Attribute {
213
- fn tokens ( & self ) -> Option < & LazyTokenStream > {
213
+ fn tokens ( & self ) -> Option < & LazyAttrTokenStream > {
214
214
match & self . kind {
215
215
AttrKind :: Normal ( normal) => normal. tokens . as_ref ( ) ,
216
216
kind @ AttrKind :: DocComment ( ..) => {
217
217
panic ! ( "Called tokens on doc comment attr {:?}" , kind)
218
218
}
219
219
}
220
220
}
221
- fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyTokenStream > > {
221
+ fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyAttrTokenStream > > {
222
222
Some ( match & mut self . kind {
223
223
AttrKind :: Normal ( normal) => & mut normal. tokens ,
224
224
kind @ AttrKind :: DocComment ( ..) => {
@@ -229,7 +229,7 @@ impl HasTokens for Attribute {
229
229
}
230
230
231
231
impl HasTokens for Nonterminal {
232
- fn tokens ( & self ) -> Option < & LazyTokenStream > {
232
+ fn tokens ( & self ) -> Option < & LazyAttrTokenStream > {
233
233
match self {
234
234
Nonterminal :: NtItem ( item) => item. tokens ( ) ,
235
235
Nonterminal :: NtStmt ( stmt) => stmt. tokens ( ) ,
@@ -243,7 +243,7 @@ impl HasTokens for Nonterminal {
243
243
Nonterminal :: NtIdent ( ..) | Nonterminal :: NtLifetime ( ..) => None ,
244
244
}
245
245
}
246
- fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyTokenStream > > {
246
+ fn tokens_mut ( & mut self ) -> Option < & mut Option < LazyAttrTokenStream > > {
247
247
match self {
248
248
Nonterminal :: NtItem ( item) => item. tokens_mut ( ) ,
249
249
Nonterminal :: NtStmt ( stmt) => stmt. tokens_mut ( ) ,
0 commit comments