From ef416e0154767619fcbfa0d1682b28bd338a8ce9 Mon Sep 17 00:00:00 2001 From: oxalica Date: Sun, 14 Mar 2021 20:03:39 +0800 Subject: Impl HirDisplay for function hover message --- crates/ide/src/hover.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/ide/src/hover.rs') diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index f872b68cf..1e4c247c0 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -354,7 +354,7 @@ fn hover_for_definition( }, mod_path, ), - ModuleDef::Function(it) => from_def_source(db, it, mod_path), + ModuleDef::Function(it) => from_hir_fmt(db, it, mod_path), ModuleDef::Adt(Adt::Struct(it)) => from_def_source(db, it, mod_path), ModuleDef::Adt(Adt::Union(it)) => from_def_source(db, it, mod_path), ModuleDef::Adt(Adt::Enum(it)) => from_def_source(db, it, mod_path), @@ -383,6 +383,14 @@ fn hover_for_definition( }, }; + fn from_hir_fmt(db: &RootDatabase, def: D, mod_path: Option) -> Option + where + D: HasAttrs + HirDisplay, + { + let label = def.display(db).to_string(); + from_def_source_labeled(db, def, Some(label), mod_path) + } + fn from_def_source(db: &RootDatabase, def: D, mod_path: Option) -> Option where D: HasSource + HasAttrs + Copy, -- cgit v1.2.3