On 6/7/12 1:41 PM, Gareth Smith wrote:
Hi Rust-Dev,

I have recently (using the latest rust from github) encountered some new
warnings about "implicitly copying a non-implicitly-copyable value". I
believe this is due to the fix for
https://github.com/mozilla/rust/issues/2450.

This warning seems to pop up all over the place because, as the bug
points out, vecs/strs are in-fact copied rather a lot (at least in the
rust I have written). I think that in some places I can restructure the
code to avoid copies, but that still leaves many places where I guess I
need to either add a `copy` or just ignore the warning (or turn it off).
I am worried that I will have to litter my code with `copy`.

Use @[int] instead of [int] or the new dvec to avoid copies. You can also use region pointers (&).

In practice copies hurt Rust performance a *lot*. Copies of vectors and strings are extremely expensive, and often make our performance drop way below even dynamically typed, interpreted languages.

The bug above mentions that the warning has been disabled for
[Mozilla's] existing projects. So my question is: what is the long-term
plan here? Will Mozilla's projects be restructured to avoid copying
strs/vecs, or to add `copy` where it is not possible? Will the new
vecs/strs make this a non-issue somehow (are vecs/strs still unique in
the new scheme?)?

The long term plan is:

* Introduce the new vectors and strings and make stack vectors the default, drastically reducing the number of unique vectors and strings.

* Only use unique vectors for vectors that are designed to cross from task to task.

* Clean up all copies from the existing Rust projects.

Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to