Type Alias rustc_parse::parser::ReplaceRange

source ·
pub 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 an AttrTokenStream.

  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.


Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes