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/
CompilerstructRepresents a compiler session and can be used to drive a compilation.The Rustc Driver and Interfacesrc/librustc_interface/
ast::CratestructA syntax-level representation of a parsed crateThe parsersrc/librustc_ast/
rustc_hir::CratestructA more abstract, compiler-friendly form of a crate's ASTThe Hirsrc/librustc_hir/
DefIdstructOne of four types of HIR node identifiersIdentifiers in the HIRsrc/librustc_hir/
DiagnosticBuilderstructA struct for building up compiler diagnostics, such as errors or lintsEmitting Diagnosticssrc/librustc_errors/
DocContextstructA state container used by rustdoc when crawling through a crate to gather its documentationRustdocsrc/librustdoc/
HirIdstructOne of four types of HIR node identifiersIdentifiers in the HIRsrc/librustc_hir/
NodeIdstructOne of four types of HIR node identifiers. Being phased outIdentifiers in the HIRsrc/librustc_ast/
PstructAn owned immutable smart pointer. By contrast, &T is not owned, and Box<T> is not immutable.Nonesrc/librustc_ast/
ParamEnvstructInformation about generic parameters or Self, useful for working with associated or generic itemsParameter Environmentsrc/librustc_middle/ty/
ParseSessstructThis struct contains information about a parsing sessionThe parsersrc/librustc_session/parse/
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/
RibstructRepresents a single scope of namesName resolutionsrc/librustc_resolve/
SessionstructThe data associated with a compilation sessionThe parser, The Rustc Driver and Interfacesrc/librustc_middle/session/mod.html
SourceFilestructPart of the SourceMap. Maps AST nodes to their source code for a single source file. Was previously called FileMapThe parsersrc/librustc_span/
SourceMapstructMaps AST nodes to their source code. It is composed of SourceFiles. Was previously called CodeMapThe parsersrc/librustc_span/
SpanstructA location in the user's source code, used for error reporting primarilyEmitting Diagnosticssrc/librustc_span/
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/librustc_parse/lexer/
rustc_ast::token_stream::TokenStreamstructAn abstract sequence of tokens, organized into TokenTreesThe parser, Macro expansionsrc/librustc_ast/
TraitDefstructThis struct contains a trait's definition with type informationThe ty modulessrc/librustc_middle/ty/
TraitRefstructThe combination of a trait and its input types (e.g. P0: Trait<P1...Pn>)Trait Solving: Goals and Clausessrc/librustc_middle/ty/
Ty<'tcx>structThis is the internal representation of a type used for type checkingType checkingsrc/librustc_middle/ty/
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_middle/ty/