missing match arms add test cases to demonstrate behavior of tuple with pattern
This commit is contained in:
parent
aec20e5094
commit
a59179ac2d
@ -972,6 +972,47 @@ mod tests {
|
|||||||
check_no_diagnostic(content);
|
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]
|
#[test]
|
||||||
fn tuple_of_tuple_and_bools_no_arms() {
|
fn tuple_of_tuple_and_bools_no_arms() {
|
||||||
let content = r"
|
let content = r"
|
||||||
@ -1553,4 +1594,38 @@ mod false_negatives {
|
|||||||
// with `!`.
|
// with `!`.
|
||||||
check_no_diagnostic(content);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user