|
|
|
|
|
by yinser
697 days ago
|
|
Is it possible for the rust compiler to statically determine if two memory regions will overlap at compile-time, especially with complex pointer arithmetic or when pointers are passed as function arguments? It would be super impressive if so. |
|
In practice, that means that when writing your own code, you can (and in the vast majority of cases should) just stick to safe Rust, and you can be sure that you won't ever make overlapping references if either one is mutable. Safe APIs can be built on top of unsafe APIs though, so you won't necessarily be able to assume your dependencies are doing the same (although there's tooling to help with that, e.g. requiring via the config to generate a build error if any dependency uses unsafe code)