missed optimimization: needless clone of stdlib non-copy type is not eliminated #138118
Labels
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
code: https://rust.godbolt.org/z/5M1nnhEbY (godbolt isn't letting me copy it for some reason)
compiler version: 1.85.0
I understand that technically
Clone
can have side effects, but standard library types should be able to use some sort of perma-unstable attribute to assert that theirClone
impl does not (technically calling the allocator is an arbitrary side-effect, but i believe rust already has a policy that allocations can be eliminated).Types that use
derive(Clone)
, where all of the fields are pure types, should also have their clone impls marked as safe.The text was updated successfully, but these errors were encountered: