-
Notifications
You must be signed in to change notification settings - Fork 1
Remove extra "ipnet" and "mac" features. Use implicit optional dependency feature instead #9
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
Conversation
The tests ( EDIT: This PR does actually break the tests. It's just that tests need to run with |
If I add the features:
... Then it magically works. I don't know what's going on here. Is there some magic going on in |
The magical documentation of features also broke with my first solution. This crates uses a lot of automagic I have not encountered before :D Well, now I think everything should work again! |
02c598d
to
6ed3826
Compare
Oh wow, thanks for putting in a bunch of legwork here! Re: magic - yes theres a lot of automagic involved, which I'm happy to start stripping out if it gets in the way of making the core functionality better. For context: this project started out as a way to scratch an exercise in learning about macros by scratching an itch. At some point I realized someone else might find it useful and decided to clean up docs and publish the crate - but I wanted to have better docs and figured a test suite wouldn't hurt either, those magic crates came out of google-oriented-programming rather than a better "understand the things" approach 🫤 . document-fatures crate: This is mostly just fluff and if it is getting in the way of using implicit dependencies rather than having to manually declare each, it can go away just fine. trybuild: this one is a bit harder to drop as there needs to be something that can verify the results of good and bad macro invocation. Since all that happens during a compilation of other code it's a bit tricky and trybuild has all the machinery for that already. feature declaration: The features were not deeply thought out, just the idea "some people may not want to have macaddr or ipnetwork pulled in and built since they aren't using them in their project", combined with the notion that there may be other cases of wanting to turn a string into a type with compile time error checking amplifying the first thought (e.g. parsing a url into the Url type, or alternate IP handling libraries, and so on). If implicit dependencies can be used to accomplish this and it makes everything simpler in the long run, I'm on board :). Next steps here:
@faern If you have any thoughts on the above and suggestions for approaches that simplify future work while keeping user's lives simple as well, I'm all ears. |
c3f3492
to
3a655a4
Compare
I have now rebased this on latest main, added this change to the newly merged changelog, and fixed the commit message style! |
3a655a4
to
5c1fce5
Compare
This is awesome! Thanks for contributing to the ecosystem ❤️
Of course. There is nothing wrong with having some more advanced custom test runner. I just don't understand why it won't work with optional dependency features 🤷
I 100% support this! I love when features are used to strip down the size of both the code in a library as well as the dependencies it pulls in! |
BREAKING CHANGE: This is breaking since features are being renamed
5c1fce5
to
27ffb5c
Compare
Rebased again and updated to work with the fix in #13. |
Looking into the implicit features thing some more, it seems like rust is moving towards getting rid of those anyway, in favor of explicit features defined like done here ( See: rust-lang/rfcs#3491 and the associated tracking issue: rust-lang/cargo#12826 . I wonder if the trybuild folks were aware of this and decided to just no worry about implicit feature compat as a result (thus causing your difficulties above). |
I had no idea! TIL! But apparent it did not make it into Rust 2024 edition. So at least three years until this becomes a real thing. But since |
I see no benefit in naming the features anything other than the name of the crate they enable support for. It's the most direct and clear to users IMHO. Since a user must directly depend on |
My comment was just about why the implicit feature seems to have some odd behaviors over the explicitly defined ones. I completely agree that they should be named after the crate they enable.
I agree :) |
LGTM, merged |
This involves a couple of things: * support for IpRange types and IpSubnets types. These are not simple fromstr implementations so the make_macro! approach didn't work. Instead a heck of a lot of proc-macro code was needed to parse and validate the args lists. * A separate set of tests for nightly vs stable builds in some cases. Reasons for this: 1) compiler output is slightly different between nightly and stable. 2) there is warning support in nightly and this emits warnings when the generated iterators might behave different than expected. Fixes: #9
This involves a couple of things: * support for IpRange types and IpSubnets types. These are not simple fromstr implementations so the make_macro! approach didn't work. Instead a heck of a lot of proc-macro code was needed to parse and validate the args lists. * A separate set of tests for nightly vs stable builds in some cases. Reasons for this: 1) compiler output is slightly different between nightly and stable. 2) there is warning support in nightly and this emits warnings when the generated iterators might behave different than expected. Fixes: #9
Fixes the first thing that blocks #6.
I suggest adopting a changelog with the keepachangelog format, to record changes in. Will be easier for users to discover what they need to do when making subtle breaking changes like these.