This is sort of a question, but doesn’t Rust refuse to compile even when you use non-concurrency safe objects in a single thread?
I think that is the case
Rust types have markers (Send, Sync) that tell the compiler whether they can be moved across threads, and whether they can be simultaneously accessed across threads.
These markers are irrelevant in a single-threaded scenario.
It's not purely about those markers. Many people also believe that the only issue with aliasing is when threads come into play, but that's not the case. Rust also prevents mutable aliasing even in non-threaded cases for this reason.
Is there any explanation of this? Specifically i would like to understand how a single mutable reference is required for correctness in a single thread scenario.
I’ve googled everywhere but I can’t find a single source of information that completely explains this, possibly showing realistic source code and elaborating the way it could generate memory errors or be miscompiled in case of multiple mutable references.