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 @@ -1661,6 +1661,59 @@ match eco {
16611661```
16621662"## ,
16631663
1664+ E0575 : r##"
1665+ Something other than a type or an associated type was given.
1666+
1667+ Erroneous code example:
1668+
1669+ ```compile_fail,E0575
1670+ enum Rick { Morty }
1671+
1672+ let _: <u8 as Rick>::Morty; // error!
1673+
1674+ trait Age {
1675+ type Empire;
1676+ fn Mythology() {}
1677+ }
1678+
1679+ impl Age for u8 {
1680+ type Empire = u16;
1681+ }
1682+
1683+ let _: <u8 as Age>::Mythology; // error!
1684+ ```
1685+
1686+ In both cases, we're declaring a variable (called `_`) and we're giving it a
1687+ type. However, `<u8 as Rick>::Morty` and `<u8 as Age>::Mythology` aren't types,
1688+ therefore the compiler throws an error.
1689+
1690+ `<u8 as Rick>::Morty` is an enum variant, you cannot use a variant as a type,
1691+ you have to use the enum directly:
1692+
1693+ ```
1694+ enum Rick { Morty }
1695+
1696+ let _: Rick; // ok!
1697+ ```
1698+
1699+ `<u8 as Age>::Mythology` is a trait method, which is definitely not a type.
1700+ However, the `Age` trait provides an associated type `Empire` which can be
1701+ used as a type:
1702+
1703+ ```
1704+ trait Age {
1705+ type Empire;
1706+ fn Mythology() {}
1707+ }
1708+
1709+ impl Age for u8 {
1710+ type Empire = u16;
1711+ }
1712+
1713+ let _: <u8 as Age>::Empire; // ok!
1714+ ```
1715+ "## ,
1716+
16641717E0603 : r##"
16651718A private item was used outside its scope.
16661719
@@ -1789,7 +1842,6 @@ struct Foo<X = Box<Self>> {
17891842// E0467, removed
17901843// E0470, removed
17911844 E0573 ,
1792- E0575 ,
17931845 E0576 ,
17941846 E0577 ,
17951847 E0578 ,
You can’t perform that action at this time.
0 commit comments