Clarify section on MIR construction

This commit is contained in:
Camelid 2020-08-22 18:51:53 -07:00 committed by Tshepang Lekhonkhobe
parent a49fce9a12
commit 014d434f46
1 changed files with 6 additions and 5 deletions

View File

@ -3,10 +3,10 @@
The lowering of [HIR] to [MIR] occurs for the following (probably incomplete) The lowering of [HIR] to [MIR] occurs for the following (probably incomplete)
list of items: list of items:
* Function and Closure bodies * Function and closure bodies
* Initializers of `static` and `const` items * Initializers of `static` and `const` items
* Initializers of enum discriminants * Initializers of enum discriminants
* Glue and Shims of any kind * Glue and shims of any kind
* Tuple struct initializer functions * Tuple struct initializer functions
* Drop code (the `Drop::drop` function is not called directly) * Drop code (the `Drop::drop` function is not called directly)
* Drop implementations of types without an explicit `Drop` implementation * Drop implementations of types without an explicit `Drop` implementation
@ -20,9 +20,10 @@ without explicit syntax) like coercions, autoderef, autoref and overloaded metho
calls have become explicit casts, deref operations, reference expressions or calls have become explicit casts, deref operations, reference expressions or
concrete function calls. concrete function calls.
The [THIR] has datatypes that mirror the [HIR] datatypes, but instead of e.g. `-x` The [THIR] has datatypes that mirror the [HIR] datatypes, but the [THIR] is a shallow
being a `thir::ExprKind::Neg(thir::Expr)` it is a `thir::ExprKind::Neg(hir::Expr)`. wrapper around [HIR]. For example, instead of `-x` being a `thir::ExprKind::Neg(thir::Expr)`
This shallowness enables the `THIR` to represent all datatypes that [HIR] has, but (a deep copy), it is a `thir::ExprKind::Neg(hir::Expr)` (a shallow copy).
This shallowness enables the [THIR] to represent all datatypes that [HIR] has, but
without having to create an in-memory copy of the entire [HIR]. without having to create an in-memory copy of the entire [HIR].
[MIR] lowering will first convert the topmost expression from [MIR] lowering will first convert the topmost expression from
[HIR] to [THIR] (in [`rustc_mir_build::thir::cx::expr`]) and then process [HIR] to [THIR] (in [`rustc_mir_build::thir::cx::expr`]) and then process