Commit 9212d1d
committed
Support arbitrary inner type in
Before this commit `NamedImplKey` could only represent the inner type as
`rust: &'a Ident`. For example, it could represent `Vec<Foo>` but could
not represent `Vec<Box<Foo>>` where the inner type (`Box<Foo>` in our
example) is not a simple identifier.
After this commit `NamedImplKey` is refactored to support an arbitrary
inner type. Note that (to simplify and to minimize risks associated
with this commit) this new ability is not actually used at this point -
it is planned to be used in follow-up commits to incrementally relax
generic type argument restrictions in `syntax/check.rs`.
This commit is quite big, but it seems difficult to extract some changes
to smaller, separate commits, because all of the changes stem from the
refactoring of the `NamedImplKey`. At a high-level this commit contains
the following changes:
1. `syntax/instantiate.rs`: Changing `pub rust: &'a Ident` field of
`NamedImplKey` to `pub inner: &'a Type`. This is the main/root
change in this commit.
2. `gen/src/write.rs`: supporting arbitrary inner types
when writing C++ thunks exposing instantiations/monomorphizations of
templates/generics supported by `cxx`.
* This depends on `fn stringify_type` introduced in
`gen/src/write.rs` in an earlier commit.
* Handling arbitrary inner types *in general* means that we can
delete `enum UniquePtr` which provided handling of two *specific*
inner types.
3. `macro/src/expand.rs`: supporting arbitrary inner types
when writing Rust thunks exposing instantiations/monomorphizations of
templates/generics supported by `cxx`.
* Using `#inner` instead of `#ident` may now (optionally) cover
generic lifetime arguments. This is why this commit also changes
`macro/src/generics.rs`. And this is why we can no longer need
the `ty_generics` field from `struct Impl`.
* One minor functional change here is changing the error messages
so that references to type names are generated purely in the
generated bindings, without depending on `fn display_namespaced`.
4. `syntax/mangle.rs`: supporting mangling of individual types. This
helps to:
* Support the (long-term, not-yet-realized) high-level goal of
actually allowing and using arbitrary inner types
* Deduplicate mangling code details that were somewhat duplicated
in `macro/src/expand.rs` and `gen/src/write.rs`.
5. `syntax/types.rs`: Supporting arbitrary inner types in
* `fn is_maybe_trivial`
* `fn is_local` (this function supports an earlier refactoring
that changed how `cxx` decides whether to provide an *implicit*
impl of a given generic/template instantiation/monomorphization)NamedImplKey.1 parent a4d5ac8 commit 9212d1d
File tree
13 files changed
+313
-318
lines changed- gen/src
- macro/src
- syntax
- tests
13 files changed
+313
-318
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
1573 | 1572 | | |
1574 | 1573 | | |
1575 | 1574 | | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
1609 | | - | |
1610 | | - | |
1611 | | - | |
1612 | | - | |
1613 | | - | |
1614 | | - | |
1615 | | - | |
1616 | | - | |
1617 | | - | |
1618 | | - | |
1619 | | - | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
1623 | | - | |
1624 | | - | |
1625 | | - | |
1626 | | - | |
1627 | 1575 | | |
1628 | 1576 | | |
1629 | 1577 | | |
| |||
1659 | 1607 | | |
1660 | 1608 | | |
1661 | 1609 | | |
1662 | | - | |
1663 | | - | |
1664 | | - | |
| 1610 | + | |
| 1611 | + | |
1665 | 1612 | | |
1666 | 1613 | | |
1667 | 1614 | | |
| |||
1683 | 1630 | | |
1684 | 1631 | | |
1685 | 1632 | | |
1686 | | - | |
1687 | | - | |
1688 | | - | |
| 1633 | + | |
| 1634 | + | |
1689 | 1635 | | |
1690 | 1636 | | |
1691 | 1637 | | |
| |||
1733 | 1679 | | |
1734 | 1680 | | |
1735 | 1681 | | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
| 1682 | + | |
| 1683 | + | |
1739 | 1684 | | |
1740 | 1685 | | |
1741 | 1686 | | |
| |||
1767 | 1712 | | |
1768 | 1713 | | |
1769 | 1714 | | |
1770 | | - | |
1771 | | - | |
1772 | | - | |
| 1715 | + | |
| 1716 | + | |
1773 | 1717 | | |
1774 | 1718 | | |
1775 | 1719 | | |
| |||
1856 | 1800 | | |
1857 | 1801 | | |
1858 | 1802 | | |
1859 | | - | |
1860 | | - | |
| 1803 | + | |
1861 | 1804 | | |
1862 | 1805 | | |
1863 | 1806 | | |
1864 | | - | |
| 1807 | + | |
1865 | 1808 | | |
1866 | 1809 | | |
1867 | 1810 | | |
1868 | 1811 | | |
1869 | 1812 | | |
1870 | | - | |
1871 | | - | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
1872 | 1816 | | |
1873 | | - | |
1874 | | - | |
1875 | | - | |
1876 | | - | |
1877 | | - | |
1878 | | - | |
1879 | | - | |
1880 | | - | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
1881 | 1822 | | |
1882 | 1823 | | |
1883 | 1824 | | |
| |||
1966 | 1907 | | |
1967 | 1908 | | |
1968 | 1909 | | |
1969 | | - | |
1970 | | - | |
1971 | | - | |
1972 | | - | |
| 1910 | + | |
| 1911 | + | |
1973 | 1912 | | |
1974 | 1913 | | |
1975 | 1914 | | |
| |||
1980 | 1919 | | |
1981 | 1920 | | |
1982 | 1921 | | |
1983 | | - | |
| 1922 | + | |
1984 | 1923 | | |
1985 | 1924 | | |
1986 | 1925 | | |
| |||
2064 | 2003 | | |
2065 | 2004 | | |
2066 | 2005 | | |
2067 | | - | |
2068 | | - | |
2069 | | - | |
| 2006 | + | |
| 2007 | + | |
2070 | 2008 | | |
2071 | 2009 | | |
2072 | 2010 | | |
| |||
2135 | 2073 | | |
2136 | 2074 | | |
2137 | 2075 | | |
2138 | | - | |
2139 | | - | |
2140 | | - | |
| 2076 | + | |
| 2077 | + | |
2141 | 2078 | | |
2142 | 2079 | | |
2143 | 2080 | | |
| |||
2195 | 2132 | | |
2196 | 2133 | | |
2197 | 2134 | | |
2198 | | - | |
| 2135 | + | |
2199 | 2136 | | |
2200 | 2137 | | |
2201 | 2138 | | |
| |||
2218 | 2155 | | |
2219 | 2156 | | |
2220 | 2157 | | |
2221 | | - | |
| 2158 | + | |
2222 | 2159 | | |
0 commit comments