internal: Adjust a few things for trait assoc item hovers#16756
Merged
bors merged 1 commit intorust-lang:masterfrom Mar 5, 2024
Merged
internal: Adjust a few things for trait assoc item hovers#16756bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Veykril
commented
Mar 5, 2024
Comment on lines
+599
to
+623
| 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("}")?; |
Member
Author
There was a problem hiding this comment.
@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.
Member
Author
|
@bors r+ |
Contributor
Contributor
Contributor
|
☀️ Test successful - checks-actions |
This was referenced May 9, 2024
This was referenced May 28, 2024
This was referenced Jun 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#15938 (minor turned major wrt diff because of test changes)