-
Notifications
You must be signed in to change notification settings - Fork 26
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
Update deps and derivation algorithm #3
Conversation
- 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.
This was made to bypass wrong type inference, such as `-10 as u64`.
Upstream PR to fix that: Manishearth/compiletest-rs#93. |
syn 0.12 and quote 0.4 were just released, which appear to be significant refactors. |
Manishearth/compiletest-rs#93 fixed build on nightly.
Will likely be able to parse even more new Rust syntax. This transition required some API-incompatible changes.
@cuviper thanks! I've adapted the code to use new I have a concern about using the "full" feature for |
Can you give me some numbers?
Unless it's extreme, then yes, I would lean in favor of functionality and accept the compilation time. |
The Ordinarily I would expect libraries that are not already using + const ALPHA: isize = (-3 - (-5isize)) - 10;
+ #[derive(ToPrimitive)]
enum Color {
Red,
Blue = 5,
Green,
- Alpha = (-3 - (-5isize)) - 10,
+ Alpha = ALPHA,
} |
Wouldn't that suggestion make I suppose |
Yeah you're right. An optional feature would work. |
In
Good idea. I'll implement it under "full-syntax" name which is short and descriptive enough to me. |
I couldn't find a way to use "full-syntax" only for `with_custom_values` :(.
Thanks, looks great! bors r+ |
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`.
Build succeeded |
|
||
[dev-dependencies.num] | ||
version = "0.1" | ||
|
||
[dev-dependencies.num-derive] | ||
path = "." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, actually, cargo package
doesn't allow any path
declarations like this.
Fixes #2.
An updated version of rust-num/num#353 which includes suggestions outlined here and here:
quote
andsyn
to parse new Rust syntax;compiletest_rs
to solve "every suggestion should have at least one span" Manishearth/compiletest-rs#86;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.#[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 liketrivial
.