You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/opaque-types-type-alias-impl-trait-inference.md
+20-7
Original file line number
Diff line number
Diff line change
@@ -43,9 +43,14 @@ pub fn main() {
43
43
*`m::produce_singleton`
44
44
*`m::produce_doubleton`
45
45
* In the `main` function, the opaque type is out of scope:
46
-
* When `main` calls `m::produce_singleton`, it gets back a reference to the opaque type `Seq<i32>`.
47
-
* The `is_send` call checks that `Seq<i32>: Send`. `Send` is not listed amongst the bounds of the impl trait, but because of auto-trait leakage, we are able to infer that it holds.
48
-
* The for loop desugaring requires that `Seq<T>: IntoIterator`, which is provable from the bounds declared on `Seq<T>`.
46
+
* When `main` calls `m::produce_singleton`,
47
+
it gets back a reference to the opaque type `Seq<i32>`.
48
+
* The `is_send` call checks that `Seq<i32>:
49
+
Send`. `Send` is not listed amongst the bounds of the impl trait,
50
+
but because of auto-trait leakage,
51
+
we are able to infer that it holds.
52
+
* The for loop desugaring requires that `Seq<T>: IntoIterator`,
53
+
which is provable from the bounds declared on `Seq<T>`.
49
54
50
55
### Type-checking `main`
51
56
@@ -97,7 +102,9 @@ flowchart TD
97
102
98
103
### Within the `type_of` query
99
104
100
-
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.
105
+
The `type_of` query, when applied to an opaque type O, returns the hidden type.
106
+
That hidden type is computed by combining the results from each constraining function
107
+
within defining scope of O.
101
108
102
109
```mermaid
103
110
flowchart TD
@@ -164,7 +171,9 @@ flowchart TD
164
171
165
172
### Interactions with queries
166
173
167
-
When queries encounter a `opaque_ty_obligation`, they do not try to process them, but instead just store the constraints into the infcx.
174
+
When queries encounter a `opaque_ty_obligation`,
175
+
they do not try to process them,
176
+
but instead just store the constraints into the infcx.
168
177
169
178
```mermaid
170
179
graph TD
@@ -184,9 +193,13 @@ graph TD
184
193
end
185
194
```
186
195
187
-
The registered hidden types are stored into the `QueryResponse` struct in the `opaque_types` field (the function `take_opaque_types_for_query_response` reads them out).
196
+
The registered hidden types are stored into the `QueryResponse` struct in
197
+
the `opaque_types` field
198
+
(the function `take_opaque_types_for_query_response` reads them out).
188
199
189
-
When the `QueryResponse` is instantiated into the surrounding infcx in `query_response_substitution_guess`, we convert each hidden type constraint by invoking `handle_opaque_type` (as above).
200
+
When the `QueryResponse` is instantiated into the surrounding infcx in
201
+
`query_response_substitution_guess`,
202
+
we convert each hidden type constraint by invoking `handle_opaque_type` (as above).
190
203
191
204
There is one bit of "weirdness".
192
205
The instantiated opaque types are stored in a *map*,
0 commit comments