From 0bf02f5ccac99c91f10ef46bb06ff2ea316c382c Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Tue, 5 May 2020 14:29:07 +0200 Subject: do not truncate display for hover #4311 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_ide/src/hover.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/hover.rs') diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 54d318858..df8451af2 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -208,7 +208,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option 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(-) (limited to 'crates/ra_ide/src/hover.rs') 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 From 1ec953f11744c708ba74c238737eac8e96a1c7b1 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Wed, 6 May 2020 11:33:43 +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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/hover.rs') diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index d52f22157..06d4f1c63 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -446,7 +446,7 @@ mod tests { } #[test] - fn hover_omits_default_generic_types() { + fn hover_default_generic_types() { check_hover_result( r#" //- /main.rs @@ -458,7 +458,7 @@ struct Test { fn main() { let zz<|> = Test { t: 23, k: 33 }; }"#, - &["Test"], + &["Test"], ); } -- cgit v1.2.3 From 001a86dc03104b75df732d69257d22526cf422b7 Mon Sep 17 00:00:00 2001 From: Hasan Ali Date: Fri, 15 May 2020 22:23:49 +0100 Subject: Fix completion and hover for module and function of same name --- crates/ra_ide/src/hover.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'crates/ra_ide/src/hover.rs') diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 06d4f1c63..befa977c7 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -921,4 +921,21 @@ fn func(foo: i32) { if true { <|>foo; }; } &["unsafe trait foo"], ); } + + #[test] + fn test_hover_mod_with_same_name_as_function() { + check_hover_result( + " + //- /lib.rs + use self::m<|>y::Bar; + + mod my { + pub struct Bar; + } + + fn my() {} + ", + &["mod my"], + ); + } } -- cgit v1.2.3