about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-14 15:00:52 +0000
committerbors <bors@rust-lang.org>2021-02-14 15:00:52 +0000
commit5fa22fe6f821ac3801d05f624b123dda25fde32c (patch)
tree2c773140aace7b0b477a108bf12f869faf5781c9 /compiler/rustc_codegen_llvm/src
parentb86674e7cc8ac9c846ed5aca84aaefc2d0d12e4a (diff)
parent3321d701617d5ba3ef348d9273f5fcca126d8f04 (diff)
downloadrust-5fa22fe6f821ac3801d05f624b123dda25fde32c.tar.gz
rust-5fa22fe6f821ac3801d05f624b123dda25fde32c.zip
Auto merge of #81286 - Aaron1011:collect-tokens-attrs, r=petrochenkov
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