mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Impl HirDisplay for function hover message
This commit is contained in:
parent
2bb8956a10
commit
ef416e0154
5 changed files with 462 additions and 15 deletions
|
@ -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<D>(db: &RootDatabase, def: D, mod_path: Option<String>) -> Option<Markup>
|
||||
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<A, D>(db: &RootDatabase, def: D, mod_path: Option<String>) -> Option<Markup>
|
||||
where
|
||||
D: HasSource<Ast = A> + HasAttrs + Copy,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue