File tree Expand file tree Collapse file tree 1 file changed +53
-1
lines changed Expand file tree Collapse file tree 1 file changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -1735,6 +1735,59 @@ match eco {
17351735```
17361736"## ,
17371737
1738+ E0575 : r##"
1739+ Something other than a type or an associated type was given.
1740+
1741+ Erroneous code example:
1742+
1743+ ```compile_fail,E0575
1744+ enum Rick { Morty }
1745+
1746+ let _: <u8 as Rick>::Morty; // error!
1747+
1748+ trait Age {
1749+ type Empire;
1750+ fn Mythology() {}
1751+ }
1752+
1753+ impl Age for u8 {
1754+ type Empire = u16;
1755+ }
1756+
1757+ let _: <u8 as Age>::Mythology; // error!
1758+ ```
1759+
1760+ In both cases, we're declaring a variable (called `_`) and we're giving it a
1761+ type. However, `<u8 as Rick>::Morty` and `<u8 as Age>::Mythology` aren't types,
1762+ therefore the compiler throws an error.
1763+
1764+ `<u8 as Rick>::Morty` is an enum variant, you cannot use a variant as a type,
1765+ you have to use the enum directly:
1766+
1767+ ```
1768+ enum Rick { Morty }
1769+
1770+ let _: Rick; // ok!
1771+ ```
1772+
1773+ `<u8 as Age>::Mythology` is a trait method, which is definitely not a type.
1774+ However, the `Age` trait provides an associated type `Empire` which can be
1775+ used as a type:
1776+
1777+ ```
1778+ trait Age {
1779+ type Empire;
1780+ fn Mythology() {}
1781+ }
1782+
1783+ impl Age for u8 {
1784+ type Empire = u16;
1785+ }
1786+
1787+ let _: <u8 as Age>::Empire; // ok!
1788+ ```
1789+ "## ,
1790+
17381791E0603 : r##"
17391792A private item was used outside its scope.
17401793
@@ -1862,7 +1915,6 @@ struct Foo<X = Box<Self>> {
18621915// E0427, merged into 530
18631916// E0467, removed
18641917// E0470, removed
1865- E0575 ,
18661918 E0576 ,
18671919 E0577 ,
18681920 E0578 ,
You can’t perform that action at this time.
0 commit comments