Skip to content

Commit a5e7b0e

Browse files
committed
Remove final_attrs local variable.
It's no shorter than `ret.attrs()`, and `ret.attrs()` is used multiple times earlier in the function.
1 parent b352814 commit a5e7b0e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

compiler/rustc_parse/src/parser/attr_wrapper.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,23 +325,21 @@ impl<'a> Parser<'a> {
325325
*target_tokens = Some(tokens.clone());
326326
}
327327

328-
let final_attrs = ret.attrs();
329-
330328
// If `capture_cfg` is set and we're inside a recursive call to
331329
// `collect_tokens_trailing_token`, then we need to register a replace range
332330
// if we have `#[cfg]` or `#[cfg_attr]`. This allows us to run eager cfg-expansion
333331
// on the captured token stream.
334332
if self.capture_cfg
335333
&& matches!(self.capture_state.capturing, Capturing::Yes)
336-
&& has_cfg_or_cfg_attr(final_attrs)
334+
&& has_cfg_or_cfg_attr(ret.attrs())
337335
{
338336
assert!(!self.break_last_token, "Should not have unglued last token with cfg attr");
339337

340338
// Replace the entire AST node that we just parsed, including attributes, with
341339
// `target`. If this AST node is inside an item that has `#[derive]`, then this will
342340
// allow us to cfg-expand this AST node.
343341
let start_pos = if has_outer_attrs { attrs.start_pos } else { start_pos };
344-
let target = AttrsTarget { attrs: final_attrs.iter().cloned().collect(), tokens };
342+
let target = AttrsTarget { attrs: ret.attrs().iter().cloned().collect(), tokens };
345343
self.capture_state.replace_ranges.push((start_pos..end_pos, Some(target)));
346344
self.capture_state.replace_ranges.extend(inner_attr_replace_ranges);
347345
} else if matches!(self.capture_state.capturing, Capturing::No) {

0 commit comments

Comments
 (0)