Uh oh!
There was an error while loading. Please reload this page.
Implement specialised clone_from via #[derive(Clone)] - #27939
Conversation
rust-highfive
commented
Aug 22, 2015
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
alexcrichton
commented
Aug 22, 2015
Looks like I'm also a little worried about this in terms of compile times, |
tbu-
commented
Aug 22, 2015
We've kept this method, maybe we should support it too... |
Diggsey
commented
Aug 23, 2015
@alexcrichton I'm not sure how best to benchmark the impact this has on compile times (or whether such results would even be meaningful if I tried to benchmark on my laptop, I seem to get incredibly variable compile times in msys). I agree with @tbu- if this method exists it should be implemented, otherwise it's just giving the illusion that there's a more performant version of clone. I've also found |
alexcrichton
commented
Aug 24, 2015
Can you generate a test cases along the lines of:
I'm not saying we should not do this, I'm saying that if this doubles compile times then we should think through this before hastily merging. |
brson
commented
Aug 24, 2015
I see @alexcrichton mentioning downsides here, but the advantage of doing this isn't clear. The linked issue doesn't describe any concrete wins. Are there theoretical performance improvements? Can they be measured? |
tbu-
commented
Aug 24, 2015
@brson Consider a struct containing a vector, with this derive the |
Kimundi
commented
Aug 24, 2015
I agree with @tbu- here - |
brson
commented
Aug 28, 2015
Waiting to see how this affects compiletimes per @alexcrichton. |
Diggsey
commented
Aug 31, 2015
I ran the two tests @alexcrichton described, code: https://gist.github.com/Diggsey/7268beefb47a2cc9a740 Each test was run five times, and the best result used (all times are in seconds): So clearly this does have a large negative impact on compile times. However, in real code it's extremely rare to only derive Unfortunately, rustc overflowed its stack for |
alexcrichton
commented
Aug 31, 2015
Hm ok, so it looks like this is about a 2x-ish hit (which kinda makes sense) in terms of adding compile time to |
Diggsey
commented
Aug 31, 2015
Testing on |
alexcrichton
commented
Sep 2, 2015
I'm personally feeling that these numbers are significant enough and the benefit is marginal enough that I would prefer to not go forward with this just yet. Perhaps in the future we can enable faster codegen of |
Aatch
commented
Sep 25, 2015
One potential option could be a way of opting in to a derived |
brson
commented
Nov 23, 2015
Since this has been stalled a long time, closing per @alexcrichton's reasoning. |
orlp
commented
Jul 3, 2021
It has been 5 years. Could this be revisited? |
frankmcsherry
commented
Sep 10, 2021
Per the above mention, we needed to manually implement |
This also adds machinery to
deriveso that it can track the mutability of self parameters, which is required so that it can generate the correct match expressions and destructuring.Fixes#13281