about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2021-01-22 13:28:08 -0500
committerAaron Hill <aa1ronham@gmail.com>2021-02-13 12:07:15 -0500
commit0b411f56e1a539e2388e9a983feb45f362923dc5 (patch)
treea630893ab6e51faada2847b807e38afb28949270 /compiler/rustc_codegen_llvm/src
parent7e0241c63755ea28045d512b742f50b307874419 (diff)
downloadrust-0b411f56e1a539e2388e9a983feb45f362923dc5.tar.gz
rust-0b411f56e1a539e2388e9a983feb45f362923dc5.zip
Require passing an `AttrWrapper` to `collect_tokens_trailing_token`
This is a pure refactoring split out from #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.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions