diff options
| author | HackMD <no-reply@hackmd.io> | 2022-02-07 22:45:11 +0000 |
|---|---|---|
| committer | Tshepang Mbambo <tshepang@gmail.com> | 2022-07-17 23:34:12 +0200 |
| commit | 0f778223df9c7177397a67b030cd9bfd623f68b3 (patch) | |
| tree | ee96e3ad643c82e2c828c5c60ab95ade79c79038 /src/doc/rustc-dev-guide | |
| parent | fd17e926c410631642e746f56eaf6c38b83acc82 (diff) | |
| download | rust-0f778223df9c7177397a67b030cd9bfd623f68b3.tar.gz rust-0f778223df9c7177397a67b030cd9bfd623f68b3.zip | |
sync with hackmd
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/opaque-types-type-alias-impl-trait-inference.md | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/doc/rustc-dev-guide/src/opaque-types-type-alias-impl-trait-inference.md b/src/doc/rustc-dev-guide/src/opaque-types-type-alias-impl-trait-inference.md index b47216aae9e..0d738c88f5a 100644 --- a/src/doc/rustc-dev-guide/src/opaque-types-type-alias-impl-trait-inference.md +++ b/src/doc/rustc-dev-guide/src/opaque-types-type-alias-impl-trait-inference.md @@ -55,24 +55,43 @@ Let's start by looking what happens when we type-check `main`. Initially we invo #### Type-checking the `is_send` call +* Explain how it invokes `type_of` + * We look at the bounds, we are able to type check it as is + ```mermaid flowchart TD TypeChecking["type checking `main`"] subgraph TypeOfSeq["type_of(Seq<T>) query"] - WalkModuleHir["Walk the HIR for the module `m`"] - VisitProduceSingleton["visit produce_singleton"] - VisitProduceDoubleton["visit produce_doubleton"] + WalkModuleHir["Walk the HIR for the module `m`\nto find the hidden types from each\nfunction within"] + VisitProduceSingleton["visit `produce_singleton`"] + InterimType["`produce_singleton` hidden type is `Vec<T>`\nkeep searching"] + VisitProduceDoubleton["visit `produce_doubleton`"] + CompareType["`produce_doubleton` hidden type is also Vec<T>\nthis matches what we saw before ✅"] + Done["Return `Vec<T>`"] end + + BorrowCheckProduceSingleton["`borrow_check(produce_singleton)`"] + TypeCheckProduceSingleton["`type_check(produce_singleton)`"] + + BorrowCheckProduceDoubleton["`borrow_check(produce_doubleton)`"] + TypeCheckProduceDoubleton["`type_check(produce_doubleton)`"] + + Substitute["Substitute `T => u32`,\nyielding `Vec<i32>` as the hidden type"] + CheckSend["Check that `Vec<i32>: Send` ✅"] TypeChecking -- trait code for auto traits --> TypeOfSeq TypeOfSeq --> WalkModuleHir WalkModuleHir --> VisitProduceSingleton - VisitProduceSingleton --> VisitProduceDoubleton + VisitProduceSingleton --> BorrowCheckProduceSingleton + BorrowCheckProduceSingleton --> TypeCheckProduceSingleton + TypeCheckProduceSingleton --> InterimType + InterimType --> VisitProduceDoubleton + VisitProduceDoubleton --> BorrowCheckProduceDoubleton + BorrowCheckProduceDoubleton --> TypeCheckProduceDoubleton + TypeCheckProduceDoubleton --> CompareType --> Done + Done --> Substitute --> CheckSend ``` -* Explain how it invokes `type_of` - * We look at the bounds, we are able to type check it as is - ### Within the `type_of` query The `type_of` query, when applied to an opaque type O, returns the hidden type. That hidden type is computed by combining the results from each constraining function within defining scope of O. |
