From 444f6caababc3335b1ed51d08eeedac106fd8077 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 1 Apr 2021 18:01:18 +0200 Subject: Resolve associated types --- crates/ide/src/hover.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'crates/ide') diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 5f9edb476..8f98056c1 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -3834,4 +3834,46 @@ fn foo() {} "#]], ); } + + #[test] + fn hover_generic_assoc() { + check( + r#" +fn foo() where T::Assoc$0: {} + +trait A { + type Assoc; +}"#, + expect![[r#" + *Assoc* + + ```rust + test + ``` + + ```rust + type Assoc + ``` + "#]], + ); + check( + r#" +trait A where + Self::Assoc$0: , +{ + type Assoc; +}"#, + expect![[r#" + *Assoc* + + ```rust + test + ``` + + ```rust + type Assoc + ``` + "#]], + ) + } } -- cgit v1.2.3 From 9fe10a96069ea0f617ff86049bb50922b5424fae Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 1 Apr 2021 21:52:07 +0200 Subject: Resolve associated types with type anchors --- crates/ide/src/hover.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'crates/ide') diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 8f98056c1..28e2e17dc 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -3841,6 +3841,27 @@ fn foo() {} r#" fn foo() where T::Assoc$0: {} +trait A { + type Assoc; +}"#, + expect![[r#" + *Assoc* + + ```rust + test + ``` + + ```rust + type Assoc + ``` + "#]], + ); + check( + r#" +fn foo() { + let _: ::Assoc$0; +} + trait A { type Assoc; }"#, @@ -3874,6 +3895,6 @@ trait A where type Assoc ``` "#]], - ) + ); } } -- cgit v1.2.3