Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

num-derive doesn't know how to handle newtypes with named fields yet. #59

Open
zRegle opened this issue Feb 4, 2024 · 3 comments
Open

Comments

@zRegle
Copy link

zRegle commented Feb 4, 2024

I'm using bindgen to create a enum, here is the generated code.

#[repr(u32)]
#[non_exhaustive]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, FromPrimitive)]
pub enum Code {
    kSuccess = 0,
    kFailed = 1,
    kHasMore = 2,
    ... // more types
}

And I got this compile error:

#[derive(Debug, Copy, Clone, FromPrimitive)
                             ^^^^^^^^^^^^^
help: message: num-derive doesn't know how to handle newtypes with named fields yet. Please use a tuple-style nentype, or submit a PR!

num-derive version: 0.3.3

Can anyone give me some advice? Thx in advance!

@cuviper
Copy link
Member

cuviper commented Feb 5, 2024

I can't reproduce the problem with that snippet alone. Are the "more types" still data-less variants?

@zRegle
Copy link
Author

zRegle commented Feb 5, 2024

I can't reproduce the problem with that snippet alone. Are the "more types" still data-less variants?

Yes, the rest of the enum definition are all simple variants. BTW, it this problem could be releated to my GLIBCXX version? I can reproduce this problem on machine with GLIBCXX_3.4.28

@cuviper
Copy link
Member

cuviper commented Feb 5, 2024

Are your types related to GLIBCXX? Otherwise I see no reason why GLIBCXX would affect this.

I noticed that your example code has a different derive line than the one in your error message. Are you sure that you've correctly identified which type is raising this error?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants