Commit 65187f5
authored
Rollup merge of rust-lang#98311 - eggyal:reverse-folder-hierarchy, r=jackh726
Reverse folder hierarchy
rust-lang#91318 introduced a trait for infallible folders distinct from the fallible version. For some reason (completely unfathomable to me now that I look at it with fresh eyes), the infallible trait was a supertrait of the fallible one: that is, all fallible folders were required to also be infallible. Moreover the `Error` associated type was defined on the infallible trait! It's so absurd that it has me questioning whether I was entirely sane.
This trait reverses the hierarchy, so that the fallible trait is a supertrait of the infallible one: all infallible folders are required to also be fallible (which is a trivial blanket implementation). This of course makes much more sense! It also enables the `Error` associated type to sit on the fallible trait, where it sensibly belongs.
There is one downside however: folders expose a `tcx` accessor method. Since the blanket fallible implementation for infallible folders only has access to a generic `F: TypeFolder`, we need that trait to expose such an accessor to which we can delegate. Alternatively it's possible to extract that accessor into a separate `HasTcx` trait (or similar) that would then be a supertrait of both the fallible and infallible folder traits: this would ensure that there's only one unambiguous `tcx` method, at the cost of a little additional boilerplate. If desired, I can submit that as a separate PR.
r? ````@jackh726````File tree
5 files changed
+40
-63
lines changed- compiler
- rustc_infer/src/infer
- rustc_middle/src/ty
- rustc_trait_selection/src/traits/query
5 files changed
+40
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
189 | 188 | | |
190 | | - | |
191 | 189 | | |
192 | 190 | | |
193 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
237 | 237 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 238 | + | |
242 | 239 | | |
243 | 240 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 241 | + | |
247 | 242 | | |
248 | 243 | | |
249 | 244 | | |
250 | 245 | | |
251 | 246 | | |
252 | | - | |
253 | 247 | | |
254 | 248 | | |
255 | 249 | | |
256 | 250 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 251 | + | |
261 | 252 | | |
262 | 253 | | |
263 | 254 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 255 | + | |
268 | 256 | | |
269 | 257 | | |
270 | 258 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 259 | + | |
275 | 260 | | |
276 | 261 | | |
277 | 262 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 263 | + | |
282 | 264 | | |
283 | 265 | | |
284 | 266 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 267 | + | |
289 | 268 | | |
290 | 269 | | |
291 | 270 | | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
| 271 | + | |
296 | 272 | | |
297 | 273 | | |
298 | 274 | | |
| |||
304 | 280 | | |
305 | 281 | | |
306 | 282 | | |
307 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
308 | 288 | | |
309 | 289 | | |
310 | 290 | | |
| |||
350 | 330 | | |
351 | 331 | | |
352 | 332 | | |
353 | | - | |
| 333 | + | |
354 | 334 | | |
355 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
356 | 342 | | |
357 | 343 | | |
358 | 344 | | |
359 | 345 | | |
360 | 346 | | |
361 | 347 | | |
362 | | - | |
| 348 | + | |
363 | 349 | | |
364 | 350 | | |
365 | 351 | | |
366 | | - | |
| 352 | + | |
367 | 353 | | |
368 | 354 | | |
369 | 355 | | |
370 | | - | |
| 356 | + | |
371 | 357 | | |
372 | 358 | | |
373 | 359 | | |
374 | 360 | | |
375 | 361 | | |
376 | 362 | | |
377 | | - | |
| 363 | + | |
378 | 364 | | |
379 | 365 | | |
380 | 366 | | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
| 367 | + | |
385 | 368 | | |
386 | 369 | | |
387 | 370 | | |
388 | 371 | | |
389 | 372 | | |
390 | 373 | | |
391 | | - | |
| 374 | + | |
392 | 375 | | |
393 | 376 | | |
394 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | 237 | | |
239 | | - | |
240 | 238 | | |
241 | 239 | | |
242 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
708 | | - | |
| 708 | + | |
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
172 | 171 | | |
173 | | - | |
174 | 172 | | |
175 | 173 | | |
176 | 174 | | |
| |||
0 commit comments