Skip to content

Commit 98ddcdc

Browse files
authored
Rollup merge of rust-lang#64455 - GuillaumeGomez:long-error-explanation-E0531, r=Centril
Add Long error explanation for E0531 Part of rust-lang#61137.
2 parents dccc8b4 + 2fd3811 commit 98ddcdc

7 files changed

+54
-5
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

src/test/ui/enums-pats-not-idents.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | let a(1) = 13;
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0531`.

src/test/ui/issues/issue-5927.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ LL | x(1) => x(1)
1212

1313
error: aborting due to 2 previous errors
1414

15-
For more information about this error, try `rustc --explain E0425`.
15+
Some errors have detailed explanations: E0425, E0531.
16+
For more information about an error, try `rustc --explain E0425`.

src/test/ui/keyword/keyword-self-as-identifier.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | let Self = 22;
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0531`.

src/test/ui/resolve/resolve-assoc-suggestions.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ LL | method;
5454

5555
error: aborting due to 9 previous errors
5656

57-
Some errors have detailed explanations: E0412, E0425.
57+
Some errors have detailed explanations: E0412, E0425, E0531.
5858
For more information about an error, try `rustc --explain E0412`.

src/test/ui/self/self_type_keyword-2.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ LL | Foo { x: Self } => (),
2424

2525
error: aborting due to 4 previous errors
2626

27-
For more information about this error, try `rustc --explain E0432`.
27+
Some errors have detailed explanations: E0432, E0531.
28+
For more information about an error, try `rustc --explain E0432`.

src/test/ui/self/self_type_keyword.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@ LL | struct Bar<'Self>;
8080

8181
error: aborting due to 12 previous errors
8282

83-
For more information about this error, try `rustc --explain E0392`.
83+
Some errors have detailed explanations: E0392, E0531.
84+
For more information about an error, try `rustc --explain E0392`.

0 commit comments

Comments
 (0)