Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/hover/tests.rs')
-rw-r--r--crates/ide/src/hover/tests.rs138
1 files changed, 116 insertions, 22 deletions
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index e63717e35a..cec1375271 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -17,6 +17,7 @@ const HOVER_BASE_CONFIG: HoverConfig = HoverConfig {
documentation: true,
format: HoverDocFormat::Markdown,
keywords: true,
+ trait_assoc_items_size: None,
};
fn check_hover_no_result(ra_fixture: &str) {
@@ -411,7 +412,7 @@ fn main() {
name: "FnOnce",
kind: Trait,
container_name: "function",
- description: "pub trait FnOnce<Args>\nwhere\n Args: Tuple,",
+ description: "pub trait FnOnce<Args>\nwhere\n Args: Tuple, {\n pub type Output,\n pub extern \"rust-call\" fn call_once(self, args: Args) -> Self::Output,\n}",
},
},
],
@@ -2685,7 +2686,7 @@ fn main() { let s$0t = foo(); }
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo",
+ description: "trait Foo {}",
},
},
],
@@ -2719,7 +2720,7 @@ fn main() { let s$0t = foo(); }
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo<T>",
+ description: "trait Foo<T> {}",
},
},
HoverGotoTypeData {
@@ -2766,7 +2767,7 @@ fn main() { let s$0t = foo(); }
focus_range: 19..22,
name: "Bar",
kind: Trait,
- description: "trait Bar",
+ description: "trait Bar {}",
},
},
HoverGotoTypeData {
@@ -2779,7 +2780,7 @@ fn main() { let s$0t = foo(); }
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo",
+ description: "trait Foo {}",
},
},
],
@@ -2816,7 +2817,7 @@ fn main() { let s$0t = foo(); }
focus_range: 22..25,
name: "Bar",
kind: Trait,
- description: "trait Bar<T>",
+ description: "trait Bar<T> {}",
},
},
HoverGotoTypeData {
@@ -2829,7 +2830,7 @@ fn main() { let s$0t = foo(); }
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo<T>",
+ description: "trait Foo<T> {}",
},
},
HoverGotoTypeData {
@@ -2886,7 +2887,7 @@ fn foo(ar$0g: &impl Foo) {}
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo",
+ description: "trait Foo {}",
},
},
],
@@ -2920,7 +2921,7 @@ fn foo(ar$0g: &impl Foo + Bar<S>) {}
focus_range: 19..22,
name: "Bar",
kind: Trait,
- description: "trait Bar<T>",
+ description: "trait Bar<T> {}",
},
},
HoverGotoTypeData {
@@ -2933,7 +2934,7 @@ fn foo(ar$0g: &impl Foo + Bar<S>) {}
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo",
+ description: "trait Foo {}",
},
},
HoverGotoTypeData {
@@ -2988,7 +2989,7 @@ pub mod future {
name: "Future",
kind: Trait,
container_name: "future",
- description: "pub trait Future",
+ description: "pub trait Future {}",
},
},
HoverGotoTypeData {
@@ -3033,7 +3034,7 @@ fn foo(ar$0g: &impl Foo<S>) {}
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo<T>",
+ description: "trait Foo<T> {}",
},
},
HoverGotoTypeData {
@@ -3096,7 +3097,7 @@ fn main() { let s$0t = foo(); }
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo",
+ description: "trait Foo {}",
},
},
],
@@ -3127,7 +3128,7 @@ fn foo(ar$0g: &dyn Foo) {}
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo",
+ description: "trait Foo {}",
},
},
],
@@ -3159,7 +3160,7 @@ fn foo(ar$0g: &dyn Foo<S>) {}
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo<T>",
+ description: "trait Foo<T> {}",
},
},
HoverGotoTypeData {
@@ -3220,7 +3221,7 @@ fn foo(a$0rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
focus_range: 28..36,
name: "DynTrait",
kind: Trait,
- description: "trait DynTrait<T>",
+ description: "trait DynTrait<T> {}",
},
},
HoverGotoTypeData {
@@ -3233,7 +3234,7 @@ fn foo(a$0rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
focus_range: 6..15,
name: "ImplTrait",
kind: Trait,
- description: "trait ImplTrait<T>",
+ description: "trait ImplTrait<T> {}",
},
},
HoverGotoTypeData {
@@ -3288,7 +3289,7 @@ fn main() { let s$0t = test().get(); }
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo",
+ description: "trait Foo {\n type Item,\n fn get(self) -> Self::Item,\n}",
},
},
],
@@ -3353,7 +3354,7 @@ fn foo<T: Foo>(t: T$0){}
focus_range: 6..9,
name: "Foo",
kind: Trait,
- description: "trait Foo",
+ description: "trait Foo {}",
},
},
],
@@ -6328,6 +6329,99 @@ impl T for () {
}
#[test]
+fn hover_trait_show_assoc_items() {
+ check(
+ r#"
+trait T {}
+impl T$0 for () {}
+"#,
+ expect![[r#"
+ *T*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ trait T {}
+ ```
+ "#]],
+ );
+
+ check(
+ r#"
+trait T {
+ fn func() {}
+}
+impl T$0 for () {}
+"#,
+ expect![[r#"
+ *T*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ trait T {
+ fn func(),
+ }
+ ```
+ "#]],
+ );
+
+ check(
+ r#"
+trait T {
+ fn func() {}
+ const FLAG: i32 = 34;
+}
+impl T$0 for () {}
+"#,
+ expect![[r#"
+ *T*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ trait T {
+ fn func(),
+ const FLAG: i32,
+ }
+ ```
+ "#]],
+ );
+
+ check(
+ r#"
+trait T {
+ fn func() {}
+ const FLAG: i32 = 34;
+ type Bar;
+}
+impl T$0 for () {}
+"#,
+ expect![[r#"
+ *T*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ trait T {
+ fn func(),
+ const FLAG: i32,
+ type Bar,
+ }
+ ```
+ "#]],
+ );
+}
+
+#[test]
fn hover_ranged_macro_call() {
check_hover_range(
r#"
@@ -7438,7 +7532,7 @@ impl Iterator for S {
name: "Future",
kind: Trait,
container_name: "future",
- description: "pub trait Future",
+ description: "pub trait Future {\n pub type Output,\n pub fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>,\n}",
},
},
HoverGotoTypeData {
@@ -7452,7 +7546,7 @@ impl Iterator for S {
name: "Iterator",
kind: Trait,
container_name: "iterator",
- description: "pub trait Iterator",
+ description: "pub trait Iterator {\n pub type Item,\n pub fn next(&mut self) -> Option<Self::Item>,\n pub fn nth(&mut self, n: usize) -> Option<Self::Item>,\n pub fn by_ref(&mut self) -> &mut Self\nwhere\n Self: Sized,,\n}",
},
},
HoverGotoTypeData {
@@ -7465,7 +7559,7 @@ impl Iterator for S {
focus_range: 49..56,
name: "Notable",
kind: Trait,
- description: "trait Notable",
+ description: "trait Notable {}",
},
},
HoverGotoTypeData {