Skip to content

Commit c8937e0

Browse files
committedOct 31, 2016
Add E0532 error explanation
1 parent 36d7467 commit c8937e0

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed
 

‎src/librustc_resolve/diagnostics.rs

+41-1
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,47 @@ match r {
14611461
```
14621462
"##,
14631463

1464+
E0532: r##"
1465+
Pattern arm did not match expected kind.
1466+
1467+
Erroneous code example:
1468+
1469+
```compile_fail,E0532
1470+
enum State {
1471+
Succeeded,
1472+
Failed(String),
1473+
}
1474+
1475+
fn print_on_failure(state: &State) {
1476+
match *state {
1477+
// error: expected unit struct/variant or constant, found tuple
1478+
// variant `State::Failed`
1479+
State::Failed => println!("Failed"),
1480+
_ => ()
1481+
}
1482+
}
1483+
```
1484+
1485+
To fix this error, ensure the match arm kind is the same as the expression
1486+
matched.
1487+
1488+
Fixed example:
1489+
1490+
```
1491+
enum State {
1492+
Succeeded,
1493+
Failed(String),
1494+
}
1495+
1496+
fn print_on_failure(state: &State) {
1497+
match *state {
1498+
State::Failed(ref msg) => println!("Failed with {}", msg),
1499+
_ => ()
1500+
}
1501+
}
1502+
```
1503+
"##,
1504+
14641505
}
14651506

14661507
register_diagnostics! {
@@ -1480,6 +1521,5 @@ register_diagnostics! {
14801521
// E0421, merged into 531
14811522
// E0422, merged into 531/532
14821523
E0531, // unresolved pattern path kind `name`
1483-
E0532, // expected pattern path kind, found another pattern path kind
14841524
// E0427, merged into 530
14851525
}

0 commit comments

Comments
 (0)