New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal: Adjust a few things for trait assoc item hovers #16756
Conversation
if let Some(limit) = f.entity_limit { | ||
let assoc_items = self.items(f.db); | ||
let count = assoc_items.len().min(limit); | ||
if count == 0 { | ||
if assoc_items.is_empty() { | ||
f.write_str(" {}")?; | ||
} else { | ||
f.write_str(" { /* … */ }")?; | ||
} | ||
} else { | ||
f.write_str(" {\n")?; | ||
for item in &assoc_items[..count] { | ||
f.write_str(" ")?; | ||
match item { | ||
AssocItem::Function(func) => func.hir_fmt(f), | ||
AssocItem::Const(cst) => cst.hir_fmt(f), | ||
AssocItem::TypeAlias(type_alias) => type_alias.hir_fmt(f), | ||
}?; | ||
f.write_str(";\n")?; | ||
} | ||
|
||
if assoc_items.len() > count { | ||
f.write_str(" /* … */\n")?; | ||
} | ||
f.write_str("}")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Young-Flash sorry for changing stuff myself here (but I figured this wasn't worth going through additional review rounds given how long the PR has been up). I hope that's okays with you.
Made some small stylistic changes (;
instead of ,
for seperators, given items), and more importantly if no limit is set we don't show any items or braces at all. As before this we'd still see {\n ...\n}
for every trait hover which is rather noisy. If someone wants that they can set the limit to 0
instead of null
.
@bors r+ |
☀️ Test successful - checks-actions |
#15938 (minor turned major wrt diff because of test changes)