diff options
author | Josh Mcguigan <[email protected]> | 2020-04-12 05:20:52 +0100 |
---|---|---|
committer | Josh Mcguigan <[email protected]> | 2020-04-12 05:20:52 +0100 |
commit | bb2e5308b77e5d115df17411aaa2dd26be171b0a (patch) | |
tree | dad40a23c15f1009cfdd5fb2190ee7e7f14a038d /crates/ra_hir_ty/src/_match.rs | |
parent | a59179ac2d0894dc45d614242816665b9bd6ef8a (diff) |
missing match arm add test cases to demonstrate enum tuple struct with ellipsis behavior
Diffstat (limited to 'crates/ra_hir_ty/src/_match.rs')
-rw-r--r-- | crates/ra_hir_ty/src/_match.rs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs index c9a6551ab..c482cf619 100644 --- a/crates/ra_hir_ty/src/_match.rs +++ b/crates/ra_hir_ty/src/_match.rs | |||
@@ -1484,6 +1484,45 @@ mod tests { | |||
1484 | 1484 | ||
1485 | check_no_diagnostic(content); | 1485 | check_no_diagnostic(content); |
1486 | } | 1486 | } |
1487 | |||
1488 | #[test] | ||
1489 | fn enum_tuple_partial_ellipsis_no_diagnostic() { | ||
1490 | let content = r" | ||
1491 | enum Either { | ||
1492 | A(bool, bool, bool, bool), | ||
1493 | B, | ||
1494 | } | ||
1495 | fn test_fn() { | ||
1496 | match Either::B { | ||
1497 | Either::A(true, .., true) => {}, | ||
1498 | Either::A(true, .., false) => {}, | ||
1499 | Either::A(false, .., true) => {}, | ||
1500 | Either::A(false, .., false) => {}, | ||
1501 | Either::B => {}, | ||
1502 | } | ||
1503 | } | ||
1504 | "; | ||
1505 | |||
1506 | check_no_diagnostic(content); | ||
1507 | } | ||
1508 | |||
1509 | #[test] | ||
1510 | fn enum_tuple_ellipsis_no_diagnostic() { | ||
1511 | let content = r" | ||
1512 | enum Either { | ||
1513 | A(bool, bool, bool, bool), | ||
1514 | B, | ||
1515 | } | ||
1516 | fn test_fn() { | ||
1517 | match Either::B { | ||
1518 | Either::A(..) => {}, | ||
1519 | Either::B => {}, | ||
1520 | } | ||
1521 | } | ||
1522 | "; | ||
1523 | |||
1524 | check_no_diagnostic(content); | ||
1525 | } | ||
1487 | } | 1526 | } |
1488 | 1527 | ||
1489 | #[cfg(test)] | 1528 | #[cfg(test)] |
@@ -1628,4 +1667,29 @@ mod false_negatives { | |||
1628 | // See comments on `tuple_of_bools_with_ellipsis_at_end_missing_arm`. | 1667 | // See comments on `tuple_of_bools_with_ellipsis_at_end_missing_arm`. |
1629 | check_no_diagnostic(content); | 1668 | check_no_diagnostic(content); |
1630 | } | 1669 | } |
1670 | |||
1671 | #[test] | ||
1672 | fn enum_tuple_partial_ellipsis_missing_arm() { | ||
1673 | let content = r" | ||
1674 | enum Either { | ||
1675 | A(bool, bool, bool, bool), | ||
1676 | B, | ||
1677 | } | ||
1678 | fn test_fn() { | ||
1679 | match Either::B { | ||
1680 | Either::A(true, .., true) => {}, | ||
1681 | Either::A(true, .., false) => {}, | ||
1682 | Either::A(false, .., false) => {}, | ||
1683 | Either::B => {}, | ||
1684 | } | ||
1685 | } | ||
1686 | "; | ||
1687 | |||
1688 | // This is a false negative. | ||
1689 | // The `..` pattern is currently lowered to a single `Pat::Wild` | ||
1690 | // no matter how many fields the `..` pattern is covering. This | ||
1691 | // causes us to return a `MatchCheckErr::MalformedMatchArm` in | ||
1692 | // `Pat::specialize_constructor`. | ||
1693 | check_no_diagnostic(content); | ||
1694 | } | ||
1631 | } | 1695 | } |