Stream: rustdoc

Topic: Representation of union


view this post on Zulip HeroicKatora (Jan 23 2021 at 23:04):

It's a bit surprising that union is the one ItemKind that shares its ItemEnum with another, with struct. Even more since unions do not permit all the StructType variants.

view this post on Zulip HeroicKatora (Jan 23 2021 at 23:04):

Is that due to implementation details, struct and union share a lot of code in the compiler? Not sure if I'm remembering this correctly.

view this post on Zulip Joshua Nelson (Jan 23 2021 at 23:14):

@HeroicKatora I think @CraftSpider is planning to fix that

view this post on Zulip Joshua Nelson (Jan 23 2021 at 23:14):

And remove the StructType fields

view this post on Zulip CraftSpider (Jan 24 2021 at 00:17):

As of the merge removing doctree::StructType, unions display as 'kind: struct, struct_type: union' (Before, there was no differentiation at all). Now that StructType has been removed, it would be nice to fix that, and I'll probably make a PR to do so soon. I just didn't want to mess with it in the same PR

view this post on Zulip CraftSpider (Jan 24 2021 at 00:18):

New style would be 'kind: union' with no struct_type, so unions are actually a proper type of their own

view this post on Zulip CraftSpider (Jan 24 2021 at 00:30):

Actually, sorry, it is tagged as kind: union already I think. I was confused by it sharing a type, but the ItemKind is different it looks like. So splitting it only removes the redundant struct_type field

view this post on Zulip HeroicKatora (Jan 24 2021 at 00:31):

It is already? Okay, I should probably update my nightly then.

view this post on Zulip CraftSpider (Jan 24 2021 at 00:34):

To clarify: Before any of my changes, unions should be kind: union, if they are appearing as kind: struct currently that's a bug as ItemKind already has a Union type. The only difference from my change would be the value of struct_type.


Last updated: Oct 11 2021 at 22:34 UTC