@@ -1611,6 +1611,80 @@ fn print_on_failure(state: &State) {
1611
1611
```
1612
1612
"## ,
1613
1613
1614
+ E0573 : r##"
1615
+ Something other than a type has been used when one was expected.
1616
+
1617
+ Erroneous code examples:
1618
+
1619
+ ```compile_fail,E0573
1620
+ enum Dragon {
1621
+ Born,
1622
+ }
1623
+
1624
+ fn oblivion() -> Dragon::Born { // error!
1625
+ Dragon::Born
1626
+ }
1627
+
1628
+ const HOBBIT: u32 = 2;
1629
+ impl HOBBIT {} // error!
1630
+
1631
+ enum Wizard {
1632
+ Gandalf,
1633
+ Saruman,
1634
+ }
1635
+
1636
+ trait Isengard {
1637
+ fn wizard(_: Wizard::Saruman); // error!
1638
+ }
1639
+ ```
1640
+
1641
+ In all these errors, a type was expected. For example, in the first error, if
1642
+ we want to return the `Born` variant from the `Dragon` enum, we must set the
1643
+ function to return the enum and not its variant:
1644
+
1645
+ ```
1646
+ enum Dragon {
1647
+ Born,
1648
+ }
1649
+
1650
+ fn oblivion() -> Dragon { // ok!
1651
+ Dragon::Born
1652
+ }
1653
+ ```
1654
+
1655
+ In the second error, you can't implement something on an item, only on types.
1656
+ We would need to create a new type if we wanted to do something similar:
1657
+
1658
+ ```
1659
+ struct Hobbit(u32); // we create a new type
1660
+
1661
+ const HOBBIT: Hobbit = Hobbit(2);
1662
+ impl Hobbit {} // ok!
1663
+ ```
1664
+
1665
+ In the third case, we tried to only expect one variant of the `Wizard` enum,
1666
+ which is not possible. To make this work, we need to using pattern matching
1667
+ over the `Wizard` enum:
1668
+
1669
+ ```
1670
+ enum Wizard {
1671
+ Gandalf,
1672
+ Saruman,
1673
+ }
1674
+
1675
+ trait Isengard {
1676
+ fn wizard(w: Wizard) { // error!
1677
+ match w {
1678
+ Wizard::Saruman => {
1679
+ // do something
1680
+ }
1681
+ _ => {} // ignore everything else
1682
+ }
1683
+ }
1684
+ }
1685
+ ```
1686
+ "## ,
1687
+
1614
1688
E0574 : r##"
1615
1689
Something other than a struct, variant or union has been used when one was
1616
1690
expected.
@@ -1788,7 +1862,6 @@ struct Foo<X = Box<Self>> {
1788
1862
// E0427, merged into 530
1789
1863
// E0467, removed
1790
1864
// E0470, removed
1791
- E0573 ,
1792
1865
E0575 ,
1793
1866
E0576 ,
1794
1867
E0577 ,
0 commit comments