]> git.lizzy.rs Git - rust.git/commitdiff
Test fill-match-arms assist: partial with wildcards
authorDawer <7803845+iDawer@users.noreply.github.com>
Sat, 17 Apr 2021 10:20:29 +0000 (15:20 +0500)
committerDawer <7803845+iDawer@users.noreply.github.com>
Sat, 17 Apr 2021 10:20:29 +0000 (15:20 +0500)
crates/ide_assists/src/handlers/fill_match_arms.rs

index e4794f17c95e80062b03e3a1239157e0052a76cf..6408d7f0bf8c9e356b1059d0ef63d9f1b6b44bdc 100644 (file)
@@ -504,6 +504,40 @@ fn main() {
         );
     }
 
+    // Fixme: This fails with extra useless match arms added.
+    // To fix, it needs full fledged match exhaustiveness checking from
+    // hir_ty::diagnostics::match_check
+    // see https://github.com/rust-analyzer/rust-analyzer/issues/8493
+    #[ignore]
+    #[test]
+    fn fill_match_arms_tuple_of_enum_partial_with_wildcards() {
+        let ra_fixture = r#"
+fn main() {
+    let a = Some(1);
+    let b = Some(());
+    match (a$0, b) {
+        (Some(_), _) => {}
+        (None, Some(_)) => {}
+    }
+}
+"#;
+        check_assist(
+            fill_match_arms,
+            &format!("//- /main.rs crate:main deps:core{}{}", ra_fixture, FamousDefs::FIXTURE),
+            r#"
+fn main() {
+    let a = Some(1);
+    let b = Some(());
+    match (a, b) {
+        (Some(_), _) => {}
+        (None, Some(_)) => {}
+        $0(None, None) => {}
+    }
+}
+"#,
+        );
+    }
+
     #[test]
     fn fill_match_arms_tuple_of_enum_not_applicable() {
         check_assist_not_applicable(