@@ -12,7 +12,7 @@ A [`NodeId`] is an identifier number that uniquely identifies an AST node within
1212a crate. Every node in the AST has its own [ ` NodeId ` ] , including top-level items
1313such as structs, but also individual statements and expressions.
1414
15- However, because they are absolute within in  a crate, adding or removing a single
15+ However, because they are absolute within a crate, adding or removing a single
1616node in the AST causes all the subsequent [ ` NodeId ` ] s to change. This renders
1717[ ` NodeId ` ] s pretty much useless for incremental compilation, where you want as
1818few things as possible to change.
@@ -31,14 +31,17 @@ The HIR uses a bunch of different identifiers that coexist and serve different p
3131  the crate the definition comes from, and a [ ` DefIndex ` ]  which identifies the definition
3232  within the crate. Unlike [ ` NodeId ` ] s, there isn't a [ ` DefId ` ]  for every expression, which
3333  makes them more stable across compilations.
34+ 
3435-  A [ ` LocalDefId ` ]  is basically a [ ` DefId ` ]  that is known to come from the current crate.
3536  This allows us to drop the [ ` CrateNum ` ]  part, and use the type system to ensure that
3637  only local definitions are passed to functions that expect a local definition.
38+ 
3739-  A [ ` HirId ` ]  uniquely identifies a node in the HIR of the current crate. It is composed
3840  of two parts: an ` owner `  and a ` local_id `  that is unique within the ` owner ` . This
3941  combination makes for more stable values which are helpful for incremental compilation.
4042  Unlike [ ` DefId ` ] s, a [ ` HirId ` ]  can refer to [ fine-grained entities] [ Node ]  like expressions,
4143  but stays local to the current crate.
44+ 
4245-  A [ ` BodyId ` ]  identifies a HIR [ ` Body ` ]  in the current crate. It is currenty only
4346  a wrapper around a [ ` HirId ` ] . For more info about HIR bodies, please refer to the
4447  [ HIR chapter] [ hir-bodies ] .
@@ -60,4 +63,46 @@ See the [HIR chapter][hir-map] for more detailed information.
6063
6164## In the MIR  
6265
63- ** TODO** 
66+ -  [ ` BasicBlock ` ]  identifies a * basic block* . It points to an instance of
67+   [ ` BasicBlockData ` ] , which can be retrieved by indexing into
68+   [ ` Body::basic_blocks() ` ]  (note that you must call a function; the field is
69+   private).
70+ 
71+ -  [ ` Local ` ]  identifies a local variable in a function. Its associated data is in
72+   [ ` LocalDecl ` ] , which can be retrieved by indexing into [ ` Body.local_decls ` ] .
73+ 
74+ -  [ ` Field ` ]  identifies a struct's, union's, or enum variant's field. It is used
75+   as a "projection" in [ ` Place ` ] .
76+ 
77+ -  [ ` SourceScope ` ]  identifies a name scope in the original source code. Used for
78+   diagnostics and for debuginfo in debuggers. It points to an instance of
79+   [ ` SourceScopeData ` ] , which can be retrieved by indexing into
80+   [ ` Body.source_scopes ` ] .
81+ 
82+ -  [ ` Promoted ` ]  identifies a promoted constant within another item (related to
83+   const evaluation). Note: it is unique only locally within the item, so it
84+   should be associated with a ` DefId ` .
85+   [ ` GlobalId ` ]  will give you a more specific identifier (TODO).
86+ 
87+ -  [ ` GlobalId ` ]  identifies a global variable: a ` const ` , a ` static ` , a ` const fn ` 
88+   where all arguments are [ zero-sized types] , or a promoted constant.
89+ 
90+ -  [ ` Location ` ]  represents the location in the MIR of a statement or terminator.
91+   It identifies the block (using [ ` BasicBlock ` ] ) and the index of the statement
92+   or terminator in the block.
93+ 
94+ [ `BasicBlock` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.BasicBlock.html 
95+ [ `BasicBlockData` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.BasicBlockData.html 
96+ [ `Body::basic_blocks()` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html#method.basic_blocks 
97+ [ `Local` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Local.html 
98+ [ `LocalDecl` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.LocalDecl.html 
99+ [ `Body.local_decls` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html#structfield.local_decls 
100+ [ `Field` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Field.html 
101+ [ `Place` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Place.html 
102+ [ `SourceScope` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.SourceScope.html 
103+ [ `SourceScopeData` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.SourceScopeData.html 
104+ [ `Body.source_scopes` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html#structfield.source_scopes 
105+ [ `Promoted` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Promoted.html 
106+ [ `GlobalId` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/struct.GlobalId.html 
107+ [ `Location` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Location.html 
108+ [ zero-sized types ] : https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts 
0 commit comments