Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/tests/flyimport.rs')
-rw-r--r--crates/ide-completion/src/tests/flyimport.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/ide-completion/src/tests/flyimport.rs b/crates/ide-completion/src/tests/flyimport.rs
index d2227d23cd..abffa73c3b 100644
--- a/crates/ide-completion/src/tests/flyimport.rs
+++ b/crates/ide-completion/src/tests/flyimport.rs
@@ -473,6 +473,47 @@ fn main() {
}
#[test]
+fn trait_completions_handle_associated_types() {
+ let fixture = r#"
+//- /foo.rs crate:foo
+pub trait NotInScope {
+ fn not_in_scope(&self);
+}
+
+pub trait Wrapper {
+ type Inner: NotInScope;
+ fn inner(&self) -> Self::Inner;
+}
+
+//- /main.rs crate:main deps:foo
+use foo::Wrapper;
+
+fn completion<T: Wrapper>(whatever: T) {
+ whatever.inner().$0
+}
+"#;
+
+ check(
+ fixture,
+ expect![[r#"
+ me not_in_scope() (use foo::NotInScope) fn(&self)
+ "#]],
+ );
+
+ check_edit(
+ "not_in_scope",
+ fixture,
+ r#"
+use foo::{NotInScope, Wrapper};
+
+fn completion<T: Wrapper>(whatever: T) {
+ whatever.inner().not_in_scope()$0
+}
+"#,
+ );
+}
+
+#[test]
fn trait_method_fuzzy_completion_aware_of_unit_type() {
let fixture = r#"
//- /test_trait.rs crate:test_trait