rustc_parse::parser

Type Alias ParserReplacement

Source
type ParserReplacement = (ParserRange, Option<AttrsTarget>);
Expand description

Indicates a range of tokens that should be replaced by an AttrsTarget (replacement) or be replaced by nothing (deletion). This is used in two places during token collection.

  1. Replacement. During the parsing of an AST node that may have a #[derive] attribute, when we parse a nested AST node that has #[cfg] or #[cfg_attr], we replace the entire inner AST node with FlatToken::AttrsTarget. This lets us perform eager cfg-expansion on an AttrTokenStream.

  2. Deletion. We delete inner attributes from all collected token streams, and instead track them through the attrs field on the AST node. This lets us manipulate them similarly to outer attributes. When we create a TokenStream, the inner attributes are inserted into the proper place in the token stream.

Each replacement starts off in ParserReplacement form but is converted to NodeReplacement form when it is attached to a single AST node, via LazyAttrTokenStreamImpl.

Layout§

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: 24 bytes