From 8d33a4d9dbcccab54ad10d80a7e8ebddfa6589b8 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 11 Jun 2021 10:58:21 -0300 Subject: [PATCH 1/5] We use HIR to do type inference, trait solving and type checking --- src/overview.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/overview.md b/src/overview.md index 1aa79e791..10439687b 100644 --- a/src/overview.md +++ b/src/overview.md @@ -68,10 +68,12 @@ 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>)). - 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 @@ -111,6 +113,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 From 9e4ce769e9b98235367d1cde820c07c81330de32 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 14 Jun 2021 12:50:27 -0300 Subject: [PATCH 2/5] Update src/overview.md Co-authored-by: Yuki Okushi --- src/overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overview.md b/src/overview.md index 10439687b..4859042dd 100644 --- a/src/overview.md +++ b/src/overview.md @@ -72,7 +72,7 @@ we'll talk about that later. 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, + (`hir::Ty`), which represent the syntactic things that the user wrote, into the internal representation used by the compiler (Ty<'tcx>)). - 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. From faf8e16c36e828840cf39ee313be5ff6571623fd Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 14 Jun 2021 12:50:34 -0300 Subject: [PATCH 3/5] Update src/overview.md Co-authored-by: Yuki Okushi --- src/overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overview.md b/src/overview.md index 4859042dd..7e7b2d29b 100644 --- a/src/overview.md +++ b/src/overview.md @@ -73,7 +73,7 @@ we'll talk about that later. 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>)). + into the internal representation used by the compiler (`Ty<'tcx>`)). - 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 From 227acffd84cb755994dd49bd7e0448ec75512368 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 14 Jun 2021 12:50:44 -0300 Subject: [PATCH 4/5] Update src/overview.md Co-authored-by: Noah Lev --- src/overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overview.md b/src/overview.md index 7e7b2d29b..8f27b0a75 100644 --- a/src/overview.md +++ b/src/overview.md @@ -70,7 +70,7 @@ we'll talk about that later. AST. This involves a lot of desugaring of things like loops and `async fn`. - 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 + 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>`)). From 16ae618989bbb0f4c2eb70c963be7060c1664595 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 14 Jun 2021 15:26:26 -0300 Subject: [PATCH 5/5] Fix type checking brief explanation --- src/overview.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/overview.md b/src/overview.md index 8f27b0a75..6c756e18f 100644 --- a/src/overview.md +++ b/src/overview.md @@ -73,7 +73,9 @@ we'll talk about that later. 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>`)). + 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