]> git.lizzy.rs Git - rust.git/commitdiff
Add test for current incorrect behaviour
authorLukas Wirth <lukastw97@gmail.com>
Mon, 8 Nov 2021 13:10:26 +0000 (14:10 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Mon, 8 Nov 2021 13:10:26 +0000 (14:10 +0100)
crates/ide_completion/src/context.rs

index 8fae06f7e2410d2713d509bcfd9f1b9260b8514e..ac01968126d152159bd639df7ba98b2fa719a707 100644 (file)
@@ -598,7 +598,8 @@ fn expected_type_and_name(&self) -> (Option<Type>, Option<NameOrNameRef>) {
                             .map(|c| (Some(c.return_type()), None))
                             .unwrap_or((None, None))
                     },
-                    ast::Stmt(_it) => (None, None),
+                    ast::ParamList(__) => (None, None),
+                    ast::Stmt(__) => (None, None),
                     ast::Item(__) => (None, None),
                     _ => {
                         match node.parent() {
@@ -1174,4 +1175,23 @@ fn foo() {
             expect![[r#"ty: Foo, name: ?"#]],
         );
     }
+
+    #[test]
+    fn expected_type_param_pat() {
+        check_expected_type_and_name(
+            r#"
+struct Foo { field: u32 }
+fn foo(a$0: Foo) {}
+"#,
+            expect![[r#"ty: Foo, name: ?"#]],
+        );
+        check_expected_type_and_name(
+            r#"
+struct Foo { field: u32 }
+fn foo($0: Foo) {}
+"#,
+            // FIXME make this work, currently fails due to pattern recovery eating the `:`
+            expect![[r#"ty: ?, name: ?"#]],
+        );
+    }
 }