Skip to content

Commit 872ba49

Browse files
LeSeulArtichautcamelid
authored and
Joshua Nelson
committed
Apply suggestions from code review
Co-authored-by: Camelid <[email protected]>
1 parent 4c8fdcf commit 872ba49

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/thir.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- toc -->
44

5-
The THIR ("Typed High-Level Intermediate Representation"), previously HAIR for
5+
The THIR ("Typed High-Level Intermediate Representation"), previously called HAIR for
66
"High-Level Abstract IR", is another IR used by rustc that is generated after
77
[type checking]. It is (as of <!-- date: 2021-03 --> March 2021) only used for
88
[MIR construction] and [exhaustiveness checking], but
@@ -16,14 +16,17 @@ for the current MIR unsafety checker.
1616

1717
As the name might suggest, the THIR is a lowered version of the [HIR] where all
1818
the types have been filled in, which is possible after type checking has completed.
19-
But it has some other interesting features that distinguish it from HIR:
20-
- like the MIR, the THIR only represents bodies, i.e. "executable code"; this includes
19+
But it has some other interesting features that distinguish it from the HIR:
20+
21+
- Like the MIR, the THIR only represents bodies, i.e. "executable code"; this includes
2122
function bodies, but also `const` initializers, for example. Consequently, the THIR
2223
has no representation for items like `struct`s or `trait`s.
23-
- a body of THIR is only stored temporarily and is dropped as soon as it's no longer
24+
25+
- Each body of THIR is only stored temporarily and is dropped as soon as it's no longer
2426
needed, as opposed to being stored until the end of the compilation process (which
2527
is what is done with the HIR).
26-
- besides making the types of all nodes available, the THIR also has additional
28+
29+
- Besides making the types of all nodes available, the THIR also has additional
2730
desugaring compared to the HIR. For example, automatic references and dereferences
2831
are made explicit, and method calls and overloaded operators are converted into
2932
plain function calls. Destruction scopes are also made explicit.
@@ -32,8 +35,8 @@ But it has some other interesting features that distinguish it from HIR:
3235

3336
The THIR lives in [`rustc_mir_build::thir`][thir]. To construct a `thir::Expr`,
3437
you can use the `build_thir` function, passing in the memory arena where the THIR
35-
will be allocated. Dropping this arena will result in the THIR being destroyed:
36-
this is useful to keep peak memory in check, as having a THIR representation of
38+
will be allocated. Dropping this arena will result in the THIR being destroyed,
39+
which is useful to keep peak memory in check. Having a THIR representation of
3740
all bodies of a crate in memory at the same time would be very heavy.
3841

3942
[thir]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_build/thir/index.html

0 commit comments

Comments
 (0)