-
Notifications
You must be signed in to change notification settings - Fork 34
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
Cannot use constants as enum values #94
Comments
Confirmed, we're facing the same issue in Theseus OS. Previously we were on 0.5.7, and some of our CI passes randomly started failing within the last 2 hours due to num_enum I think 0.5.8 likely needs to be yanked because it somehow broke semver compatibility guarantees. |
This is likely the culprit: num_enum/num_enum_derive/src/lib.rs Line 41 in 4cd978d
|
rdkafka also appears to be affected:
We have CI builds failing just now with num_enum 0.5.8 that previously passed with 0.5.7. Edit: manually pinning the version appears to be a workaround.
|
Yes, looks like this was the change that did it! I also started with a cryptic error in rdkafka which hasn't seen any changes for quite some time and eventually noticed the derive trait their error enum uses which led me to here. Love the macro name there 😂 |
I've yanked 0.5.8 - thanks for the reports, and sorry for the breakage! |
While preserving favouring literal values where possible. Fixes #94 The story here is: #89 tried to simplify the generated code (which, among other things, made rustc not stack overflow when codegening for large enums). Unfortunately, it assumed that all explicit discriminants were literals (and non-negative ones, as `-123` parses as a `UnaryExpr` not a `Literal`). And further unfortunately, because of a typo in a `#[cfg(feature)]` attached to the only tests we had for non-literal enums, we weren't running those tests (this PR re-enables them and adds some which aren't feature gated, and #95 will ensure we don't regress in this way again). This PR attempts to preserve the "prefer just using literals rather than large chains of wrapping adds" property of #89, while also supporting non-literal cases.
Since the update from 0.5.7 to 0.5.8 using a constants as the value of an enum variant does not work anymore:
Produces the following error:
The text was updated successfully, but these errors were encountered: