Skip to content

Commit 7996563

Browse files
committed
Add Error Explanations for E0163 & E0164
Addds `--explain` support for E0163 and E0164.
1 parent 0369304 commit 7996563

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

src/librustc_typeck/diagnostics.rs

+52-2
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,58 @@ fn(isize, *const *const u8) -> isize;
17791779
```
17801780
"##,
17811781

1782+
E0163: r##"
1783+
This error means that an attempt was made to match an enum variant as a
1784+
struct type when the variant isn't a struct type:
1785+
1786+
```
1787+
enum Foo { B(u32) }
1788+
1789+
fn bar(foo: Foo) -> u32 {
1790+
match foo {
1791+
Foo::B{i} => i // error 0163
1792+
}
1793+
}
1794+
```
1795+
1796+
Try using `()` instead:
1797+
1798+
```
1799+
fn bar(foo: Foo) -> u32 {
1800+
match foo {
1801+
Foo::B(i) => i
1802+
}
1803+
}
1804+
```
1805+
"##,
1806+
1807+
E0164: r##"
1808+
1809+
This error means that an attempt was made to match a struct type enum
1810+
variant as a non-struct type:
1811+
1812+
```
1813+
enum Foo { B{ i: u32 } }
1814+
1815+
fn bar(foo: Foo) -> u32 {
1816+
match foo {
1817+
Foo::B(i) => i // error 0164
1818+
}
1819+
}
1820+
```
1821+
1822+
Try using `{}` isntead:
1823+
1824+
```
1825+
fn bar(foo: Foo) -> u32 {
1826+
match foo {
1827+
Foo::B{i} => i
1828+
}
1829+
}
1830+
```
1831+
"##,
1832+
1833+
17821834
E0166: r##"
17831835
This error means that the compiler found a return expression in a function
17841836
marked as diverging. A function diverges if it has `!` in the place of the
@@ -3293,8 +3345,6 @@ register_diagnostics! {
32933345
// E0129,
32943346
// E0141,
32953347
// E0159, // use of trait `{}` as struct constructor
3296-
E0163,
3297-
E0164,
32983348
E0167,
32993349
// E0168,
33003350
// E0173, // manual implementations of unboxed closure traits are experimental

0 commit comments

Comments
 (0)