rust/compiler/rustc_ast/src
Aaron Hill 0b411f56e1
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.
2021-02-13 12:07:15 -05:00
..
ast mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
attr Replace let Some(..) = with .is_some() 2021-01-17 19:06:12 -05:00
expand mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
util Remove unnecessary manual shrink_to_fit calls 2021-01-16 14:02:36 +01:00
ast.rs Require passing an AttrWrapper to collect_tokens_trailing_token 2021-02-13 12:07:15 -05:00
crate_disambiguator.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
entry.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
lib.rs Stabilize feature(iterator_fold_self): Iterator::reduce 2021-02-04 11:31:11 +01:00
mut_visit.rs Make panic/assert calls in rustc compatible with Rust 2021. 2021-02-03 22:42:53 +01:00
node_id.rs Clarify docs for DUMMY_NODE_ID 2021-02-07 19:42:12 -08:00
ptr.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
token.rs rustc_parse: Better spans for synthesized token streams 2021-01-07 17:48:13 +03:00
tokenstream.rs Refactor token collection to capture trailing token immediately 2021-01-22 00:33:03 -05:00
visit.rs Box the biggest ast::ItemKind variants 2021-02-01 09:23:39 +01:00