Expand description
Re-exportsΒ§
use std::borrow::Cow;πuse std::hash::Hash;πuse std::hash::Hash;πuse std::ops::Range;πuse std::sync::Arc;πuse std::sync::LazyLock;πuse std::cmp;πuse std::fmt;πuse std::iter;πuse std::mem;πuse rustc_data_structures::stable_hash::StableHash;πuse rustc_data_structures::stable_hash::StableHashCtxt;πuse rustc_data_structures::stable_hash::StableHasher;πuse rustc_data_structures::sync;πuse rustc_macros::Decodable;πuse rustc_macros::Encodable;πuse rustc_macros::StableHash;πuse rustc_macros::Walkable;πuse rustc_serialize::Decodable;πuse rustc_serialize::Encodable;πuse rustc_span::DUMMY_SP;πuse rustc_span::Span;πuse rustc_span::SpanDecoder;πuse rustc_span::SpanEncoder;πuse rustc_span::Symbol;πuse rustc_span::sym;πuse thin_vec::ThinVec;πuse crate::ast::AttrStyle;πuse crate::ast_traits::HasTokens;πuse crate::token;πuse crate::token::Delimiter;πuse crate::token::Token;πuse crate::token::TokenKind;πuse crate::AttrVec;πuse crate::Attribute;π
ModulesΒ§
- size_
asserts π
StructsΒ§
- Attrs
Target - Stores the tokens for an attribute target, along with its attributes.
- Delim
Spacing - Delim
Span - Lazy
Token Stream - A lazy version of
TokenStream, which defers creation of an actualTokenStreamuntil it is needed. - Node
Range - A token range within an individual AST nodeβs (lazy) token stream, i.e.
relative to that nodeβs first token. Distinct from
ParserRangeso the two kinds of range canβt be mixed up. - Parser
Range - A token range within a
Parserβs full token stream. - Token
Cursor - A
TokenStreamcursor that producesTokens. Itβs a bit odd that we (a) lex tokens into a nice tree structure (TokenStream), and then (b) use this type to emit them as a linear sequence. But a linear sequence is what the parser expects, for the most part. - Token
Stream - A
TokenStreamis an abstract sequence of tokens, organized intoTokenTrees. - Token
Stream Iter - Token
Tree πCursor - With
Tokens
EnumsΒ§
- Flat
Token π - A helper struct used when building a
TokenStreamfrom aLazyTokenStream. Both delimiter and non-delimited tokens are stored asFlatToken::Token. A vector ofFlatTokens is then βparsedβ to build up aTokenStreamwith nestedTokenTree::Delimitedtokens. - Lazy
Token πStream Inner - Spacing
- Indicates whether a token can join with the following token to form a
compound token. Used for conversions to
proc_macro::Spacing. Also used to guide pretty-printing, which is where theJointHiddenvalue (which isnβt part ofproc_macro::Spacing) comes in useful. - Token
Tree - Part of a
TokenStream.
StaticsΒ§
- EMPTY_
TOKEN_ πSTREAM - A shared empty token stream, used to avoid an unnecessary
Arcallocation for every empty token stream.
FunctionsΒ§
- _dummy π
- append_
attrs_ πand_ stream_ as_ token_ trees_ to - append_
flat_ πtokens_ as_ token_ trees_ to - Converts a flattened iterator of tokens (including open and close delimiter tokens) into a
sequence of
TokenTree(appended tores), creating aTokenTree::Delimitedfor each matching pair of open and close delims. AnyFlatToken::AttrsTargetelement will only be appended ifconfiguresucceeds, andconfigurecan also modify any such element. - keep_
all π - A
ConfigureFnthat keeps the target, i.e. the node and its tokens.
Type AliasesΒ§
- Configure
Fn π - Fn type used to do (or not do)
cfgexpansion. It can modify attributes. The return value indicates if the target should be retained. Any children of discarded targets are skipped. - Node
Replacement - See the comment on
ParserReplacement. - Parser
Replacement - 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.