aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-05-23 15:59:23 +0100
committerFlorian Diebold <[email protected]>2021-05-23 17:24:21 +0100
commit4a6cdd776d403bacce0a5471d77e8c76695c5bc5 (patch)
tree63f29d9de92697b522c6cc274324764c31ef904f /crates/ide_completion
parent96e5412f881608d703df129ed87f3488ad39a9e1 (diff)
Record method call substs and use them in call info
Diffstat (limited to 'crates/ide_completion')
-rw-r--r--crates/ide_completion/src/context.rs60
1 files changed, 60 insertions, 0 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index 787eb2fd3..c929d7394 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -785,6 +785,19 @@ fn foo() {
785 } 785 }
786 786
787 #[test] 787 #[test]
788 fn expected_type_generic_struct_field() {
789 check_expected_type_and_name(
790 r#"
791struct Foo<T> { a: T }
792fn foo() -> Foo<u32> {
793 Foo { a: $0 }
794}
795"#,
796 expect![[r#"ty: u32, name: a"#]],
797 )
798 }
799
800 #[test]
788 fn expected_type_struct_field_with_leading_char() { 801 fn expected_type_struct_field_with_leading_char() {
789 cov_mark::check!(expected_type_struct_field_with_leading_char); 802 cov_mark::check!(expected_type_struct_field_with_leading_char);
790 check_expected_type_and_name( 803 check_expected_type_and_name(
@@ -895,4 +908,51 @@ fn foo() -> u32 {
895 expect![[r#"ty: u32, name: ?"#]], 908 expect![[r#"ty: u32, name: ?"#]],
896 ) 909 )
897 } 910 }
911
912 #[test]
913 fn expected_type_closure_param() {
914 check_expected_type_and_name(
915 r#"
916fn foo() {
917 bar(|| $0);
918}
919
920fn bar(f: impl FnOnce() -> u32) {}
921#[lang = "fn_once"]
922trait FnOnce { type Output; }
923"#,
924 expect![[r#"ty: u32, name: ?"#]],
925 );
926 }
927
928 #[test]
929 fn expected_type_generic_function() {
930 check_expected_type_and_name(
931 r#"
932fn foo() {
933 bar::<u32>($0);
934}
935
936fn bar<T>(t: T) {}
937"#,
938 expect![[r#"ty: u32, name: t"#]],
939 );
940 }
941
942 #[test]
943 fn expected_type_generic_method() {
944 check_expected_type_and_name(
945 r#"
946fn foo() {
947 S(1u32).bar($0);
948}
949
950struct S<T>(T);
951impl<T> S<T> {
952 fn bar(self, t: T) {}
953}
954"#,
955 expect![[r#"ty: u32, name: t"#]],
956 );
957 }
898} 958}