Commit e7cc3bd
committed
Auto merge of rust-lang#92007 - oli-obk:lazy_tait2, r=nikomatsakis
Lazy type-alias-impl-trait
Previously opaque types were processed by
1. replacing all mentions of them with inference variables
2. memorizing these inference variables in a side-table
3. at the end of typeck, resolve the inference variables in the side table and use the resolved type as the hidden type of the opaque type
This worked okayish for `impl Trait` in return position, but required lots of roundabout type inference hacks and processing.
This PR instead stops this process of replacing opaque types with inference variables, and just keeps the opaque types around.
Whenever an opaque type `O` is compared with another type `T`, we make the comparison succeed and record `T` as the hidden type. If `O` is compared to `U` while there is a recorded hidden type for it, we grab the recorded type (`T`) and compare that against `U`. This makes implementing
* rust-lang/rfcs#2515
much simpler (previous attempts on the inference based scheme were very prone to ICEs and general misbehaviour that was not explainable except by random implementation defined oddities).
r? `@nikomatsakis`
fixes rust-lang#93411
fixes rust-lang#88236File tree
359 files changed
+3306
-2442
lines changed- compiler
- rustc_borrowck/src
- region_infer
- type_check
- rustc_const_eval/src/transform
- check_consts
- rustc_data_structures/src
- rustc_infer/src
- infer
- canonical
- nll_relate
- opaque_types
- outlives
- traits
- rustc_lint/src
- rustc_middle/src
- infer
- ty
- print
- rustc_mir_build/src/build
- rustc_query_system/src/dep_graph
- rustc_trait_selection/src
- traits
- error_reporting
- query/type_op
- select
- rustc_traits/src
- chalk
- rustc_type_ir/src
- rustc_typeck/src
- check
- fn_ctxt
- method
- collect
- impl_wf_check
- outlives
- src
- bootstrap/bin
- librustdoc/clean
- test
- incremental/hashes
- ui
- associated-type-bounds
- associated-types
- async-await
- multiple-lifetimes
- cast
- closures/2229_closure_analysis/diagnostics/borrowck
- const-generics/defaults
- entry-point
- feature-gates
- generator
- generic-associated-types
- impl-trait
- issues
- multiple-lifetimes
- lang-items
- lazy-type-alias-impl-trait
- lifetimes
- lint
- never_type
- nll
- ty-outlives
- parser
- polymorphization
- resolve
- save-analysis
- self
- suggestions
- lifetimes
- traits/alias
- type-alias-impl-trait
- tools/clippy/clippy_utils/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
359 files changed
+3306
-2442
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | | - | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
Lines changed: 38 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
57 | | - | |
| 56 | + | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | | - | |
| 61 | + | |
63 | 62 | | |
64 | | - | |
| 63 | + | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
78 | 94 | | |
79 | 95 | | |
80 | 96 | | |
| |||
100 | 116 | | |
101 | 117 | | |
102 | 118 | | |
103 | | - | |
104 | | - | |
| 119 | + | |
105 | 120 | | |
106 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
107 | 126 | | |
108 | | - | |
109 | 127 | | |
110 | 128 | | |
111 | 129 | | |
| |||
149 | 167 | | |
150 | 168 | | |
151 | 169 | | |
152 | | - | |
| 170 | + | |
| 171 | + | |
153 | 172 | | |
154 | | - | |
| 173 | + | |
155 | 174 | | |
156 | 175 | | |
157 | 176 | | |
| |||
177 | 196 | | |
178 | 197 | | |
179 | 198 | | |
180 | | - | |
181 | 199 | | |
182 | 200 | | |
183 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
| 150 | + | |
152 | 151 | | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
174 | 173 | | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
0 commit comments