mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Infallible definition hovers
This commit is contained in:
parent
2223b4fa71
commit
a822291a02
5 changed files with 135 additions and 38 deletions
|
@ -264,7 +264,7 @@ pub(super) fn keyword(
|
|||
let markup = process_markup(
|
||||
sema.db,
|
||||
Definition::Module(doc_owner),
|
||||
&markup(Some(docs.into()), description, None)?,
|
||||
&markup(Some(docs.into()), description, None),
|
||||
config,
|
||||
);
|
||||
Some(HoverResult { markup, actions })
|
||||
|
@ -396,11 +396,11 @@ pub(super) fn definition(
|
|||
famous_defs: Option<&FamousDefs<'_, '_>>,
|
||||
notable_traits: &[(Trait, Vec<(Option<Type>, Name)>)],
|
||||
config: &HoverConfig,
|
||||
) -> Option<Markup> {
|
||||
) -> Markup {
|
||||
let mod_path = definition_mod_path(db, &def);
|
||||
let label = def.label(db)?;
|
||||
let label = def.label(db);
|
||||
let docs = def.docs(db, famous_defs);
|
||||
let value = match def {
|
||||
let value = (|| match def {
|
||||
Definition::Variant(it) => {
|
||||
if !it.parent_enum(db).is_data_carrying(db) {
|
||||
match it.eval(db) {
|
||||
|
@ -436,7 +436,7 @@ pub(super) fn definition(
|
|||
Some(body.to_string())
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
})();
|
||||
|
||||
let layout_info = match def {
|
||||
Definition::Field(it) => render_memory_layout(
|
||||
|
@ -683,7 +683,7 @@ fn definition_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> {
|
|||
def.module(db).map(|module| path(db, module, definition_owner_name(db, def)))
|
||||
}
|
||||
|
||||
fn markup(docs: Option<String>, desc: String, mod_path: Option<String>) -> Option<Markup> {
|
||||
fn markup(docs: Option<String>, desc: String, mod_path: Option<String>) -> Markup {
|
||||
let mut buf = String::new();
|
||||
|
||||
if let Some(mod_path) = mod_path {
|
||||
|
@ -696,7 +696,7 @@ fn markup(docs: Option<String>, desc: String, mod_path: Option<String>) -> Optio
|
|||
if let Some(doc) = docs {
|
||||
format_to!(buf, "\n___\n\n{}", doc);
|
||||
}
|
||||
Some(buf.into())
|
||||
buf.into()
|
||||
}
|
||||
|
||||
fn find_std_module(famous_defs: &FamousDefs<'_, '_>, name: &str) -> Option<hir::Module> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue