mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
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:
commit
1a0988b899
@ -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>"],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user