fix: Omit generic defaults for types in hover messages

This commit is contained in:
Lukas Wirth 2021-11-22 18:27:03 +01:00
parent a07e406d06
commit ec07bb98f8
4 changed files with 17 additions and 5 deletions

View file

@ -639,7 +639,7 @@ impl HirDisplay for Ty {
if let Some(sig) = sig {
if sig.params().is_empty() {
write!(f, "||")?;
} else if f.omit_verbose_types() {
} else if f.should_truncate() {
write!(f, "|{}|", TYPE_HINT_TRUNCATION)?;
} else {
write!(f, "|")?;

View file

@ -444,7 +444,7 @@ fn find_std_module(famous_defs: &FamousDefs, name: &str) -> Option<hir::Module>
fn local(db: &RootDatabase, it: hir::Local) -> Option<Markup> {
let ty = it.ty(db);
let ty = ty.display(db);
let ty = ty.display_truncated(db, None);
let is_mut = if it.is_mut(db) { "mut " } else { "" };
let desc = match it.source(db).value {
Either::Left(ident) => {

View file

@ -607,10 +607,22 @@ fn main() {
*zz*
```rust
let zz: Test<i32, u8>
let zz: Test<i32>
```
"#]],
);
check_hover_range(
r#"
struct Test<K, T = u8> { k: K, t: T }
fn main() {
let $0zz$0 = Test { t: 23u8, k: 33 };
}"#,
expect![[r#"
```rust
Test<i32, u8>
```"#]],
);
}
#[test]

View file

@ -1443,14 +1443,14 @@ fn main() {
//^^^^^^^^^ i32
let multiply =
//^^^^^^^^ || -> i32
//^^^^^^^^ |i32, i32| -> i32
| a, b| a * b
//^ i32 ^ i32
;
let _: i32 = multiply(1, 2);
let multiply_ref = &multiply;
//^^^^^^^^^^^^ &|| -> i32
//^^^^^^^^^^^^ &|i32, i32| -> i32
let return_42 = || 42;
//^^^^^^^^^ || -> i32