4316: do not truncate display for hover r=matklad a=bnjjj

close #4311 

4351: Fix Windows server path r=matklad a=lnicola

CC @Coder-256.

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
This commit is contained in:
bors[bot] 2020-05-06 16:54:31 +00:00 committed by GitHub
commit 1a0988b899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 5 deletions

View File

@ -143,7 +143,7 @@ fn hover_text_from_name_kind(db: &RootDatabase, def: Definition) -> Option<Strin
ModuleDef::TypeAlias(it) => from_def_source(db, it, mod_path),
ModuleDef::BuiltinType(it) => Some(it.to_string()),
},
Definition::Local(it) => Some(rust_code_markup(&it.ty(db).display_truncated(db, None))),
Definition::Local(it) => Some(rust_code_markup(&it.ty(db).display(db))),
Definition::TypeParam(_) | Definition::SelfType(_) => {
// FIXME: Hover for generic param
None
@ -208,7 +208,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
}
}?;
res.extend(Some(rust_code_markup(&ty.display_truncated(db, None))));
res.extend(Some(rust_code_markup(&ty.display(db))));
let range = sema.original_range(&node).range;
Some(RangeInfo::new(range, res))
}
@ -279,6 +279,47 @@ mod tests {
assert_eq!(trim_markup_opt(hover.info.first()), Some("u32"));
}
#[test]
fn hover_shows_long_type_of_an_expression() {
check_hover_result(
r#"
//- /main.rs
struct Scan<A, B, C> {
a: A,
b: B,
c: C,
}
struct FakeIter<I> {
inner: I,
}
struct OtherStruct<T> {
i: T,
}
enum FakeOption<T> {
Some(T),
None,
}
fn scan<A, B, C>(a: A, b: B, c: C) -> FakeIter<Scan<OtherStruct<A>, B, C>> {
FakeIter { inner: Scan { a, b, c } }
}
fn main() {
let num: i32 = 55;
let closure = |memo: &mut u32, value: &u32, _another: &mut u32| -> FakeOption<u32> {
FakeOption::Some(*memo + value)
};
let number = 5u32;
let mut iter<|> = scan(OtherStruct { i: num }, closure, number);
}
"#,
&["FakeIter<Scan<OtherStruct<OtherStruct<i32>>, |&mut u32, &u32, &mut u32| -> FakeOption<u32>, u32>>"],
);
}
#[test]
fn hover_shows_fn_signature() {
// Single file with result
@ -405,7 +446,7 @@ mod tests {
}
#[test]
fn hover_omits_default_generic_types() {
fn hover_default_generic_types() {
check_hover_result(
r#"
//- /main.rs
@ -417,7 +458,7 @@ struct Test<K, T = u8> {
fn main() {
let zz<|> = Test { t: 23, k: 33 };
}"#,
&["Test<i32>"],
&["Test<i32, u8>"],
);
}

View File

@ -61,7 +61,7 @@ The server binary is stored in:
* Linux: `~/.config/Code/User/globalStorage/matklad.rust-analyzer`
* macOS: `~/Library/Application Support/Code/User/globalStorage/matklad.rust-analyzer`
* Windows: `%APPDATA%\Code\User\globalStorage`
* Windows: `%APPDATA%\Code\User\globalStorage\matklad.rust-analyzer`
Note that we only support the latest version of VS Code.