Display fully qualified associated types correctly

Currently they are formatted in the internal `Trait<Self = Type>::Assoc`
forms where `hir_ty::TypeRef` is formatted, like hover.
This commit is contained in:
oxalica 2023-08-09 00:04:55 +08:00
parent af4ba46b40
commit 3bfe1d5d78
No known key found for this signature in database
GPG key ID: D425CB23CADE82D9
2 changed files with 78 additions and 7 deletions

View file

@ -1556,6 +1556,49 @@ fn test_hover_function_show_types() {
);
}
#[test]
fn test_hover_function_associated_type_params() {
check(
r#"
trait Foo { type Bar; }
impl Foo for i32 { type Bar = i64; }
fn foo(arg: <i32 as Foo>::Bar) {}
fn main() { foo$0; }
"#,
expect![[r#"
*foo*
```rust
test
```
```rust
fn foo(arg: <i32 as Foo>::Bar)
```
"#]],
);
check(
r#"
trait Foo<T> { type Bar<U>; }
impl Foo<i64> for i32 { type Bar<U> = i32; }
fn foo(arg: <<i32 as Foo<i64>>::Bar<i8> as Foo<i64>>::Bar<i8>) {}
fn main() { foo$0; }
"#,
expect![[r#"
*foo*
```rust
test
```
```rust
fn foo(arg: <<i32 as Foo<i64>>::Bar<i8> as Foo<i64>>::Bar<i8>)
```
"#]],
);
}
#[test]
fn test_hover_function_pointer_show_identifiers() {
check(