Commit 4ec548a
authored
Rollup merge of rust-lang#118161 - compiler-errors:coroutine-obligation-opaques, r=lcnr
Allow defining opaques in `check_coroutine_obligations`
In the new trait solver, when an obligation stalls on an unresolved coroutine witness, we will stash away the *root* obligation, even if the stalled obligation is only a distant descendent of the root obligation, since the new solver is purely recursive.
This means that we may need to reprocess alias-relate obligations (and others) which may define opaque types in the new solver. Currently, we use the coroutine's def id as the defining anchor in `check_coroutine_obligations`, which will allow defining no opaque types, resulting in errors like:
```
error[E0271]: type mismatch resolving `{coroutine@<source>:6:5: 6:17} <: impl Clone`
--> <source>:6:5
|
6 | / move |_: ()| {
7 | | let () = yield ();
8 | | }
| |_____^ types differ
```
So this PR fixes the defining anchor and does the same trick as `check_opaque_well_formed`, where we manually compare opaques that were defined against their hidden types to make sure they weren't defined differently when processing these stalled coroutine obligations.
r? `@lcnr` cc `@cjgillot`File tree
3 files changed
+36
-5
lines changed- compiler
- rustc_hir_analysis/src/check
- rustc_middle/src/query
- tests/ui/coroutine
3 files changed
+36
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1468 | 1468 | | |
1469 | 1469 | | |
1470 | 1470 | | |
1471 | | - | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
1472 | 1475 | | |
1473 | 1476 | | |
1474 | 1477 | | |
| |||
1482 | 1485 | | |
1483 | 1486 | | |
1484 | 1487 | | |
1485 | | - | |
1486 | | - | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
1487 | 1491 | | |
1488 | 1492 | | |
1489 | 1493 | | |
| |||
1513 | 1517 | | |
1514 | 1518 | | |
1515 | 1519 | | |
1516 | | - | |
| 1520 | + | |
1517 | 1521 | | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
1518 | 1532 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
570 | | - | |
| 570 | + | |
571 | 571 | | |
572 | 572 | | |
573 | 573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments