Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/dot.rs')
-rw-r--r--crates/ide-completion/src/completions/dot.rs77
1 files changed, 77 insertions, 0 deletions
diff --git a/crates/ide-completion/src/completions/dot.rs b/crates/ide-completion/src/completions/dot.rs
index c5bbb7f8d7..5bcc867fe1 100644
--- a/crates/ide-completion/src/completions/dot.rs
+++ b/crates/ide-completion/src/completions/dot.rs
@@ -1095,4 +1095,81 @@ fn test(s: S<Unknown>) {
"#]],
);
}
+
+ #[test]
+ fn assoc_impl_1() {
+ check(
+ r#"
+//- minicore: deref
+fn main() {
+ let foo: Foo<&u8> = Foo::new(&42_u8);
+ foo.$0
+}
+
+trait Bar {
+ fn bar(&self);
+}
+
+impl Bar for u8 {
+ fn bar(&self) {}
+}
+
+struct Foo<F> {
+ foo: F,
+}
+
+impl<F> Foo<F> {
+ fn new(foo: F) -> Foo<F> {
+ Foo { foo }
+ }
+}
+
+impl<F: core::ops::Deref<Target = impl Bar>> Foo<F> {
+ fn foobar(&self) {
+ self.foo.deref().bar()
+ }
+}
+"#,
+ expect![[r#"
+ fd foo &u8
+ me foobar() fn(&self)
+ "#]],
+ );
+ }
+
+ #[test]
+ fn assoc_impl_2() {
+ check(
+ r#"
+//- minicore: deref
+fn main() {
+ let foo: Foo<&u8> = Foo::new(&42_u8);
+ foo.$0
+}
+
+trait Bar {
+ fn bar(&self);
+}
+
+struct Foo<F> {
+ foo: F,
+}
+
+impl<F> Foo<F> {
+ fn new(foo: F) -> Foo<F> {
+ Foo { foo }
+ }
+}
+
+impl<B: Bar, F: core::ops::Deref<Target = B>> Foo<F> {
+ fn foobar(&self) {
+ self.foo.deref().bar()
+ }
+}
+"#,
+ expect![[r#"
+ fd foo &u8
+ "#]],
+ );
+ }
}