Skip to content

Commit

Permalink
Rename FlatToken::AttrTarget as FlatToken::Attributes.
Browse files Browse the repository at this point in the history
So it matches the closely related `AttrTokenTree::Attributes` variant.
  • Loading branch information
nnethercote committed Jul 4, 2024
1 parent c73191a commit 406244b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_parse/src/parser/attr_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
for (range, attr_data) in replace_ranges.into_iter().rev() {
assert!(!range.is_empty(), "Cannot replace an empty range: {range:?}");

// Replace the tokens in range with zero or one `FlatToken::AttrTarget`s, plus
// Replace the tokens in range with zero or one `FlatToken::Attribute`s, plus
// enough `FlatToken::Empty`s to fill up the rest of the range. This keeps the
// total length of `tokens` constant throughout the replacement process, allowing
// us to use all of the `ReplaceRanges` entries without adjusting indices.
Expand All @@ -157,7 +157,7 @@ impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
(range.start as usize)..(range.end as usize),
attr_data
.into_iter()
.map(|attr_data| (FlatToken::AttrTarget(attr_data), Spacing::Alone))
.map(|attr_data| (FlatToken::Attributes(attr_data), Spacing::Alone))
.chain(
iter::repeat((FlatToken::Empty, Spacing::Alone))
.take(range.len() - attr_data_len),
Expand Down Expand Up @@ -414,7 +414,7 @@ fn make_attr_token_stream(
.expect("Bottom token frame is missing!")
.inner
.push(AttrTokenTree::Token(token, spacing)),
FlatToken::AttrTarget(data) => stack
FlatToken::Attributes(data) => stack
.last_mut()
.expect("Bottom token frame is missing!")
.inner
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ struct ClosureSpans {
/// 1. During the parsing of an AST node that may have a `#[derive]`
/// attribute, we parse a nested AST node that has `#[cfg]` or `#[cfg_attr]`
/// In this case, we use a `ReplaceRange` to replace the entire inner AST node
/// with `FlatToken::AttrTarget`, allowing us to perform eager cfg-expansion
/// with `FlatToken::Attributes`, allowing us to perform eager cfg-expansion
/// on an `AttrTokenStream`.
///
/// 2. When we parse an inner attribute while collecting tokens. We
Expand Down Expand Up @@ -1612,7 +1612,7 @@ enum FlatToken {
/// `AttributesData` is inserted directly into the
/// constructed `AttrTokenStream` as
/// an `AttrTokenTree::Attributes`.
AttrTarget(AttributesData),
Attributes(AttributesData),
/// A special 'empty' token that is ignored during the conversion
/// to an `AttrTokenStream`. This is used to simplify the
/// handling of replace ranges.
Expand Down

0 comments on commit 406244b

Please sign in to comment.