Skip to content

transpile: Translate EnumConstant with associated constants - #1659

Open
Rua wants to merge 3 commits into
immunant:masterfrom
Rua:enum-associated-constant
Open

transpile: Translate EnumConstant with associated constants#1659
Rua wants to merge 3 commits into
immunant:masterfrom
Rua:enum-associated-constant

Conversation

@Rua

@Rua Rua commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

@Rua Rua mentioned this pull request Mar 14, 2026
@Rua
Rua marked this pull request as draft April 16, 2026 10:16
@Rua
Rua force-pushed the enum-associated-constant branch 28 times, most recently from d2aced7 to 17365e3 Compare April 20, 2026 19:59
@Rua
Rua force-pushed the enum-associated-constant branch 4 times, most recently from cb01918 to 43e8bfe Compare April 20, 2026 21:26
kkysen added a commit that referenced this pull request Apr 24, 2026
…1746)

- Fixes #1660

This was quite tricky to implement, but it's now working and #1659
passes its tests with these additions. Only `const` associated items are
supported. `type` items could be added later, but `fn` is probably never
going to work because they are too complex to test for equivalence.
@Rua
Rua force-pushed the enum-associated-constant branch 4 times, most recently from 1168841 to d6b6fea Compare May 1, 2026 18:46
@Rua
Rua force-pushed the enum-associated-constant branch 2 times, most recently from 28f1743 to 804eecf Compare May 3, 2026 17:18
@Rua
Rua force-pushed the enum-associated-constant branch from 804eecf to ef79d45 Compare May 5, 2026 19:22
@Rua
Rua force-pushed the enum-associated-constant branch 3 times, most recently from 4b2c73d to 7688d77 Compare August 4, 2026 20:48
@Rua
Rua marked this pull request as ready for review August 4, 2026 21:31
@Rua
Rua force-pushed the enum-associated-constant branch from 7688d77 to 9d477e1 Compare August 4, 2026 22:29
@Rua
Rua force-pushed the enum-associated-constant branch from 9d477e1 to 93fe084 Compare August 6, 2026 07:59
})
.collect();

let impl_block = mk().impl_item(mk().ident_ty(enum_name), constants);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this get a span?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've given it the same span as the newtype struct. I don't know if that's correct, I'm not sure what the purpose of the spans is.

@Rua
Rua force-pushed the enum-associated-constant branch from 93fe084 to 937303a Compare August 7, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translate enums as newtype structs with associated constants?

2 participants