Type Definition rustc_ap_rustc_parse::parser::ReplaceRange[][src]

type ReplaceRange = (Range<u32>, Vec<(FlatToken, Spacing)>);
Expand description

Indicates a range of tokens that should be replaced by the tokens in the provided vector. This is used in two places during token collection:

  1. During the parsing of an AST node that may have a #[derive] attribute, we parse a nested AST node that has #[cfg] or #[cfg_attr] In this case, we use a ReplaceRange to replace the entire inner AST node with FlatToken::AttrTarget, allowing us to perform eager cfg-expansion on a AttrAnnotatedTokenStream

  2. When we parse an inner attribute while collecting tokens. We remove inner attributes from the token stream entirely, and instead track them through the attrs field on the AST node. This allows us to easily manipulate them (for example, removing the first macro inner attribute to invoke a proc-macro). When create a TokenStream, the inner attributes get inserted into the proper place in the token stream.