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 HIRcompiler/rustc_hir/src/
CompilerstructRepresents a compiler session and can be used to drive a compilation.The Rustc Driver and Interfacecompiler/rustc_interface/src/
ast::CratestructA syntax-level representation of a parsed crateThe parsercompiler/rustc_ast/src/
rustc_hir::CratestructA more abstract, compiler-friendly form of a crate's ASTThe Hircompiler/rustc_hir/src/
DefIdstructOne of four types of HIR node identifiersIdentifiers in the HIRcompiler/rustc_hir/src/
DiagstructA struct for a compiler diagnostic, such as an error or lintEmitting Diagnosticscompiler/rustc_errors/src/
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 HIRcompiler/rustc_hir/src/
NodeIdstructOne of four types of HIR node identifiers. Being phased outIdentifiers in the HIRcompiler/rustc_ast/src/
PstructAn owned immutable smart pointer. By contrast, &T is not owned, and Box<T> is not immutable.Nonecompiler/rustc_ast/src/
ParamEnvstructInformation about generic parameters or Self, useful for working with associated or generic itemsParameter Environmentcompiler/rustc_middle/src/ty/
ParseSessstructThis struct contains information about a parsing sessionThe parsercompiler/rustc_session/src/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 Interfacecompiler/rustc_interface/src/
RibstructRepresents a single scope of namesName resolutioncompiler/rustc_resolve/src/
SessionstructThe data associated with a compilation sessionThe parser, The Rustc Driver and Interfacecompiler/rustc_session/src/
SourceFilestructPart of the SourceMap. Maps AST nodes to their source code for a single source file. Was previously called FileMapThe parsercompiler/rustc_span/src/
SourceMapstructMaps AST nodes to their source code. It is composed of SourceFiles. Was previously called CodeMapThe parsercompiler/rustc_span/src/
SpanstructA location in the user's source code, used for error reporting primarilyEmitting Diagnosticscompiler/rustc_span/src/
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 parsercompiler/rustc_parse/src/lexer/
rustc_ast::token_stream::TokenStreamstructAn abstract sequence of tokens, organized into TokenTreesThe parser, Macro expansioncompiler/rustc_ast/src/
TraitDefstructThis struct contains a trait's definition with type informationThe ty modulescompiler/rustc_middle/src/ty/
TraitRefstructThe combination of a trait and its input types (e.g. P0: Trait<P1...Pn>)Trait Solving: Goals and Clausescompiler/rustc_middle/src/ty/
Ty<'tcx>structThis is the internal representation of a type used for type checkingType checkingcompiler/rustc_middle/src/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 modulescompiler/rustc_middle/src/ty/