Skip to content

transpile: Translate enums with newtype structs#1620

Open
Rua wants to merge 1 commit intoimmunant:masterfrom
Rua:enum-struct
Open

transpile: Translate enums with newtype structs#1620
Rua wants to merge 1 commit intoimmunant:masterfrom
Rua:enum-struct

Conversation

@Rua
Copy link
Contributor

@Rua Rua commented Feb 25, 2026

No description provided.

@Rua Rua changed the title Translate enums with newtype structs transpile: Translate enums with newtype structs Feb 25, 2026
@Rua Rua force-pushed the enum-struct branch 6 times, most recently from 1fd4b08 to 908acb1 Compare February 25, 2026 16:43
@Rua
Copy link
Contributor Author

Rua commented Feb 25, 2026

It seems that the transpiler is generating working code, but then the refactorer is breaking the imports. I don't know if that's simply a bug in the refactorer, or something else.

Edit: wondering if the refactorer is not handling impl blocks properly, to support associated constants?

Copy link
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

Btw, #1623 should help with the error messages here, which I saw were atrocious (#1621).

@Rua Rua force-pushed the enum-struct branch 2 times, most recently from 20ee393 to 54595eb Compare February 27, 2026 12:08
@Rua
Copy link
Contributor Author

Rua commented Feb 27, 2026

The errors from refactor don't seem to have gone away. This PR hasn't changed anything about refactor, so is that a bug in the refactorer?

Copy link
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

The errors from refactor don't seem to have gone away. This PR hasn't changed anything about refactor, so is that a bug in the refactorer?

Oh sorry, I meant #1623 should help make the error messages legible, but not fix them.

This is likely either a bug in the refactorer, or the refactorer is assuming something about what code the transpiler generates for enums and now can't handle a different translation of enums. If it's the latter, we should probably fix it here.

@Rua
Copy link
Contributor Author

Rua commented Feb 27, 2026

I've not looked at the refactorer code at all yet, so I wouldn't really know where to look for a possible cause. The CI error messages don't give much of a hint.

@kkysen
Copy link
Contributor

kkysen commented Feb 27, 2026

I've not looked at the refactorer code at all yet, so I wouldn't really know where to look for a possible cause. The CI error messages don't give much of a hint.

@ahomescu, do you have any idea maybe?

@Rua Rua marked this pull request as ready for review March 6, 2026 15:06
@ahomescu
Copy link
Contributor

ahomescu commented Mar 7, 2026

Could you share the refactorer errors you're getting?

@Rua
Copy link
Contributor Author

Rua commented Mar 7, 2026

The errors are happening in CI. I can't run the tests on NixOS myself.

@Rua Rua force-pushed the enum-struct branch 3 times, most recently from 1064aa6 to 797e7a0 Compare March 14, 2026 11:32
@Rua
Copy link
Contributor Author

Rua commented Mar 14, 2026

I've removed the second commit from the PR, the one that uses associated constants instead of global ones. That seems to be the one that the refactorer has trouble with.

EDIT: I guess not? Hmm.

@ahomescu
Copy link
Contributor

If you run the transpiler with --reorganize-definitions (we're renaming that btw, but I don't think it has landed), are you maybe missing the c2rust::src_loc attributes on the newtypes?

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.

3 participants