missing match arms add test cases to demonstrate behavior of tuple with pattern

This commit is contained in:
Josh Mcguigan 2020-04-11 20:50:54 -07:00
parent aec20e5094
commit a59179ac2d

View file

@ -972,6 +972,47 @@ mod tests {
check_no_diagnostic(content);
}
#[test]
fn tuple_of_bools_with_ellipsis_at_end_no_diagnostic() {
let content = r"
fn test_fn() {
match (false, true, false) {
(false, ..) => {},
(true, ..) => {},
}
}
";
check_no_diagnostic(content);
}
#[test]
fn tuple_of_bools_with_ellipsis_at_beginning_no_diagnostic() {
let content = r"
fn test_fn() {
match (false, true, false) {
(.., false) => {},
(.., true) => {},
}
}
";
check_no_diagnostic(content);
}
#[test]
fn tuple_of_bools_with_ellipsis_no_diagnostic() {
let content = r"
fn test_fn() {
match (false, true, false) {
(..) => {},
}
}
";
check_no_diagnostic(content);
}
#[test]
fn tuple_of_tuple_and_bools_no_arms() {
let content = r"
@ -1553,4 +1594,38 @@ mod false_negatives {
// with `!`.
check_no_diagnostic(content);
}
#[test]
fn tuple_of_bools_with_ellipsis_at_end_missing_arm() {
let content = r"
fn test_fn() {
match (false, true, false) {
(false, ..) => {},
}
}
";
// This is a false negative.
// The `..` pattern is currently lowered to a single `Pat::Wild`
// no matter how many fields the `..` pattern is covering. This
// causes the match arm in this test not to type check against
// the match expression, which causes this diagnostic not to
// fire.
check_no_diagnostic(content);
}
#[test]
fn tuple_of_bools_with_ellipsis_at_beginning_missing_arm() {
let content = r"
fn test_fn() {
match (false, true, false) {
(.., false) => {},
}
}
";
// This is a false negative.
// See comments on `tuple_of_bools_with_ellipsis_at_end_missing_arm`.
check_no_diagnostic(content);
}
}