The borrow rule — at any point, either many &T (shared) XOR exactly one &mut T (exclusive), never both — isn’t arbitrary strictness. It exists to give the compiler a hard aliasing guarantee: data reachable through immutable references can never be mutated via some aliased mutable reference at the same time.

That guarantee buys two concrete things:

  1. Optimization. The compiler can cache a value in a register across a stretch of code, knowing no hidden aliased write can invalidate it. In C/C++ two pointers might alias, so the compiler must conservatively re-read from memory; Rust’s rule lets it assume they don’t.
  2. Data-race-freedom. A data race requires a concurrent read and write (or two writes) to the same location. Since you can’t have a shared borrow and an exclusive borrow coexist, unsynchronized concurrent mutation is impossible by construction — this is the static half of Rust’s Send/Sync story.

So “many-shared XOR one-exclusive” is the single rule that makes both aggressive optimization and memory/thread safety sound at once.

See also

References

Questions

flashcards/rust

Why does the borrow rule (many &T XOR one &mut T) exist \u2014 what does it buy the compiler?::A hard aliasing guarantee: shared data can’t be mutated via an aliased &mut concurrently. This enables register-caching optimizations (no hidden write invalidates a cached value) and makes data races impossible by construction.

The no-aliased-mutation guarantee makes both aggressive optimization and data-race-freedom sound at the same time.

Why can C/C++ not cache a value in a register as aggressively as Rust across pointer operations?::Two C/C++ pointers might alias, so a write through one could invalidate a value read through another — the compiler must conservatively re-read from memory. Rust’s borrow rule rules out that aliasing.