Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir/src/display.rs7
-rw-r--r--crates/ide/src/hover/tests.rs57
2 files changed, 61 insertions, 3 deletions
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs
index 07e61a83c4..afdac484a1 100644
--- a/crates/hir/src/display.rs
+++ b/crates/hir/src/display.rs
@@ -192,9 +192,10 @@ fn write_impl_header<'db>(impl_: &Impl, f: &mut HirFormatter<'_, 'db>) -> Result
let def_id = GenericDefId::ImplId(impl_.id);
write_generic_params(def_id, f)?;
- if let Some(trait_) = impl_.trait_(db) {
- let trait_data = db.trait_signature(trait_.id);
- write!(f, " {} for", trait_data.name.display(db, f.edition()))?;
+ if let Some(trait_ref) = impl_.trait_ref(db) {
+ f.write_char(' ')?;
+ trait_ref.hir_fmt(f)?;
+ f.write_str(" for")?;
}
f.write_char(' ')?;
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 071eacf660..5330b7eb99 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -11169,3 +11169,60 @@ fn foo() {
"#]],
);
}
+
+#[test]
+fn hover_trait_impl_shows_generic_args() {
+ // Single generic arg
+ check(
+ r#"
+trait Foo<T> {
+ fn foo(&self) {}
+}
+
+impl<T> Foo<()> for T {
+ fn fo$0o(&self) {}
+}
+
+fn bar() {
+ ().foo();
+}
+"#,
+ expect![[r#"
+ *foo*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ impl<T> Foo<()> for T
+ fn foo(&self)
+ ```
+ "#]],
+ );
+
+ // Multiple generic args
+ check(
+ r#"
+trait Foo<A, B> {
+ fn foo(&self) {}
+}
+
+impl<T> Foo<i32, u64> for T {
+ fn fo$0o(&self) {}
+}
+"#,
+ expect![[r#"
+ *foo*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ impl<T> Foo<i32, u64> for T
+ fn foo(&self)
+ ```
+ "#]],
+ );
+}