-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Empty struct with braces tracking issue (RFC 218) #24266
Comments
@nrc I would like to work on this |
@Dineshs91 It looks like you should remove those two checks, yes. I'm not sure that that will be enough, it might be. You will need to add a test or two to check it works and make sure all the existing tests pass (you'll probably find that some tests which checked for those conditions no longer pass and need to be removed). |
@Dineshs91 No, its not enough just to remove the two checks, at least not to satisfy all the requirements of the RFC Such as small change might have been enough to satisfy very early drafts of the RFC, but the actual RFC text that ended up being accepted has an important extra condition: structs defined via This means that to implement this correctly, the compiler needs to track which kind of definition was used to define the struct initially -- it ends up being part of the type of the struct itself. (Also, it may be good to attempt to put this change in behind a feature-gate while we get the initial wrinkles worked out. That's another reason that removing checks does not suffice.) (I have updated the issue description to include the summary text and a link to the RFC, so hopefully this point will not be overlooked in the future.) |
@pnkfelix Thanks for the clarification. So there are two things that should be taken care of
I've checked the above, after removing the 2 conditions that i have mentioned in my previous comment. A quick question Say i construct an empty struct using Please correct me if i am wrong, I don't have much knowledge about the internals. |
@Dineshs91 yes, if the struct is defined without braces then it can be pattern matched either with or without braces. How the struct is constructed doesn't make any difference. The underlying reason for the difference is that Rust has two namespaces when we lookup the name of something - types and values (values includes functions). When you use |
@Dineshs91 hey, how did you get along the namespacing? Can I help you out? |
@nrc I haven't started digging into namespace thing yet. I will try to work it out this weekend. |
So, it looks like PR #28336 successfully implements this without adding any additional feature gates. @rust-lang/lang Does this feature need a feature gate? Or shall we just land PR #28336 (preferably right after the upcoming beta is cut)? |
Tracking issue for rust-lang/rfcs#218.
cc @pnkfelix.
RFC text
The text was updated successfully, but these errors were encountered: