From 550c62949829c16861aefd6c1aea240709343ac8 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Wed, 6 May 2020 11:08:50 +0200 Subject: do not truncate display for hover Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_ide/src/hover.rs | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index df8451af2..d52f22157 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -143,7 +143,7 @@ fn hover_text_from_name_kind(db: &RootDatabase, def: Definition) -> Option 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 @@ -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: A, + b: B, + c: C, + } + + struct FakeIter { + inner: I, + } + + struct OtherStruct { + i: T, + } + + enum FakeOption { + Some(T), + None, + } + + fn scan(a: A, b: B, c: C) -> FakeIter, 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 { + FakeOption::Some(*memo + value) + }; + let number = 5u32; + let mut iter<|> = scan(OtherStruct { i: num }, closure, number); + } + "#, + &["FakeIter>, |&mut u32, &u32, &mut u32| -> FakeOption, u32>>"], + ); + } + #[test] fn hover_shows_fn_signature() { // Single file with result -- cgit v1.2.3