Skip to content

Commit

Permalink
We use HIR to do type inference, trait solving and type checking (#1139)
Browse files Browse the repository at this point in the history
* We use HIR to do type inference, trait solving and type checking

* Update src/overview.md

Co-authored-by: Yuki Okushi <[email protected]>

* Update src/overview.md

Co-authored-by: Yuki Okushi <[email protected]>

* Update src/overview.md

Co-authored-by: Noah Lev <[email protected]>

* Fix type checking brief explanation

Co-authored-by: Yuki Okushi <[email protected]>
Co-authored-by: Noah Lev <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2021
1 parent 6e4f0cb commit c3ac40d
Showing 1 changed file with 10 additions and 4 deletions.
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
(`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

0 comments on commit c3ac40d

Please sign in to comment.