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.
Item | Kind | Short description | Chapter | Declaration |
---|---|---|---|---|
BodyId |
struct | One of four types of HIR node identifiers | Identifiers in the HIR | src/librustc/hir/mod.rs |
Compiler |
struct | Represents a compiler session and can be used to drive a compilation. | The Rustc Driver and Interface | src/librustc_interface/interface.rs |
ast::Crate |
struct | A syntax-level representation of a parsed crate | The parser | src/librustc/hir/mod.rs |
hir::Crate |
struct | A more abstract, compiler-friendly form of a crate's AST | The Hir | src/librustc/hir/mod.rs |
DefId |
struct | One of four types of HIR node identifiers | Identifiers in the HIR | src/librustc/hir/def_id.rs |
DiagnosticBuilder |
struct | A struct for building up compiler diagnostics, such as errors or lints | Emitting Diagnostics | src/librustc_errors/diagnostic_builder.rs |
DocContext |
struct | A state container used by rustdoc when crawling through a crate to gather its documentation | Rustdoc | src/librustdoc/core.rs |
HirId |
struct | One of four types of HIR node identifiers | Identifiers in the HIR | src/librustc/hir/mod.rs |
NodeId |
struct | One of four types of HIR node identifiers. Being phased out | Identifiers in the HIR | src/libsyntax/ast.rs |
P |
struct | An owned immutable smart pointer. By contrast, &T is not owned, and Box<T> is not immutable. |
None | src/syntax/ptr.rs |
ParamEnv |
struct | Information about generic parameters or Self , useful for working with associated or generic items |
Parameter Environment | src/librustc/ty/mod.rs |
ParseSess |
struct | This struct contains information about a parsing session | The parser | src/libsyntax/parse/mod.rs |
Query |
struct | Represents the result of query to the Compiler interface and allows stealing, borrowing, and returning the results of compiler passes. |
The Rustc Driver and Interface | src/librustc_interface/queries.rs |
Rib |
struct | Represents a single scope of names | Name resolution | src/librustc_resolve/lib.rs |
Session |
struct | The data associated with a compilation session | The parser, The Rustc Driver and Interface | src/librustc/session/mod.html |
SourceFile |
struct | Part of the SourceMap . Maps AST nodes to their source code for a single source file. Was previously called FileMap |
The parser | src/libsyntax_pos/lib.rs |
SourceMap |
struct | Maps AST nodes to their source code. It is composed of SourceFile s. Was previously called CodeMap |
The parser | src/libsyntax/source_map.rs |
Span |
struct | A location in the user's source code, used for error reporting primarily | Emitting Diagnostics | src/libsyntax_pos/span_encoding.rs |
StringReader |
struct | This 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 parser | The parser | src/libsyntax/parse/lexer/mod.rs |
syntax::token_stream::TokenStream |
struct | An abstract sequence of tokens, organized into TokenTree s |
The parser, Macro expansion | src/libsyntax/tokenstream.rs |
TraitDef |
struct | This struct contains a trait's definition with type information | The ty modules |
src/librustc/ty/trait_def.rs |
TraitRef |
struct | The combination of a trait and its input types (e.g. P0: Trait<P1...Pn> ) |
Trait Solving: Goals and Clauses, Trait Solving: Lowering impls | src/librustc/ty/sty.rs |
Ty<'tcx> |
struct | This is the internal representation of a type used for type checking | Type checking | src/librustc/ty/mod.rs |
TyCtxt<'cx, 'tcx, 'tcx> |
struct | The "typing context". This is the central data structure in the compiler. It is the context that you use to perform all manner of queries | The ty modules |
src/librustc/ty/context.rs |