aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion')
-rw-r--r--crates/ide_completion/src/completions/attribute/derive.rs49
-rw-r--r--crates/ide_completion/src/completions/keyword.rs20
-rw-r--r--crates/ide_completion/src/completions/unqualified_path.rs18
-rw-r--r--crates/ide_completion/src/render.rs12
4 files changed, 31 insertions, 68 deletions
diff --git a/crates/ide_completion/src/completions/attribute/derive.rs b/crates/ide_completion/src/completions/attribute/derive.rs
index d526824fb..7b3133e53 100644
--- a/crates/ide_completion/src/completions/attribute/derive.rs
+++ b/crates/ide_completion/src/completions/attribute/derive.rs
@@ -93,57 +93,20 @@ mod tests {
93 } 93 }
94 94
95 #[test] 95 #[test]
96 #[ignore] // FIXME: Fixtures cant test proc-macros/derives yet as we cant specify them in fixtures
97 fn empty_derive() { 96 fn empty_derive() {
98 check( 97 // FIXME: Add build-in derives to fixture.
99 r#"#[derive($0)] struct Test;"#, 98 check(r#"#[derive($0)] struct Test;"#, expect![[r#""#]]);
100 expect![[r#"
101 at Clone
102 at Clone, Copy
103 at Debug
104 at Default
105 at Hash
106 at PartialEq
107 at PartialEq, Eq
108 at PartialEq, PartialOrd
109 at PartialEq, Eq, PartialOrd, Ord
110 "#]],
111 );
112 } 99 }
113 100
114 #[test] 101 #[test]
115 #[ignore] // FIXME: Fixtures cant test proc-macros/derives yet as we cant specify them in fixtures
116 fn derive_with_input() { 102 fn derive_with_input() {
117 check( 103 // FIXME: Add build-in derives to fixture.
118 r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#, 104 check(r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#, expect![[r#""#]])
119 expect![[r#"
120 at Clone
121 at Clone, Copy
122 at Debug
123 at Default
124 at Hash
125 at Eq
126 at PartialOrd
127 at Eq, PartialOrd, Ord
128 "#]],
129 )
130 } 105 }
131 106
132 #[test] 107 #[test]
133 #[ignore] // FIXME: Fixtures cant test proc-macros/derives yet as we cant specify them in fixtures
134 fn derive_with_input2() { 108 fn derive_with_input2() {
135 check( 109 // FIXME: Add build-in derives to fixture.
136 r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#, 110 check(r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#, expect![[r#""#]])
137 expect![[r#"
138 at Clone
139 at Clone, Copy
140 at Debug
141 at Default
142 at Hash
143 at Eq
144 at PartialOrd
145 at Eq, PartialOrd, Ord
146 "#]],
147 )
148 } 111 }
149} 112}
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs
index ba13d3707..0fccbeccf 100644
--- a/crates/ide_completion/src/completions/keyword.rs
+++ b/crates/ide_completion/src/completions/keyword.rs
@@ -536,17 +536,11 @@ Some multi-line comment$0
536 fn test_completion_await_impls_future() { 536 fn test_completion_await_impls_future() {
537 check( 537 check(
538 r#" 538 r#"
539//- /main.rs crate:main deps:std 539//- minicore: future
540use std::future::*; 540use core::future::*;
541struct A {} 541struct A {}
542impl Future for A {} 542impl Future for A {}
543fn foo(a: A) { a.$0 } 543fn foo(a: A) { a.$0 }
544
545//- /std/lib.rs crate:std
546pub mod future {
547 #[lang = "future_trait"]
548 pub trait Future {}
549}
550"#, 544"#,
551 expect![[r#" 545 expect![[r#"
552 kw await expr.await 546 kw await expr.await
@@ -555,20 +549,12 @@ pub mod future {
555 549
556 check( 550 check(
557 r#" 551 r#"
558//- /main.rs crate:main deps:std 552//- minicore: future
559use std::future::*; 553use std::future::*;
560fn foo() { 554fn foo() {
561 let a = async {}; 555 let a = async {};
562 a.$0 556 a.$0
563} 557}
564
565//- /std/lib.rs crate:std
566pub mod future {
567 #[lang = "future_trait"]
568 pub trait Future {
569 type Output;
570 }
571}
572"#, 558"#,
573 expect![[r#" 559 expect![[r#"
574 kw await expr.await 560 kw await expr.await
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs
index 952f052a1..f86b2d3f3 100644
--- a/crates/ide_completion/src/completions/unqualified_path.rs
+++ b/crates/ide_completion/src/completions/unqualified_path.rs
@@ -809,4 +809,22 @@ fn foo(_: impl Foo<B$0>) {}
809 "#]], 809 "#]],
810 ); 810 );
811 } 811 }
812
813 #[test]
814 fn completes_assoc_types_in_trait_bound() {
815 check(
816 r#"
817trait Foo {
818 type Bar;
819}
820
821fn foo<T: Foo<B$0>>(_: T) {}
822"#,
823 expect![[r#"
824 ta Bar = type Bar;
825 tp T
826 tt Foo
827 "#]],
828 );
829 }
812} 830}
diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs
index d8ca18c73..3eb51e80b 100644
--- a/crates/ide_completion/src/render.rs
+++ b/crates/ide_completion/src/render.rs
@@ -1152,16 +1152,11 @@ fn main() {
1152 fn suggest_deref() { 1152 fn suggest_deref() {
1153 check_relevance( 1153 check_relevance(
1154 r#" 1154 r#"
1155#[lang = "deref"] 1155//- minicore: deref
1156trait Deref {
1157 type Target;
1158 fn deref(&self) -> &Self::Target;
1159}
1160
1161struct S; 1156struct S;
1162struct T(S); 1157struct T(S);
1163 1158
1164impl Deref for T { 1159impl core::ops::Deref for T {
1165 type Target = S; 1160 type Target = S;
1166 1161
1167 fn deref(&self) -> &Self::Target { 1162 fn deref(&self) -> &Self::Target {
@@ -1185,8 +1180,9 @@ fn main() {
1185 st T [] 1180 st T []
1186 st S [] 1181 st S []
1187 fn main() [] 1182 fn main() []
1188 tt Deref []
1189 fn foo(…) [] 1183 fn foo(…) []
1184 md core []
1185 tt Sized []
1190 "#]], 1186 "#]],
1191 ) 1187 )
1192 } 1188 }