Skip to content

Commit aa80a8c

Browse files
Rollup merge of #37475 - AndiDog:feature/error-explanation-E0532, r=GuillaumeGomez
Add E0532 error explanation This resolves one of the error list in #35347 - just because I stumbled over it today. I assumed the error code should be removed from `register_diagnostics!` because it's now defined above. Since that is my first code contribution, please check that all is in order. It would be helpful to know how to run the test for the `compile_fail,E0532` part. I did `make check-stage1-cfail NO_REBUILD=1` but that doesn't test the inlined example. r? @GuillaumeGomez
2 parents 46cfba2 + c8937e0 commit aa80a8c

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/librustc_resolve/diagnostics.rs

Lines changed: 41 additions & 1 deletion
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)