@@ -313,23 +313,21 @@ impl<'a> Parser<'a> {
313313 * target_tokens = Some ( tokens. clone ( ) ) ;
314314 }
315315
316- let final_attrs = ret. attrs ( ) ;
317-
318316 // If `capture_cfg` is set and we're inside a recursive call to
319317 // `collect_tokens_trailing_token`, then we need to register a replace range
320318 // if we have `#[cfg]` or `#[cfg_attr]`. This allows us to run eager cfg-expansion
321319 // on the captured token stream.
322320 if self . capture_cfg
323321 && matches ! ( self . capture_state. capturing, Capturing :: Yes )
324- && has_cfg_or_cfg_attr ( final_attrs )
322+ && has_cfg_or_cfg_attr ( ret . attrs ( ) )
325323 {
326324 assert ! ( !self . break_last_token, "Should not have unglued last token with cfg attr" ) ;
327325
328326 // Replace the entire AST node that we just parsed, including attributes, with
329327 // `target`. If this AST node is inside an item that has `#[derive]`, then this will
330328 // allow us to cfg-expand this AST node.
331329 let start_pos = if has_outer_attrs { attrs. start_pos } else { start_pos } ;
332- let target = AttrsTarget { attrs : final_attrs . iter ( ) . cloned ( ) . collect ( ) , tokens } ;
330+ let target = AttrsTarget { attrs : ret . attrs ( ) . iter ( ) . cloned ( ) . collect ( ) , tokens } ;
333331 self . capture_state . replace_ranges . push ( ( start_pos..end_pos, Some ( target) ) ) ;
334332 self . capture_state . replace_ranges . extend ( inner_attr_replace_ranges) ;
335333 } else if matches ! ( self . capture_state. capturing, Capturing :: No ) {
0 commit comments