Appendix D: Code Index

rustc has a lot of important data structures. This is an attempt to give some guidance on where to learn more about some of the key data structures of the compiler.

ItemKindShort descriptionChapterDeclaration
BodyIdstructOne of four types of HIR node identifiersIdentifiers in the HIRsrc/librustc/hir/mod.rs
CompilerstructRepresents a compiler session and can be used to drive a compilation.The Rustc Driver and Interfacesrc/librustc_interface/interface.rs
ast::CratestructA syntax-level representation of a parsed crateThe parsersrc/librustc/hir/mod.rs
hir::CratestructA more abstract, compiler-friendly form of a crate's ASTThe Hirsrc/librustc/hir/mod.rs
DefIdstructOne of four types of HIR node identifiersIdentifiers in the HIRsrc/librustc/hir/def_id.rs
DiagnosticBuilderstructA struct for building up compiler diagnostics, such as errors or lintsEmitting Diagnosticssrc/librustc_errors/diagnostic_builder.rs
DocContextstructA state container used by rustdoc when crawling through a crate to gather its documentationRustdocsrc/librustdoc/core.rs
HirIdstructOne of four types of HIR node identifiersIdentifiers in the HIRsrc/librustc/hir/mod.rs
NodeIdstructOne of four types of HIR node identifiers. Being phased outIdentifiers in the HIRsrc/libsyntax/ast.rs
PstructAn owned immutable smart pointer. By contrast, &T is not owned, and Box<T> is not immutable.Nonesrc/syntax/ptr.rs
ParamEnvstructInformation about generic parameters or Self, useful for working with associated or generic itemsParameter Environmentsrc/librustc/ty/mod.rs
ParseSessstructThis struct contains information about a parsing sessionThe parsersrc/libsyntax/parse/mod.rs
QuerystructRepresents the result of query to the Compiler interface and allows stealing, borrowing, and returning the results of compiler passes.The Rustc Driver and Interfacesrc/librustc_interface/queries.rs
RibstructRepresents a single scope of namesName resolutionsrc/librustc_resolve/lib.rs
SessionstructThe data associated with a compilation sessionThe parser, The Rustc Driver and Interfacesrc/librustc/session/mod.html
SourceFilestructPart of the SourceMap. Maps AST nodes to their source code for a single source file. Was previously called FileMapThe parsersrc/libsyntax_pos/lib.rs
SourceMapstructMaps AST nodes to their source code. It is composed of SourceFiles. Was previously called CodeMapThe parsersrc/libsyntax/source_map.rs
SpanstructA location in the user's source code, used for error reporting primarilyEmitting Diagnosticssrc/libsyntax_pos/span_encoding.rs
StringReaderstructThis is the lexer used during parsing. It consumes characters from the raw source code being compiled and produces a series of tokens for use by the rest of the parserThe parsersrc/libsyntax/parse/lexer/mod.rs
syntax::token_stream::TokenStreamstructAn abstract sequence of tokens, organized into TokenTreesThe parser, Macro expansionsrc/libsyntax/tokenstream.rs
TraitDefstructThis struct contains a trait's definition with type informationThe ty modulessrc/librustc/ty/trait_def.rs
TraitRefstructThe combination of a trait and its input types (e.g. P0: Trait<P1...Pn>)Trait Solving: Goals and Clauses, Trait Solving: Lowering implssrc/librustc/ty/sty.rs
Ty<'tcx>structThis is the internal representation of a type used for type checkingType checkingsrc/librustc/ty/mod.rs
TyCtxt<'tcx>structThe "typing context". This is the central data structure in the compiler. It is the context that you use to perform all manner of queriesThe ty modulessrc/librustc/ty/context.rs