On 12/3/13 12:54 AM, Josh Matthews wrote:
I don't entirely understand what this means, either in theory or in
practice.

So the issue is that the Rust compiler assumes a couple of things around `&mut`:

1. No `&mut` aliases any `&` (because then `&` wouldn't be immutable).

2. No `&mut` aliases any other `&mut` (i.e. no two `&mut`s to the same location).

Violating this will lead to undefined behavior, in particular iterator invalidation. So these rules need to be enforced dynamically.

The easiest way, and the way we'd like to do it in the future, is to not have mutable borrows of reference-counted or garbage-collected, and to instead wrap individual fields that should be mutable in the new `RefCell` (today called `Slot` in Servo), which exposes convenient `.get()` and `.set()` methods. But the problem is that `RefCell`/`Slot` currently bloats the field by adding an extra byte. I have a plan to fix that for most fields, but this is not yet implemented. So it's probably best to just `FIXME` it for now.

Patrick
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to