@@ -114,17 +114,17 @@ impl Attribute {
114
114
#[ inline]
115
115
pub fn has_name ( & self , name : Symbol ) -> bool {
116
116
match self . kind {
117
- AttrKind :: Normal ( ref item , _ ) => item. path == name,
117
+ AttrKind :: Normal ( ref normal ) => normal . item . path == name,
118
118
AttrKind :: DocComment ( ..) => false ,
119
119
}
120
120
}
121
121
122
122
/// For a single-segment attribute, returns its name; otherwise, returns `None`.
123
123
pub fn ident ( & self ) -> Option < Ident > {
124
124
match self . kind {
125
- AttrKind :: Normal ( ref item , _ ) => {
126
- if item. path . segments . len ( ) == 1 {
127
- Some ( item. path . segments [ 0 ] . ident )
125
+ AttrKind :: Normal ( ref normal ) => {
126
+ if normal . item . path . segments . len ( ) == 1 {
127
+ Some ( normal . item . path . segments [ 0 ] . ident )
128
128
} else {
129
129
None
130
130
}
@@ -138,14 +138,16 @@ impl Attribute {
138
138
139
139
pub fn value_str ( & self ) -> Option < Symbol > {
140
140
match self . kind {
141
- AttrKind :: Normal ( ref item, _) => item. meta_kind ( ) . and_then ( |kind| kind. value_str ( ) ) ,
141
+ AttrKind :: Normal ( ref normal) => {
142
+ normal. item . meta_kind ( ) . and_then ( |kind| kind. value_str ( ) )
143
+ }
142
144
AttrKind :: DocComment ( ..) => None ,
143
145
}
144
146
}
145
147
146
148
pub fn meta_item_list ( & self ) -> Option < Vec < NestedMetaItem > > {
147
149
match self . kind {
148
- AttrKind :: Normal ( ref item , _ ) => match item. meta_kind ( ) {
150
+ AttrKind :: Normal ( ref normal ) => match normal . item . meta_kind ( ) {
149
151
Some ( MetaItemKind :: List ( list) ) => Some ( list) ,
150
152
_ => None ,
151
153
} ,
@@ -154,8 +156,8 @@ impl Attribute {
154
156
}
155
157
156
158
pub fn is_word ( & self ) -> bool {
157
- if let AttrKind :: Normal ( item , _ ) = & self . kind {
158
- matches ! ( item. args, MacArgs :: Empty )
159
+ if let AttrKind :: Normal ( normal ) = & self . kind {
160
+ matches ! ( normal . item. args, MacArgs :: Empty )
159
161
} else {
160
162
false
161
163
}
@@ -247,7 +249,8 @@ impl Attribute {
247
249
pub fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > {
248
250
match self . kind {
249
251
AttrKind :: DocComment ( kind, data) => Some ( ( data, kind) ) ,
250
- AttrKind :: Normal ( ref item, _) if item. path == sym:: doc => item
252
+ AttrKind :: Normal ( ref normal) if normal. item . path == sym:: doc => normal
253
+ . item
251
254
. meta_kind ( )
252
255
. and_then ( |kind| kind. value_str ( ) )
253
256
. map ( |data| ( data, CommentKind :: Line ) ) ,
@@ -258,8 +261,8 @@ impl Attribute {
258
261
pub fn doc_str ( & self ) -> Option < Symbol > {
259
262
match self . kind {
260
263
AttrKind :: DocComment ( .., data) => Some ( data) ,
261
- AttrKind :: Normal ( ref item , _ ) if item. path == sym:: doc => {
262
- item. meta_kind ( ) . and_then ( |kind| kind. value_str ( ) )
264
+ AttrKind :: Normal ( ref normal ) if normal . item . path == sym:: doc => {
265
+ normal . item . meta_kind ( ) . and_then ( |kind| kind. value_str ( ) )
263
266
}
264
267
_ => None ,
265
268
}
@@ -271,36 +274,37 @@ impl Attribute {
271
274
272
275
pub fn get_normal_item ( & self ) -> & AttrItem {
273
276
match self . kind {
274
- AttrKind :: Normal ( ref item , _ ) => item,
277
+ AttrKind :: Normal ( ref normal ) => & normal . item ,
275
278
AttrKind :: DocComment ( ..) => panic ! ( "unexpected doc comment" ) ,
276
279
}
277
280
}
278
281
279
282
pub fn unwrap_normal_item ( self ) -> AttrItem {
280
283
match self . kind {
281
- AttrKind :: Normal ( item , _ ) => item,
284
+ AttrKind :: Normal ( normal ) => normal . into_inner ( ) . item ,
282
285
AttrKind :: DocComment ( ..) => panic ! ( "unexpected doc comment" ) ,
283
286
}
284
287
}
285
288
286
289
/// Extracts the MetaItem from inside this Attribute.
287
290
pub fn meta ( & self ) -> Option < MetaItem > {
288
291
match self . kind {
289
- AttrKind :: Normal ( ref item , _ ) => item. meta ( self . span ) ,
292
+ AttrKind :: Normal ( ref normal ) => normal . item . meta ( self . span ) ,
290
293
AttrKind :: DocComment ( ..) => None ,
291
294
}
292
295
}
293
296
294
297
pub fn meta_kind ( & self ) -> Option < MetaItemKind > {
295
298
match self . kind {
296
- AttrKind :: Normal ( ref item , _ ) => item. meta_kind ( ) ,
299
+ AttrKind :: Normal ( ref normal ) => normal . item . meta_kind ( ) ,
297
300
AttrKind :: DocComment ( ..) => None ,
298
301
}
299
302
}
300
303
301
304
pub fn tokens ( & self ) -> AttrAnnotatedTokenStream {
302
305
match self . kind {
303
- AttrKind :: Normal ( _, ref tokens) => tokens
306
+ AttrKind :: Normal ( ref normal) => normal
307
+ . tokens
304
308
. as_ref ( )
305
309
. unwrap_or_else ( || panic ! ( "attribute is missing tokens: {:?}" , self ) )
306
310
. create_token_stream ( ) ,
@@ -361,7 +365,12 @@ pub fn mk_attr_from_item(
361
365
style : AttrStyle ,
362
366
span : Span ,
363
367
) -> Attribute {
364
- Attribute { kind : AttrKind :: Normal ( item, tokens) , id : mk_attr_id ( ) , style, span }
368
+ Attribute {
369
+ kind : AttrKind :: Normal ( P ( ast:: NormalAttr { item, tokens } ) ) ,
370
+ id : mk_attr_id ( ) ,
371
+ style,
372
+ span,
373
+ }
365
374
}
366
375
367
376
/// Returns an inner attribute with the given value and span.
0 commit comments