Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute cleanups #127308

Merged
merged 9 commits into from
Jul 7, 2024
Merged

Attribute cleanups #127308

merged 9 commits into from
Jul 7, 2024

Commits on Jul 4, 2024

  1. Remove some unnecessary integer conversions.

    These should have been removed in rust-lang#127233 when the positions were
    changed from `usize` to `u32`.
    nnethercote committed Jul 4, 2024
    Configuration menu
    Copy the full SHA
    dd790ab View commit details
    Browse the repository at this point in the history

Commits on Jul 7, 2024

  1. Rename Attribute::tokens (the inherent method).

    To distinguish it from the `HasTokens` method.
    nnethercote committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    14b859f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    88373e9 View commit details
    Browse the repository at this point in the history
  3. Remove HasSpan trait.

    The only place it is meaningfully used is in a panic message in
    `TokenStream::from_ast`. But `node.span()` doesn't need to be printed
    because `node` is also printed and it must contain the span.
    nnethercote committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    b261501 View commit details
    Browse the repository at this point in the history
  4. Simplify ReplaceRange.

    Currently the second element is a `Vec<(FlatToken, Spacing)>`. But the
    vector always has zero or one elements, and the `FlatToken` is always
    `FlatToken::AttrTarget` (which contains an `AttributesData`), and the
    spacing is always `Alone`. So we can simplify it to
    `Option<AttributesData>`.
    
    An assertion in `to_attr_token_stream` can can also be removed, because
    `new_tokens.len()` was always 0 or 1, which means than `range.len()`
    is always greater than or equal to it, because `range.is_empty()` is
    always false (as per the earlier assertion).
    nnethercote committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    9d33a8f View commit details
    Browse the repository at this point in the history
  5. Rename some attribute types for consistency.

    - `AttributesData` -> `AttrsTarget`
    - `AttrTokenTree::Attributes` -> `AttrTokenTree::AttrsTarget`
    - `FlatToken::AttrTarget` -> `FlatToken::AttrsTarget`
    nnethercote committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    3a5c4b6 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    022582c View commit details
    Browse the repository at this point in the history
  7. Add an size assertion.

    `Option<LazyAttrTokenStream>` is the type that's actually used in all
    the aST nodes.
    nnethercote committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    9f16f1f View commit details
    Browse the repository at this point in the history
  8. Use filter_map instead of flat_map in configure_tokens.

    All the branches produce either zero or one elements.
    nnethercote committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    9e0aab7 View commit details
    Browse the repository at this point in the history