diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-12 16:03:51 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-19 15:25:54 +1000 |
| commit | 1f67cf9e63258c57d35e8d75a2dcfa5f2e4b5cf3 (patch) | |
| tree | 0422c6280bc994a16fbc5f350ffc0982c73c40c2 /compiler/rustc_parse/src | |
| parent | 757f73f506a48ff96de54c0cb8c79a25ffbc70d9 (diff) | |
| download | rust-1f67cf9e63258c57d35e8d75a2dcfa5f2e4b5cf3.tar.gz rust-1f67cf9e63258c57d35e8d75a2dcfa5f2e4b5cf3.zip | |
Remove `final_attrs` local variable.
It's no shorter than `ret.attrs()`, and `ret.attrs()` is used multiple times earlier in the function.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/attr_wrapper.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index efe9c55f523..1743cb0bdbc 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -313,15 +313,13 @@ impl<'a> Parser<'a> { *target_tokens = Some(tokens.clone()); } - let final_attrs = ret.attrs(); - // If `capture_cfg` is set and we're inside a recursive call to // `collect_tokens_trailing_token`, then we need to register a replace range // if we have `#[cfg]` or `#[cfg_attr]`. This allows us to run eager cfg-expansion // on the captured token stream. if self.capture_cfg && matches!(self.capture_state.capturing, Capturing::Yes) - && has_cfg_or_cfg_attr(final_attrs) + && has_cfg_or_cfg_attr(ret.attrs()) { assert!(!self.break_last_token, "Should not have unglued last token with cfg attr"); @@ -329,7 +327,7 @@ impl<'a> Parser<'a> { // `target`. If this AST node is inside an item that has `#[derive]`, then this will // allow us to cfg-expand this AST node. let start_pos = if has_outer_attrs { attrs.start_pos } else { start_pos }; - let target = AttrsTarget { attrs: final_attrs.iter().cloned().collect(), tokens }; + let target = AttrsTarget { attrs: ret.attrs().iter().cloned().collect(), tokens }; self.capture_state.replace_ranges.push((start_pos..end_pos, Some(target))); self.capture_state.replace_ranges.extend(inner_attr_replace_ranges); } else if matches!(self.capture_state.capturing, Capturing::No) { |
