[][src]Module rustc_span::symbol

An "interner" is a data structure that associates values with usize tags and allows bidirectional lookup; i.e., given a value, one can easily find the type, and vice versa.

Modules

kw

This module contains all the defined keyword Symbols.

sym

This module contains all the defined non-keyword Symbols.

Structs

Ident
IdentPrinter

This is the most general way to print identifiers. AST pretty-printer is used as a fallback for turning AST structures into token streams for proc macros. Additionally, proc macros may stringify their input and expect it survive the stringification (especially true for proc macro derives written between Rust 1.15 and 1.30). So we need to somehow pretty-print $crate in a way preserving at least some of its hygiene data, most importantly name of the crate it refers to. As a result we print $crate as crate if it refers to the local crate and as ::other_crate_name if it refers to some other crate. Note, that this is only done if the ident token is printed from inside of AST pretty-pringing, but not otherwise. Pretty-printing is the only way for proc macros to discover token contents, so we should not perform this lossy conversion if the top level call to the pretty-printer was done for a token stream or a single token.

Interner
MacroRulesNormalizedIdent

An newtype around Ident that calls Ident::normalize_to_macro_rules on construction.

Symbol

An interned string.

SymbolIndex
SymbolStr

An alternative to Symbol, useful when the chars within the symbol need to be accessed. It deliberately has limited functionality and should only be used for temporary values.

Constants

SYMBOL_DIGITS_BASE

Functions

with_interner