@@ -98,7 +98,7 @@ impl<'a> Parser<'a> {
98
98
debug ! ( "parse_attribute_with_inner_parse_policy: inner_parse_policy={:?} self.token={:?}" ,
99
99
inner_parse_policy,
100
100
self . token) ;
101
- let ( span, path , tokens , style) = match self . token . kind {
101
+ let ( span, item , style) = match self . token . kind {
102
102
token:: Pound => {
103
103
let lo = self . token . span ;
104
104
self . bump ( ) ;
@@ -115,7 +115,7 @@ impl<'a> Parser<'a> {
115
115
} ;
116
116
117
117
self . expect ( & token:: OpenDelim ( token:: Bracket ) ) ?;
118
- let ( path , tokens ) = self . parse_meta_item_unrestricted ( ) ?;
118
+ let item = self . parse_attr_item ( ) ?;
119
119
self . expect ( & token:: CloseDelim ( token:: Bracket ) ) ?;
120
120
let hi = self . prev_span ;
121
121
@@ -150,7 +150,7 @@ impl<'a> Parser<'a> {
150
150
}
151
151
}
152
152
153
- ( attr_sp, path , tokens , style)
153
+ ( attr_sp, item , style)
154
154
}
155
155
_ => {
156
156
let token_str = self . this_token_to_string ( ) ;
@@ -159,7 +159,7 @@ impl<'a> Parser<'a> {
159
159
} ;
160
160
161
161
Ok ( ast:: Attribute {
162
- item : ast :: AttrItem { path , tokens } ,
162
+ item,
163
163
id : attr:: mk_attr_id ( ) ,
164
164
style,
165
165
is_sugared_doc : false ,
@@ -176,17 +176,17 @@ impl<'a> Parser<'a> {
176
176
/// PATH
177
177
/// PATH `=` TOKEN_TREE
178
178
/// The delimiters or `=` are still put into the resulting token stream.
179
- crate fn parse_meta_item_unrestricted ( & mut self ) -> PResult < ' a , ( ast:: Path , TokenStream ) > {
180
- let meta = match self . token . kind {
179
+ crate fn parse_attr_item ( & mut self ) -> PResult < ' a , ast:: AttrItem > {
180
+ let item = match self . token . kind {
181
181
token:: Interpolated ( ref nt) => match * * nt {
182
- Nonterminal :: NtMeta ( ref meta ) => Some ( meta . clone ( ) ) ,
182
+ Nonterminal :: NtMeta ( ref item ) => Some ( item . clone ( ) ) ,
183
183
_ => None ,
184
184
} ,
185
185
_ => None ,
186
186
} ;
187
- Ok ( if let Some ( meta ) = meta {
187
+ Ok ( if let Some ( item ) = item {
188
188
self . bump ( ) ;
189
- ( meta . path , meta . node . tokens ( meta . span ) )
189
+ item
190
190
} else {
191
191
let path = self . parse_path ( PathStyle :: Mod ) ?;
192
192
let tokens = if self . check ( & token:: OpenDelim ( DelimToken :: Paren ) ) ||
@@ -213,7 +213,7 @@ impl<'a> Parser<'a> {
213
213
} else {
214
214
TokenStream :: empty ( )
215
215
} ;
216
- ( path, tokens)
216
+ ast :: AttrItem { path, tokens }
217
217
} )
218
218
}
219
219
@@ -281,9 +281,14 @@ impl<'a> Parser<'a> {
281
281
_ => None ,
282
282
} ;
283
283
284
- if let Some ( meta) = nt_meta {
285
- self . bump ( ) ;
286
- return Ok ( meta) ;
284
+ if let Some ( item) = nt_meta {
285
+ return match item. meta ( item. path . span ) {
286
+ Some ( meta) => {
287
+ self . bump ( ) ;
288
+ Ok ( meta)
289
+ }
290
+ None => self . unexpected ( ) ,
291
+ }
287
292
}
288
293
289
294
let lo = self . token . span ;
0 commit comments