@@ -114,17 +114,17 @@ impl Attribute {
114114 #[ inline]
115115 pub fn has_name ( & self , name : Symbol ) -> bool {
116116 match self . kind {
117- AttrKind :: Normal ( ref item , _ ) => item. path == name,
117+ AttrKind :: Normal ( ref normal ) => normal . item . path == name,
118118 AttrKind :: DocComment ( ..) => false ,
119119 }
120120 }
121121
122122 /// For a single-segment attribute, returns its name; otherwise, returns `None`.
123123 pub fn ident ( & self ) -> Option < Ident > {
124124 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 )
128128 } else {
129129 None
130130 }
@@ -138,14 +138,16 @@ impl Attribute {
138138
139139 pub fn value_str ( & self ) -> Option < Symbol > {
140140 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+ }
142144 AttrKind :: DocComment ( ..) => None ,
143145 }
144146 }
145147
146148 pub fn meta_item_list ( & self ) -> Option < Vec < NestedMetaItem > > {
147149 match self . kind {
148- AttrKind :: Normal ( ref item , _ ) => match item. meta_kind ( ) {
150+ AttrKind :: Normal ( ref normal ) => match normal . item . meta_kind ( ) {
149151 Some ( MetaItemKind :: List ( list) ) => Some ( list) ,
150152 _ => None ,
151153 } ,
@@ -154,8 +156,8 @@ impl Attribute {
154156 }
155157
156158 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 )
159161 } else {
160162 false
161163 }
@@ -247,7 +249,8 @@ impl Attribute {
247249 pub fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > {
248250 match self . kind {
249251 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
251254 . meta_kind ( )
252255 . and_then ( |kind| kind. value_str ( ) )
253256 . map ( |data| ( data, CommentKind :: Line ) ) ,
@@ -258,8 +261,8 @@ impl Attribute {
258261 pub fn doc_str ( & self ) -> Option < Symbol > {
259262 match self . kind {
260263 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 ( ) )
263266 }
264267 _ => None ,
265268 }
@@ -271,36 +274,37 @@ impl Attribute {
271274
272275 pub fn get_normal_item ( & self ) -> & AttrItem {
273276 match self . kind {
274- AttrKind :: Normal ( ref item , _ ) => item,
277+ AttrKind :: Normal ( ref normal ) => & normal . item ,
275278 AttrKind :: DocComment ( ..) => panic ! ( "unexpected doc comment" ) ,
276279 }
277280 }
278281
279282 pub fn unwrap_normal_item ( self ) -> AttrItem {
280283 match self . kind {
281- AttrKind :: Normal ( item , _ ) => item,
284+ AttrKind :: Normal ( normal ) => normal . into_inner ( ) . item ,
282285 AttrKind :: DocComment ( ..) => panic ! ( "unexpected doc comment" ) ,
283286 }
284287 }
285288
286289 /// Extracts the MetaItem from inside this Attribute.
287290 pub fn meta ( & self ) -> Option < MetaItem > {
288291 match self . kind {
289- AttrKind :: Normal ( ref item , _ ) => item. meta ( self . span ) ,
292+ AttrKind :: Normal ( ref normal ) => normal . item . meta ( self . span ) ,
290293 AttrKind :: DocComment ( ..) => None ,
291294 }
292295 }
293296
294297 pub fn meta_kind ( & self ) -> Option < MetaItemKind > {
295298 match self . kind {
296- AttrKind :: Normal ( ref item , _ ) => item. meta_kind ( ) ,
299+ AttrKind :: Normal ( ref normal ) => normal . item . meta_kind ( ) ,
297300 AttrKind :: DocComment ( ..) => None ,
298301 }
299302 }
300303
301304 pub fn tokens ( & self ) -> AttrAnnotatedTokenStream {
302305 match self . kind {
303- AttrKind :: Normal ( _, ref tokens) => tokens
306+ AttrKind :: Normal ( ref normal) => normal
307+ . tokens
304308 . as_ref ( )
305309 . unwrap_or_else ( || panic ! ( "attribute is missing tokens: {:?}" , self ) )
306310 . create_token_stream ( ) ,
@@ -361,7 +365,12 @@ pub fn mk_attr_from_item(
361365 style : AttrStyle ,
362366 span : Span ,
363367) -> 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+ }
365374}
366375
367376/// Returns an inner attribute with the given value and span.
0 commit comments