From 19094abd41fe398c2ba1a3c4926ef50c04eebabb Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 11 Jan 2020 01:51:08 +0800 Subject: Proper handling local in hover --- crates/ra_ide/src/hover.rs | 20 +++++++++++++++++++- 1 file changed, 19 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 35e39f965..5548681f1 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -128,7 +128,7 @@ fn hover_text_from_name_kind(db: &RootDatabase, name_kind: NameKind) -> Option from_def_source(db, it), hir::ModuleDef::BuiltinType(it) => Some(it.to_string()), }, - Local(_) => None, + Local(it) => Some(rust_code_markup(it.ty(db).display_truncated(db, None).to_string())), TypeParam(_) | SelfType(_) => { // FIXME: Hover for generic param None @@ -174,6 +174,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Optionfoo; }; } &["fn foo()"], ); } + + #[test] + fn test_hover_through_expr_in_macro() { + check_hover_result( + " + //- /lib.rs + macro_rules! id { + ($($tt:tt)*) => { $($tt)* } + } + fn foo(bar:u32) { + let a = id!(ba<|>r); + } + ", + &["u32"], + ); + } } -- cgit v1.2.3