|
1 | 1 | use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor, TrailingToken}; |
2 | 2 | use rustc_ast::token::{self, Delimiter, Token, TokenKind}; |
3 | | -use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, AttributesData, DelimSpacing}; |
| 3 | +use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, AttrsTarget, DelimSpacing}; |
4 | 4 | use rustc_ast::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, ToAttrTokenStream}; |
5 | 5 | use rustc_ast::{self as ast}; |
6 | 6 | use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens}; |
@@ -145,22 +145,22 @@ impl ToAttrTokenStream for LazyAttrTokenStreamImpl { |
145 | 145 | // start position, we ensure that any replace range which encloses |
146 | 146 | // another replace range will capture the *replaced* tokens for the inner |
147 | 147 | // range, not the original tokens. |
148 | | - for (range, attr_data) in replace_ranges.into_iter().rev() { |
| 148 | + for (range, target) in replace_ranges.into_iter().rev() { |
149 | 149 | assert!(!range.is_empty(), "Cannot replace an empty range: {range:?}"); |
150 | 150 |
|
151 | | - // Replace the tokens in range with zero or one `FlatToken::AttrTarget`s, plus |
| 151 | + // Replace the tokens in range with zero or one `FlatToken::AttrsTarget`s, plus |
152 | 152 | // enough `FlatToken::Empty`s to fill up the rest of the range. This keeps the |
153 | 153 | // total length of `tokens` constant throughout the replacement process, allowing |
154 | 154 | // us to use all of the `ReplaceRanges` entries without adjusting indices. |
155 | | - let attr_data_len = attr_data.is_some() as usize; |
| 155 | + let target_len = target.is_some() as usize; |
156 | 156 | tokens.splice( |
157 | 157 | (range.start as usize)..(range.end as usize), |
158 | | - attr_data |
| 158 | + target |
159 | 159 | .into_iter() |
160 | | - .map(|attr_data| (FlatToken::AttrTarget(attr_data), Spacing::Alone)) |
| 160 | + .map(|target| (FlatToken::AttrsTarget(target), Spacing::Alone)) |
161 | 161 | .chain( |
162 | 162 | iter::repeat((FlatToken::Empty, Spacing::Alone)) |
163 | | - .take(range.len() - attr_data_len), |
| 163 | + .take(range.len() - target_len), |
164 | 164 | ), |
165 | 165 | ); |
166 | 166 | } |
@@ -346,13 +346,12 @@ impl<'a> Parser<'a> { |
346 | 346 | { |
347 | 347 | assert!(!self.break_last_token, "Should not have unglued last token with cfg attr"); |
348 | 348 |
|
349 | | - // Replace the entire AST node that we just parsed, including attributes, |
350 | | - // with `attr_data`. If this AST node is inside an item |
351 | | - // that has `#[derive]`, then this will allow us to cfg-expand this |
352 | | - // AST node. |
| 349 | + // Replace the entire AST node that we just parsed, including attributes, with |
| 350 | + // `target`. If this AST node is inside an item that has `#[derive]`, then this will |
| 351 | + // allow us to cfg-expand this AST node. |
353 | 352 | let start_pos = if has_outer_attrs { attrs.start_pos } else { start_pos }; |
354 | | - let attr_data = AttributesData { attrs: final_attrs.iter().cloned().collect(), tokens }; |
355 | | - self.capture_state.replace_ranges.push((start_pos..end_pos, Some(attr_data))); |
| 353 | + let target = AttrsTarget { attrs: final_attrs.iter().cloned().collect(), tokens }; |
| 354 | + self.capture_state.replace_ranges.push((start_pos..end_pos, Some(target))); |
356 | 355 | self.capture_state.replace_ranges.extend(inner_attr_replace_ranges); |
357 | 356 | } |
358 | 357 |
|
@@ -414,11 +413,11 @@ fn make_attr_token_stream( |
414 | 413 | .expect("Bottom token frame is missing!") |
415 | 414 | .inner |
416 | 415 | .push(AttrTokenTree::Token(token, spacing)), |
417 | | - FlatToken::AttrTarget(data) => stack |
| 416 | + FlatToken::AttrsTarget(target) => stack |
418 | 417 | .last_mut() |
419 | 418 | .expect("Bottom token frame is missing!") |
420 | 419 | .inner |
421 | | - .push(AttrTokenTree::Attributes(data)), |
| 420 | + .push(AttrTokenTree::AttrsTarget(target)), |
422 | 421 | FlatToken::Empty => {} |
423 | 422 | } |
424 | 423 | token_and_spacing = iter.next(); |
|
0 commit comments