Switch public interface to always use proc-macro2#93
Conversation
2bac2c6 to
f7540c0
Compare
|
The code coverage fails even after upgrading, I can try to re-write the whole action but I think this is mostly out of scope for this PR :) |
|
We specifically do not want to have
The only reason we have proc-macro2 is so we can test the builder structs to generate the expected output. Developers should use virtue as a standalone crate, and this should not pull in |
|
I started with ripping out proc-macro2 and writing a custom shim in the feat/remove-proc-macro2 branch. Going to close this in favor of that solution |
|
@VictorKoenders are you thinking about exposing this shim to downstream crates? |
|
No, as the shim will only be enabled in If there's a desire for this you can always grab the code and put it in your own project. I recommend not exposing it as a library, because then you get the same shimming problems as you've had before |
|
@VictorKoenders I have a derive crate using virtue, and I have tests for that crate, currently using Does bincode-derive not have input-output tests using TokenStream? |
|
Bincode does behavioral testing, we test if the generated interfaces behave as expected. One way I can think of to do this is have a Maybe let parse = Parse::new(input)?;Can default to |
The only thing is that the features here should be additive, we can gate a separate Personally I don't mind if it's |
This aligns more with how
quoteworks:Also: https://github.com/dtolnay/quote/blob/62fd385a800f7398ab416c00100664479261a86e/Cargo.toml#L15-L26
In practice, I got to it because I encountered the following problem:
I have a workspace similiar to bincode/serde, where I have a workspace with crate
Aand aderivecrate,the
deriveusesvirtueand contains a bunch of test vectors that are done by usingproc_macro2in the proc-macro unit tests.crate
Aalso depends onbincode(in tests/benchmarks) and uses its derive proc-macro.This means that when I run
cargo t --all, then the tests of crateAwill usebincode-derive->virtuewith theproc-macro2feature enabled (as they are needed in thederivecrate dev-depdencies).This causes
bincode-deriveto fail with this error:The intrinsic problem here is that the current
proc-macro2feature is not strictly additive,I also thought about removing
TokenStreamfrom the prelude of this crate, but decided to leave it asproc_macro2::TokenStreambut I'm more than willing to just remove it and force users to explicitly import from the "right" place