rust-analyzer: [feat] Optional Inlay Hint for Too Many Implicit Returns in One Function
I have previewed the history of issues, and noticed that the optional inlay hint for the implicit returns would be useful when there are too many returns in one function.
For example, in crates\hir-def\src\body\lower\asm.rs, the lower_inline_asm function has too many returns for readers to distinguish the difference.
I also see the similar issues in the history, e.g. #9969, #4691.
I think adding inlay hint for the implicit return would be a useful option.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (9 by maintainers)
I think this is an interesting idea that would be useful when the statements are very large. However, its implementation needs further discussion. We could also use document-highlight to indicate where the current value is returned.
@Veykril @lnicola @ChayimFriedman2
I have designed a scheme to give a inlay hint to the reader, but it’s my first time to issue a new feature request. Thus, it needs more discussion. I use two code snippets in
crates\hir-def\src\body\lower\asm.rsas examples. Please review them and give me some suggestions.Example 1
Example 2
When a user hovers and clicks the line of the implicit return in the nesting match block, the lsp would give inlay hints of
⏎before the clicked line and other implicit return lines in the same match block as shown in the code snippet. The user can find the variable assigned to the return value near the first⏎tag and the match keyword.When user changes the cursor to the other line, the
⏎tag is no longer hinted in the editor.It is also helpful to add an comtemporary inlay hint of
▶to the variable receiving the implicit return variable, also disappearing when the user moves the cursor to the other line.