-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow recursive untagged unions #1804
Comments
What is the use case? As you mentioned in your comment, it looks like it would only provide a different (and more verbose) name to the same data. |
My use case is generic unions generated by a macro, of the form: union Foo<A, B> {
a: A,
b: B,
}
|
related: #1151 (recursive enums) |
@spinda It seems like the generic types there should eliminate the circularity. A Foo can't unconditionally contain a Foo, but it can contain a T and a user can map that T to a different Foo type; that doesn't create a loop. I wonder what makes the compiler think it does? Can you post a concrete code example with a macro invocation that produces the error? |
@joshtriplett Hrm... In the months since I submitted this, I changed my approach to the project that needed it, and now I can't recall a specific example. I'd be okay with closing this. |
@spinda I'm trying to get around this right now, how did you change your approach? |
Triaging this issue: @spinda Are you interested in this still? |
@Centril I'm late here, but no, not really. Moved on to other things. |
Alright. Closing this then. |
The current implementation of RFC #1444 disallows the following:
Unlike structs, since all fields of a union exist in the same space, a union whose definition involves infinite recursion can be represented in finite space. In this case,
Foo
can be represented asunion { f0: u8 }
, with&foo.f1
equivalent to&foo
.The text was updated successfully, but these errors were encountered: