Skip to content
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

Display scope inlay hints after closing brace for more types of blocks #18833

Open
AeonSolstice opened this issue Jan 4, 2025 · 8 comments
Open
Labels
A-inlay-hints inlay/inline hints C-feature Category: feature request good first issue

Comments

@AeonSolstice
Copy link

Currently fn and mod are supported, but it would be nice if things like loop, while (+let), if (+let), let+else, match + block arms, etc were also supported.
Image

On a side note, async fn's should show async fn

@AeonSolstice AeonSolstice added the C-feature Category: feature request label Jan 4, 2025
@lnicola lnicola added the A-inlay-hints inlay/inline hints label Jan 4, 2025
@crsche
Copy link

crsche commented Jan 7, 2025

Hey, could I take a crack at implementing this?

@Veykril
Copy link
Member

Veykril commented Jan 7, 2025

Go ahead!

@crsche
Copy link

crsche commented Jan 7, 2025

How should conditionals be handled? Should the hint be inlaid after each branch or just after the end?

After each:
Image

@ChayimFriedman2
Copy link
Contributor

@crsche The recommended rustfmt style is to put the else on the same line, so it doesn't matter usually.

@Veykril
Copy link
Member

Veykril commented Jan 8, 2025

I think we should probably omit them if something follows the closing brace? Also I just realized how confusing these look as one could interpret them as being implicit code in this position (which they aren't, unlike most of our other hints). I never noticed this as I am no longer using them myself. We might want to have some special disambiguator at the front to mark that?

@crsche
Copy link

crsche commented Jan 8, 2025

That seems like the best approach, maybe something like a pipe character to explicitly separate?

@crsche
Copy link

crsche commented Jan 8, 2025

Also, for conditionals, where should hints jump?

//v   v         v, etc?
if let Some(x) = Some(1) {
    ..
}

@Veykril
Copy link
Member

Veykril commented Jan 9, 2025

Either to the if or the start of the condition, depends on where the other jump to. If they all jump to the start of the block like thing we should oth esame here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inlay-hints inlay/inline hints C-feature Category: feature request good first issue
Projects
None yet
Development

No branches or pull requests

5 participants