-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[WIP] Implement shim for types that transitively derive Clone #72409
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
If a type is `#[derive(Clone)]`, and all of its transitive fields are also `#[derive(Clone)]`, we skip generating the actual `clone` function. Instead, we generate a 'clone shim', which just acts like the trivial `Clone` impl for a `Copy` type. We do this even if the type itself is not `Copy`.
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit c5f81d3 with merge c5fabb124ddbb26acecd838a51e410b4e1ea16e4... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☀️ Try build successful - checks-azure |
Queued c5fabb124ddbb26acecd838a51e410b4e1ea16e4 with parent 0aa6751, future comparison URL. |
Finished benchmarking try commit c5fabb124ddbb26acecd838a51e410b4e1ea16e4, comparison URL. |
Needs to rebase and fix the CI failure. |
Was the expectation that this would improve performance, or is there a different motivation? |
@varkor: I opened this as an experiment to measure the perf impact - however, it doesn't seem that optimization is very useful in practice (at least where compilation time is concerned). |
I'm closing this for now. I may revisit it at some point if I come up with a way to speed it up. |
If a type is
#[derive(Clone)]
, and all of its transitive fieldsare also
#[derive(Clone)]
, we skip generating the actualclone
function. Instead, we generate a 'clone shim', which just acts like the
trivial
Clone
impl for aCopy
type. We do this even if the typeitself is not
Copy
.