-
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
Disable derive clone on owned pattern #111
Disable derive clone on owned pattern #111
Conversation
Thanks for contributing to the crate. I can take a look at this |
Regarding cargo choosing 0.3.3, I believe cargo.lock overrides cargo.toml and you can update cargo.lock with
In my other projects I have a parameter or environment variable in scripts to select the toolchain, then call those scripts from Travis. Would you be willing to try this? If not I'll have a go. |
So turns out it was this niggly point: I've locked down
I think that's intended — this crate maintains compatibility with Rust 1.15, so it must always compile with that as part of testing. I have tested on
Pushed! |
Yes, tests for You can bump the minimum Rust version, if you think there is good reason to do so. Stale dependencies can be a very good reason of course. Just keep in mind, that this is a breaking change and implies a "major" release of derive-builder. :-) But this just reminds me that travis was recently failing and I changed Now a quick fix would be to remove the "skeptic_tests" feature in this line. And replace Then you don't need to stick with old dependencies or bump the minimum rust version. Because it's good enough when skeptic tests only run on nightly. |
@azriel91 Let me know if you need further advice. Regarding the PR: As of Jan 3rd @TedDriggs volunteered to lead this crate development together with @Dylan-DPC @fluffysquirrels. We still have to see how this works out. This is like the first test case. ;-) |
Zing!
I also did this, because I like good dev user experience:
|
it is better to mention |
@colin-kiegel Kindly review this. I see no issue with it. There are a few caveats (like having a minimum requirement of Rust 1.15 which could mess up some dependencies) but we can solve them as separate issues. |
@TedDriggs Hiya, do you have time to review this in the near future? |
Hiya again! I'd like to push for this to be merged / released, because it helps me remove one of the "bad contagion" tech debts before it starts to grow in my code base. |
@azriel91 reviewing now |
derive_builder/src/options/mod.rs
Outdated
//! options specified at the struct level. This creates one `OptionsBuilder<FieldMode>` per | ||
//! struct field on the input/target type. Once complete, these get converted into | ||
//! `FieldOptions` instances. | ||
//! 1. Builder options on the struct are parsed into |
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.
@azriel91 please undo the formatting on comments; this has broken the ordered list rendering.
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.
Fixed!
Will merge after fix to doc comments |
This aligns the development git hook with the Travis CI build. The skeptic tests are still run on `nightly`, so we don't lose that level of testing.
This also tells them that the flag has been updated to `hooks.checkminimumrust`.
dfc1e69
to
c72a3c5
Compare
Sweet thank you! I've pushed the branch minus the Rustfmt commit, but the nightly build fails due to rust-lang/cargo#5364 |
@azriel91 well, that's not very helpful of them. I'll check back in a couple days to see if the nightlies have it fixed; I'm more comfortable merging when there's a passing Travis run. |
@azriel91 I've finally had some time to come back to this crate, and CI is now fixed on master. I've got a PR in (#120) that updates our version of |
@@ -76,6 +81,11 @@ impl<'a> ToTokens for Builder<'a> { | |||
let builder_vis = self.visibility; | |||
let builder_ident = self.ident; | |||
let derives = self.derives; | |||
let clone_derive = if self.pattern.requires_clone() || self.initializer_requires_clone { |
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.
Why is this an 'or' here?
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's because the builder needs to derive Clone
when using the mutable or immutable patterns;
When the builder pattern is owned, but at least one field overrides the pattern to be mutable/immutable, the builder itself doesn't have to. At the time the PR was made, I was a noob just catered for making the builder not derive Clone
when no fields override the pattern and didn't work through the code to make the builder also not derive Clone
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.
Okay, I think my version handles this correctly then; it requires clone if any field requires it, whether via explicit or implicitly getting the mutable or immutable pattern.
Removing approval because of larger crate changes
Closing in favour of #122 |
Attempts to address #97, here's the quick summary:
Clone
optionally derived on theBuilder
, depending on theBuilderPattern
on the struct as well as on each of the fields. I'm not sure if the way it calculates and passes the "mark this as should deriveClone
" is a good way — it was the quickest way to get most of the tests to pass.The
./dev/checkfeatures.sh
run fails, but I couldn't figure out how to make it pass:getopts 0.2.17
fails to compile:Cargo.lock
sayscompiletest_rs 0.3.7
depends ongetopts 0.2.17
.Cargo.toml
inderive_builder
says:Which, to me says "use version
0.3.3
of compiletest_rs" but cargo is disobeying that. Then I became sad because I tried munging dependencies, but cargo always chose0.3.7
ofcompiletest_rs
. I did deleteCargo.lock
and try again + some other variations. Maybe this issue would solve that: rust-lang/cargo#4100Re-enactment of how I did this PR
rg -F owned
.cargo test
rg -F '::Owned'
.CONTRIBUTING.md