Conversation
Newer versions support new syntax, such as pub(restricted).
|
cuviper
left a comment
There was a problem hiding this comment.
Looks like those errors are just because #(variants,)* should now be #(#variants,)*.
| } | ||
| if let Some(val) = variant.discriminant { | ||
| idx = val.value; | ||
| if let Some(Lit(Int(value, _))) = variant.discriminant { |
There was a problem hiding this comment.
Can we support the full ConstExpr, instead of picking it apart? This will fail on even simple values like -100 which will map to something like Unary(Neg, Lit(Int(100))). Nevermind more complicated expressions. (It seems the old syn just failed to parse it at all.)
I'm thinking instead of idx, we store the actual expr and an offset 0, which we encode as quote!(... #expr + #offset ...). If the next variant has a discriminant, update expr and set offset back to 0, otherwise reuse the former expr with an incremented offset.
|
Please do move this to the new repo and issue, rust-num/num-derive#2 |
3: Update deps and derivation algorithm r=cuviper a=hcpl Fixes #2. An updated version of rust-num/num#353 which includes suggestions outlined [here](rust-num/num#353 (review)) and [here](https://github.com/rust-num/num/pull/353/files/76b5b2189f2b45e864e14c38c7856be578125931#r157100221): - Update `quote` and `syn` to parse new Rust syntax; - Update `compiletest_rs` to solve Manishearth/compiletest-rs#86; - Add support for arbitrary constant expressions as enum discriminants; - Remove the need to `extern crate num` just for deriving. Some notes: - `#[derive(FromPrimitive)]` now uses if-else to do its job because non-literal expressions are not allowed for pattern matching. - I added tests for self-containment of `#[derive]` alongside the code testing derivation functionality to keep the tests small. Would it be better to separate concerns? - `with_custom_value` should have all three tests like `trivial`.
Fixes #352.
Newer versions support new syntax, such as pub(restricted).