Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We use HIR to do type inference, trait solving and type checking #1139

Merged
merged 5 commits into from
Jun 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ we'll talk about that later.
- We then take the AST and [convert it to High-Level Intermediate
Representation (HIR)][hir]. This is a compiler-friendly representation of the
AST. This involves a lot of desugaring of things like loops and `async fn`.
- We use the HIR to do [type inference]. This is the process of automatic
detection of the type of an expression.
- **TODO: Maybe some other things are done here? I think initial type checking
happens here? And trait solving?**
- We use the HIR to do [type inference] (the process of automatic
detection of the type of an expression), [trait solving] (the process
of pairing up an impl with each reference to a trait), and [type
checking] (the process of converting the types found in the HIR
spastorino marked this conversation as resolved.
Show resolved Hide resolved
(`hir::Ty`), which represent the syntactic things that the user wrote,
into the internal representation used by the compiler (`Ty<'tcx>`),
and using that information to verify the type safety, correctness and
coherence of the types used in the program).
- The HIR is then [lowered to Mid-Level Intermediate Representation (MIR)][mir].
- Along the way, we construct the THIR, which is an even more desugared HIR.
THIR is used for pattern and exhaustiveness checking. It is also more
Expand Down Expand Up @@ -111,6 +115,8 @@ we'll talk about that later.
[parser]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html
[hir]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/index.html
[type inference]: https://rustc-dev-guide.rust-lang.org/type-inference.html
[trait solving]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html
[type checking]: https://rustc-dev-guide.rust-lang.org/type-checking.html
[mir]: https://rustc-dev-guide.rust-lang.org/mir/index.html
[borrow checking]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
[mir-opt]: https://rustc-dev-guide.rust-lang.org/mir/optimizations.html
Expand Down