mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
missing match arms add test cases to demonstrate behavior of tuple with pattern
This commit is contained in:
parent
aec20e5094
commit
a59179ac2d
1 changed files with 75 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue