File tree 1 file changed +53
-1
lines changed
1 file changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -1735,6 +1735,59 @@ match eco {
1735
1735
```
1736
1736
"## ,
1737
1737
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
+
1738
1791
E0603 : r##"
1739
1792
A private item was used outside its scope.
1740
1793
@@ -1862,7 +1915,6 @@ struct Foo<X = Box<Self>> {
1862
1915
// E0427, merged into 530
1863
1916
// E0467, removed
1864
1917
// E0470, removed
1865
- E0575 ,
1866
1918
E0576 ,
1867
1919
E0577 ,
1868
1920
E0578 ,
You can’t perform that action at this time.
0 commit comments