Skip to content

Commit 33b89a3

Browse files
Add long error explanation for E0531
1 parent c9edc02 commit 33b89a3

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

src/librustc_resolve/error_codes.rs

+45-1
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,51 @@ match r {
15251525
```
15261526
"##,
15271527

1528+
E0531: r##"
1529+
An unknown tuple struct/variant has been used.
1530+
1531+
Erroneous code example:
1532+
1533+
```compile_fail,E0531
1534+
let Type(x) = Type(12); // error!
1535+
match Bar(12) {
1536+
Bar(x) => {} // error!
1537+
_ => {}
1538+
}
1539+
```
1540+
1541+
In most cases, it's either a forgotten import or a typo. However, let's look at
1542+
how you can have such a type:
1543+
1544+
```edition2018
1545+
struct Type(u32); // this is a tuple struct
1546+
1547+
enum Foo {
1548+
Bar(u32), // this is a tuple variant
1549+
}
1550+
1551+
use Foo::*; // To use Foo's variant directly, we need to import them in
1552+
// the scope.
1553+
```
1554+
1555+
Either way, it should work fine with our previous code:
1556+
1557+
```edition2018
1558+
struct Type(u32);
1559+
1560+
enum Foo {
1561+
Bar(u32),
1562+
}
1563+
use Foo::*;
1564+
1565+
let Type(x) = Type(12); // ok!
1566+
match Type(12) {
1567+
Type(x) => {} // ok!
1568+
_ => {}
1569+
}
1570+
```
1571+
"##,
1572+
15281573
E0532: r##"
15291574
Pattern arm did not match expected kind.
15301575
@@ -1675,7 +1720,6 @@ fn const_id<T, const N: T>() -> T { // error: const parameter
16751720
// E0419, merged into 531
16761721
// E0420, merged into 532
16771722
// E0421, merged into 531
1678-
E0531, // unresolved pattern path kind `name`
16791723
// E0427, merged into 530
16801724
// E0467, removed
16811725
// E0470, removed

0 commit comments

Comments
 (0)