-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Better Type Hints for Enum Structs/Tuples #2947
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
Comments
bors bot
added a commit
that referenced
this issue
Feb 17, 2020
3169: Show record field names in Enum completion r=flodiebold a=adamrk Adresses #2947. Previously the details shown when autocompleting an Enum variant would look like the variant was a tuple even if it was a record:  This change will show the names of the fields for a record and use curly braces instead of parentheses:  This required exposing the type `adt::StructKind` from `ra_hir` and adding a function ``` kind(self, db: &impl HirDatabase) -> StructKind ``` in the `impl` of `EnumVariant`. There was also a previously existing function `is_unit(self, db: &impl HirDatabase) -> bool` for `EnumVariant` which I removed because it seemed redundant after adding `kind`. Co-authored-by: adamrk <[email protected]>
closed by #3169 |
lnicola
pushed a commit
to lnicola/rust-analyzer
that referenced
this issue
Apr 7, 2024
Try to fix cronjob PR creation The main tests use `bash` several times, maybe that is the issue here, too?
RalfJung
pushed a commit
to RalfJung/rust-analyzer
that referenced
this issue
Apr 27, 2024
Try to fix cronjob PR creation The main tests use `bash` several times, maybe that is the issue here, too?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
This is relatively small, but it might not be something the RA can do yet.
If I have an enum like this:
Rust-analyzer can be a little strange with autocompletion here for the non-tuple variant (
AdvanceAnIssue
).Here is what autocompletion/help looks like for

PlayStaffCard
:That's very clear. I know that i should, after hitting tab, type a
(
and then a String, like in the type inlay.Here's the struct variant on the other hand:

It shows something similar, representing its data as a tuple! That's fine from a memory standpoint, but it means:
I'm not sure what a better enum variant hint here would look like, but i suspect merely changing the type hint to just
{String, String}
as opposed to(String, String)
would be good enough. Perhaps a real:popping up would be the best long term solution, along with perhaps an assist in making all the fields if desired, but just the small change would be good enough I think.
Thank you!
The text was updated successfully, but these errors were encountered: