Does UnsafeCell still function under &mut T?

⚓ Rust    📅 2026-02-13    👤 surdeus    👁️ 1      

surdeus

UnsafeCell supports concurrent modification under &T without causing optimization issues because the compiler knows multiple references exist.

However, when using &mut T, does UnsafeCell still serve a purpose? Since the compiler assumes &mut T is a unique reference, will it become "more confident" in its optimizations and ignore the memory instability signaled by UnsafeCell?

12 posts - 6 participants

Read full topic

🏷️ Rust_feed