Commit d6f91e0
committed
upvar inference for implicit deref patterns
There's a bit of a hack here, which I don't love, but the other ways I
could think of doing this were substantially messier. I'll be saving
that for a separate commit to reduce the noise in this one. I also
haven't written that separate commit yet though, since I'm not convinced
the alternatives I've thought of are better than this. Please let me
know if one of these (or better yet, something else) sounds good:
- The callback argument to `cat_pattern` could take a
`PatOrAdjust<'hir>` enum instead of a `Pat<'hir>`, which would
correspond either to a (potentially scrutinee-borrowing) pattern or a
(currently definitely scrutinee-borrowing) implicit overloaded deref.
Matching on `PatOrAdjust` is really noisy, unfortunately, and would
require a separate `cat_pattern_unadjusted` helper that bypasses it to
avoid reindenting `maybe_read_scrutinee`.
- `cat_pattern` could invoke the delegate's `borrow` callback directly.
This results in some repeated work between `walk_pat` and
`maybe_read_scrutinee` for refutable patterns (but hopefully that
wouldn't have correctness implications..?). `cat_pattern` would also
need to take the `HirId` of the top-level scrutinee expression as an
argument for use in diagnostics.1 parent 3564b31 commit d6f91e0
File tree
2 files changed
+69
-11
lines changed- compiler/rustc_hir_typeck/src
- tests/ui/pattern/deref-patterns
2 files changed
+69
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
1004 | 1006 | | |
1005 | 1007 | | |
1006 | 1008 | | |
| |||
1726 | 1728 | | |
1727 | 1729 | | |
1728 | 1730 | | |
1729 | | - | |
1730 | | - | |
1731 | | - | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
1732 | 1736 | | |
1733 | | - | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
1734 | 1753 | | |
| 1754 | + | |
1735 | 1755 | | |
1736 | 1756 | | |
1737 | 1757 | | |
| |||
1834 | 1854 | | |
1835 | 1855 | | |
1836 | 1856 | | |
1837 | | - | |
1838 | | - | |
1839 | | - | |
1840 | 1857 | | |
1841 | | - | |
1842 | | - | |
1843 | | - | |
1844 | | - | |
| 1858 | + | |
1845 | 1859 | | |
1846 | 1860 | | |
1847 | 1861 | | |
| |||
1893 | 1907 | | |
1894 | 1908 | | |
1895 | 1909 | | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
1896 | 1927 | | |
1897 | 1928 | | |
1898 | 1929 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
17 | 26 | | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
21 | 48 | | |
0 commit comments