4 ms·
Actually, &mut isn't equivalent to restrict, since two restrict pointers are allowed to alias in C as long as none of the intervening accesses are writes.
by cwzwarich 8y ago
Actually, &mut isn't equivalent to restrict, since two restrict pointers are allowed to alias in C as long as none of the intervening accesses are writes.
- steveklabnik 8y agoIsn’t that the same in Rust? For example, split_at_mut? (I mean, it’s not like this is 100% nailed down yet...)
- Jweb_Guru 8y agosplit_at_mut doesn't allow you to read through aliased "active" &mut pointers either (I would assume that restrict pointers that cannot be either read from or written to don't count).
- steveklabnik 8y agoRight, but they both exist. I guess that’s what I’m trying to say... it’s the active bit that matters.
- Jweb_Guru 8y agoHm, in that case you don't need to appeal to split_at_mut--reborrowing is sufficient to demonstrate that point. I think what czwarich is saying is more subtle--that restrict allows "multiple readers, exclusive writer", which means that both shared pointers without UnsafeCell and mutable references in Rust are restrict in this sense, while &mut is more restrictive.
- steveklabnik 8y agoThat’s fair, but I feel like split_at_mut is far more well-known than reborrowing.