@@ -11,16 +11,22 @@ list of items:
11
11
* Drop code (the ` Drop::drop ` function is not called directly)
12
12
* Drop implementations of types without an explicit ` Drop ` implementation
13
13
14
- The lowering is triggered by calling the ` mir_built ` query. The entire lowering
15
- code lives in ` src/librustc_mir/build ` . There is an intermediate representation
16
- between [ HIR] and [ MIR] called the ` HAIR ` that is only used during the lowering.
17
- The ` HAIR ` has datatypes that mirror the [ HIR] datatypes, but instead of e.g. ` -x `
14
+ The lowering is triggered by calling the [ ` mir_built ` ] query.
15
+ There is an intermediate representation
16
+ between [ HIR] and [ MIR] called the [ HAIR] that is only used during the lowering.
17
+ The [ HAIR] 's most important feature is that the various adjustments that happen
18
+ without explicit syntax (coercion, autoderef, autoref, ...) have become explicit
19
+ casts, deref operations or reference expressions.
20
+
21
+ The [ HAIR] has datatypes that mirror the [ HIR] datatypes, but instead of e.g. ` -x `
18
22
being a ` hair::ExprKind::Neg(hair::Expr) ` it is a ` hair::ExprKind::Neg(hir::Expr) ` .
19
-
20
23
This shallowness enables the ` HAIR ` to represent all datatypes that [ HIR] has, but
21
- without having to create an in-memory copy of the entire [ HIR] . The ` HAIR ` also
24
+ without having to create an in-memory copy of the entire [ HIR] . The [ HAIR] also
22
25
does a few simplifications, e.g. method calls and function calls have been merged
23
- into a single variant.
26
+ into a single variant. [ MIR] lowering will first convert the topmost expression from
27
+ [ HIR] to [ HAIR] (in
28
+ [ https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/hair/cx/expr/index.html ] )
29
+ and then process the [ HAIR] expressions recursively.
24
30
25
31
The lowering creates local variables for every argument as specified in the signature.
26
32
Next it creates local variables for every binding specified (e.g. ` (a, b): (i32, String) ` )
@@ -35,7 +41,7 @@ writes the result into the `RETURN_PLACE`.
35
41
## ` unpack! ` all the things
36
42
37
43
One important thing of note is the ` unpack! ` macro, which accompanies all recursive
38
- calls. The macro ensures, that you get the result of the recursive call while updating
44
+ calls. The macro ensures that you get the result of the recursive call while updating
39
45
the basic block that you are now in. As an example: lowering ` a + b ` will need to do
40
46
three somewhat independent things:
41
47
@@ -108,4 +114,6 @@ statement per aggregate field plus an assignment to the discriminant in the
108
114
case of ` enum ` s.
109
115
110
116
[ MIR ] : ./index.html
111
- [ HIR ] : ../hir.html
117
+ [ HIR ] : ../hir.html
118
+ [ HAIR ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/hair/index.html
119
+ [ `mir_built` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/transform/fn.mir_built.html
0 commit comments