@@ -55,24 +55,43 @@ Let's start by looking what happens when we type-check `main`. Initially we invo
55
55
56
56
#### Type-checking the ` is_send ` call
57
57
58
+ * Explain how it invokes ` type_of `
59
+ * We look at the bounds, we are able to type check it as is
60
+
58
61
``` mermaid
59
62
flowchart TD
60
63
TypeChecking["type checking `main`"]
61
64
subgraph TypeOfSeq["type_of(Seq<T>) query"]
62
- WalkModuleHir["Walk the HIR for the module `m`"]
63
- VisitProduceSingleton["visit produce_singleton"]
64
- VisitProduceDoubleton["visit produce_doubleton"]
65
+ WalkModuleHir["Walk the HIR for the module `m`\nto find the hidden types from each\nfunction within"]
66
+ VisitProduceSingleton["visit `produce_singleton`"]
67
+ InterimType["`produce_singleton` hidden type is `Vec<T>`\nkeep searching"]
68
+ VisitProduceDoubleton["visit `produce_doubleton`"]
69
+ CompareType["`produce_doubleton` hidden type is also Vec<T>\nthis matches what we saw before ✅"]
70
+ Done["Return `Vec<T>`"]
65
71
end
72
+
73
+ BorrowCheckProduceSingleton["`borrow_check(produce_singleton)`"]
74
+ TypeCheckProduceSingleton["`type_check(produce_singleton)`"]
75
+
76
+ BorrowCheckProduceDoubleton["`borrow_check(produce_doubleton)`"]
77
+ TypeCheckProduceDoubleton["`type_check(produce_doubleton)`"]
78
+
79
+ Substitute["Substitute `T => u32`,\nyielding `Vec<i32>` as the hidden type"]
80
+ CheckSend["Check that `Vec<i32>: Send` ✅"]
66
81
67
82
TypeChecking -- trait code for auto traits --> TypeOfSeq
68
83
TypeOfSeq --> WalkModuleHir
69
84
WalkModuleHir --> VisitProduceSingleton
70
- VisitProduceSingleton --> VisitProduceDoubleton
85
+ VisitProduceSingleton --> BorrowCheckProduceSingleton
86
+ BorrowCheckProduceSingleton --> TypeCheckProduceSingleton
87
+ TypeCheckProduceSingleton --> InterimType
88
+ InterimType --> VisitProduceDoubleton
89
+ VisitProduceDoubleton --> BorrowCheckProduceDoubleton
90
+ BorrowCheckProduceDoubleton --> TypeCheckProduceDoubleton
91
+ TypeCheckProduceDoubleton --> CompareType --> Done
92
+ Done --> Substitute --> CheckSend
71
93
```
72
94
73
- * Explain how it invokes ` type_of `
74
- * We look at the bounds, we are able to type check it as is
75
-
76
95
### Within the ` type_of ` query
77
96
78
97
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.
0 commit comments