This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 15e2e51
authored
Rollup merge of rust-lang#100473 - compiler-errors:normalize-the-fn-def-sig-plz, r=lcnr
Attempt to normalize `FnDef` signature in `InferCtxt::cmp`
Stashes a normalization callback in `InferCtxt` so that the signature we get from `tcx.fn_sig(..).subst(..)` in `InferCtxt::cmp` can be properly normalized, since we cannot expect for it to have normalized types since it comes straight from astconv.
This is kind of a hack, but I will say that `@jyn514` found the fact that we present unnormalized types to be very confusing in real life code, and I agree with that feeling. Though altogether I am still a bit unsure about whether this PR is worth the effort, so I'm open to alternatives and/or just closing it outright.
On the other hand, this isn't a ridiculously heavy implementation anyways -- it's less than a hundred lines of changes, and half of that is just miscellaneous cleanup.
This is stacked onto rust-lang#100471 which is basically unrelated, and it can be rebased off of that when that lands or if needed.
---
The code:
```rust
trait Foo { type Bar; }
impl<T> Foo for T {
type Bar = i32;
}
fn foo<T>(_: <T as Foo>::Bar) {}
fn needs_i32_ref_fn(f: fn(&'static i32)) {}
fn main() {
needs_i32_ref_fn(foo::<()>);
}
```
Before:
```
= note: expected fn pointer `fn(&'static i32)`
found fn item `fn(<() as Foo>::Bar) {foo::<()>}`
```
After:
```
= note: expected fn pointer `fn(&'static i32)`
found fn item `fn(i32) {foo::<()>}`
```File tree
8 files changed
+125
-14
lines changed- compiler
- rustc_infer/src/infer
- error_reporting
- rustc_trait_selection/src/traits
- error_reporting
- rustc_typeck/src/check
- src/test/ui/mismatched_types
8 files changed
+125
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
961 | 961 | | |
962 | 962 | | |
963 | 963 | | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
964 | 972 | | |
965 | 973 | | |
966 | 974 | | |
967 | 975 | | |
968 | 976 | | |
969 | 977 | | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
970 | 981 | | |
971 | 982 | | |
972 | 983 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
340 | 343 | | |
341 | 344 | | |
342 | 345 | | |
| |||
540 | 543 | | |
541 | 544 | | |
542 | 545 | | |
| 546 | + | |
| 547 | + | |
543 | 548 | | |
544 | 549 | | |
545 | 550 | | |
| |||
553 | 558 | | |
554 | 559 | | |
555 | 560 | | |
| 561 | + | |
556 | 562 | | |
557 | 563 | | |
558 | 564 | | |
| |||
582 | 588 | | |
583 | 589 | | |
584 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
585 | 599 | | |
586 | 600 | | |
587 | 601 | | |
| |||
611 | 625 | | |
612 | 626 | | |
613 | 627 | | |
| 628 | + | |
614 | 629 | | |
615 | 630 | | |
616 | 631 | | |
| |||
629 | 644 | | |
630 | 645 | | |
631 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
632 | 650 | | |
633 | 651 | | |
634 | 652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
| |||
41 | 50 | | |
42 | 51 | | |
43 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
44 | 57 | | |
45 | 58 | | |
46 | 59 | | |
| |||
Lines changed: 17 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
1589 | 1589 | | |
1590 | 1590 | | |
1591 | 1591 | | |
1592 | | - | |
| 1592 | + | |
1593 | 1593 | | |
1594 | 1594 | | |
1595 | 1595 | | |
1596 | 1596 | | |
1597 | 1597 | | |
1598 | | - | |
| 1598 | + | |
1599 | 1599 | | |
1600 | | - | |
| 1600 | + | |
1601 | 1601 | | |
1602 | | - | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
1603 | 1606 | | |
1604 | 1607 | | |
1605 | 1608 | | |
1606 | 1609 | | |
1607 | 1610 | | |
1608 | | - | |
| 1611 | + | |
1609 | 1612 | | |
1610 | | - | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
1611 | 1617 | | |
1612 | 1618 | | |
1613 | 1619 | | |
1614 | 1620 | | |
1615 | 1621 | | |
1616 | 1622 | | |
1617 | | - | |
| 1623 | + | |
1618 | 1624 | | |
1619 | 1625 | | |
1620 | 1626 | | |
| |||
1634 | 1640 | | |
1635 | 1641 | | |
1636 | 1642 | | |
1637 | | - | |
1638 | | - | |
| 1643 | + | |
| 1644 | + | |
1639 | 1645 | | |
1640 | | - | |
1641 | | - | |
| 1646 | + | |
1642 | 1647 | | |
1643 | 1648 | | |
1644 | 1649 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
87 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
88 | 113 | | |
89 | 114 | | |
90 | 115 | | |
| |||
| 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 | + | |
| 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 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments