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

Require passing an AttrWrapper to collect_tokens_trailing_token #81286

Merged
merged 2 commits into from
Feb 14, 2021

Commits on Feb 13, 2021

  1. Require passing an AttrWrapper to collect_tokens_trailing_token

    This is a pure refactoring split out from rust-lang#80689.
    It represents the most invasive part of that PR, requiring changes in
    every caller of `parse_outer_attributes`
    
    In order to eagerly expand `#[cfg]` attributes while preserving the
    original `TokenStream`, we need to know the range of tokens that
    corresponds to every attribute target. This is accomplished by making
    `parse_outer_attributes` return an opaque `AttrWrapper` struct. An
    `AttrWrapper` must be converted to a plain `AttrVec` by passing it to
    `collect_tokens_trailing_token`. This makes it difficult to accidentally
    construct an AST node with attributes without calling `collect_tokens_trailing_token`,
    since AST nodes store an `AttrVec`, not an `AttrWrapper`.
    
    As a result, we now call `collect_tokens_trailing_token` for attribute
    targets which only support inert attributes, such as generic arguments
    and struct fields. Currently, the constructed `LazyTokenStream` is
    simply discarded. Future PRs will record the token range corresponding
    to the attribute target, allowing those tokens to be removed from an
    enclosing `collect_tokens_trailing_token` call if necessary.
    Aaron1011 committed Feb 13, 2021
    Configuration menu
    Copy the full SHA
    0b411f5 View commit details
    Browse the repository at this point in the history
  2. Address review comments

    Aaron1011 committed Feb 13, 2021
    Configuration menu
    Copy the full SHA
    3321d70 View commit details
    Browse the repository at this point in the history