-
Notifications
You must be signed in to change notification settings - Fork 89
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
refactoring: re-export custom derive with additional items (WIP) #94
Conversation
this allows to add other item definitions as described in https://users.rust-lang.org/t/10546/2
move `no_std` testcase into a separate crate inside `testsuite`. This way we have better control, e.g. - panic="abort" compiler flag - only run on nightly - compile `derive_builder` with no_std feature
somehow `cd testsuite && cargo test --all` pulled in tests from `no_std`, despite the fact that it was (a) not in the workspace and (b) only an optional dependency. Now we disable the test via a feature flag `nightlytests`.
I'd request we merge #92 before embarking on this, or else I'll have a hell of a time merging that later. I can look at this next week and see if I can figure out what's causing problems. |
Done. I also updated this branch. :-) It was surprisingly simple - git was able to figure everything out - except of the location of a new file. git checkout reexport_macro_with_items
git merge master
git mv derive_builder/tests/bounds_generation.rs testsuite/tests/
git commit --amend |
I think I've got most of it figured out now; |
@TedDriggs Ok, cool. I merged your changes into from your fork into this branch.
Note: You should also be able to push directly to the branch in this repository. If your local branch is also called git remote add upstream git@github.com:colin-kiegel/rust-derive-builder.git
git push --set-upstream upstream reexport_macro_with_items |
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.
I left some inline comments
pub use ::core::default::Default; | ||
pub use ::core::marker::PhantomData; | ||
pub use ::core::option::Option::{self, Some, None}; | ||
pub use ::core::result::Result::{self, Ok, Err}; |
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.
I wonder if this can lead to problems if crate A exports FooBuilder
and crate B wants to use that builder. Without depending on derive_builder
, all those re-exports would not be in scope of crate B.
We should double check if that is a problem.
(Serde seems to do somethings similar https://github.com/serde-rs/serde/blob/6fbf40b83c65ba2bfe9e94276482b13dd979ac63/serde/src/export.rs)
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.
It doesn't seem to; it looks like the system is smart enough to know that these are actually the same ones as in ::std
, or in ::core
// Attribute { style: Outer, value: NameValue(Ident("doc"), Str("/// This is a doc comment for a field", Cooked)), is_sugared_doc: true } | ||
// example: | ||
// Attribute { style: Outer, value: NameValue(Ident("doc"), Str("/// This is a | ||
// doc comment for a field", Cooked)), is_sugared_doc: true } |
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.
the indentation should not change here
// Attribute { style: Outer, value: List(Ident("allow"), [MetaItem(Word(Ident("non_snake_case")))]), is_sugared_doc: false } | ||
// example: | ||
// Attribute { style: Outer, value: List(Ident("allow"), | ||
// [MetaItem(Word(Ident("non_snake_case")))]), is_sugared_doc: false } |
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.
the indentation should not change here
testsuite/tests/no_std
Outdated
@@ -1 +0,0 @@ | |||
../no_std/tests/ |
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.
didn't you like this symlink?
I thought it would make it easier to find the no_std
testcases.
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.
It was causing build problems for me for some reason.
@colin-kiegel as a heads-up, I'm going to take another stab at this. Since we don't support generating multiple builders off a single struct, it still makes sense to me to expose a One major change though: Somehow the crate name Edit: Having just written this, I'm waffling on the trait argument. Callers would have to import the type they wanted to build and the trait (blegh), which seems less ergonomic than importing two types from the crate they're directly consuming. |
This allows to add other item definitions as described in https://users.rust-lang.org/t/10546/2
derive_builder
->derive_builder_macro
derive_builder
, which re-exportsderive_builder_macro
testsuite
no_std
testcase into a separate crate insidetestsuite
.This way we have better control, e.g.
derive_builder
with no_std featureWIP
The
no_std
test is still failing. Somehowderive_builder
still re-exportsstd
. This is probably due to the glob-export inderive_builder/src/lib.rs:530
But it would seem very difficult to write
derive_builder_macro
withoutstd
. There must be a different way - especially since serde seems to be doing something like this successfully. Could this be the trick?cc @TedDriggs