Skip to content
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

Math on enums generates invalid Rust #165

Open
waywardmonkeys opened this issue Sep 21, 2017 · 0 comments
Open

Math on enums generates invalid Rust #165

waywardmonkeys opened this issue Sep 21, 2017 · 0 comments

Comments

@waywardmonkeys
Copy link
Contributor

This Rust gets generated:

            (*(*state).result).segment = (SegmentRegister::SEG_ES as (i32) +
                                              (prefix as (i32) - 0x60i32)) as
                (SegmentRegister);

And unfortunately, that's not valid:

error[E0605]: non-primitive cast: `i32` as `asmx86::SegmentRegister`
     --> src/asmx86.rs:10645:42
      |
10645 |               (*(*state).result).segment = (SegmentRegister::SEG_ES as (i32) +
      |  __________________________________________^
10646 | |                                               (prefix as (i32) - 0x60i32)) as
10647 | |                 (SegmentRegister);
      | |_________________________________^
      |
      = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait

Fixing this would require having some code generated that allows converting an integer back to the enum value.

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

No branches or pull requests

1 participant