diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs index 7bb88006f6..69b83f3b12 100644 --- a/crates/ide/src/hover/render.rs +++ b/crates/ide/src/hover/render.rs @@ -909,9 +909,9 @@ fn render_notable_trait( let mut needs_impl_header = true; for (trait_, assoc_types) in notable_traits { desc.push_str(if mem::take(&mut needs_impl_header) { - "Implements notable traits: " + "Implements notable traits: `" } else { - ", " + "`, `" }); format_to!(desc, "{}", trait_.name(db).display(db, edition)); if !assoc_types.is_empty() { @@ -931,7 +931,12 @@ fn render_notable_trait( desc.push('>'); } } - desc.is_empty().not().then_some(desc) + if desc.is_empty() { + None + } else { + desc.push('`'); + Some(desc) + } } fn type_info( @@ -958,37 +963,12 @@ fn type_info( res.markup = if let Some(adjusted_ty) = adjusted { walk_and_push_ty(db, &adjusted_ty, &mut push_new_def); - let notable = { - let mut desc = String::new(); - let mut needs_impl_header = true; - for (trait_, assoc_types) in notable_traits(db, &original) { - desc.push_str(if mem::take(&mut needs_impl_header) { - "Implements Notable Traits: " - } else { - ", " - }); - format_to!(desc, "{}", trait_.name(db).display(db, edition)); - if !assoc_types.is_empty() { - desc.push('<'); - format_to!( - desc, - "{}", - assoc_types.into_iter().format_with(", ", |(ty, name), f| { - f(&name.display(db, edition))?; - f(&" = ")?; - match ty { - Some(ty) => f(&ty.display(db, display_target)), - None => f(&"?"), - } - }) - ); - desc.push('>'); - } - } - if !desc.is_empty() { - desc.push('\n'); - } - desc + let notable = if let Some(notable) = + render_notable_trait(db, ¬able_traits(db, &original), edition, display_target) + { + format!("{notable}\n") + } else { + String::new() }; let original = original.display(db, display_target).to_string(); diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index e08a95659e..293efa0c02 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -8929,7 +8929,7 @@ fn main(notable$0: u32) {} --- - Implements notable traits: Notable\ + Implements notable traits: `Notable` --- @@ -9054,7 +9054,7 @@ fn main() { S ``` ___ - Implements notable traits: Future, Iterator, Notable"#]], + Implements notable traits: `Future`, `Iterator`, `Notable`"#]], ); }