fn main() {
let mut a = 13;
let b = &a;
let c = b as *const _ as *mut _;
unsafe { *c = 42; }
println!("b = {}", b);
}
On the playground it prints "b = 42" (https://play.rust-lang.org/?version=stable&mode=debug&editio...). error[E0080]: constant evaluation error: borrow being
accessed (Alias(None)) does not exist on the borrow stack
--> src/main.rs:5:14
|
5 | unsafe { *c = 42; }
| ^^^^^^^ borrow being accessed
(Alias(None)) does not exist on the borrow stack
error: aborting due to previous error
The error messages of the constant evaluator aren't great yet, but that basically tells you that it couldn't find a suitable mutable borrow to mutate the variable, so the access is undefined behavior.
Obviously, these tools don't solve the problem for you. In the same way that some C++ projects use doxygen without writing doc comments and say "but we have auto-docs!", some Rust projects (the rust compiler libraries and official projects, e.g., cargo, libsyntax, etc.) almost completely lack API docs. They do have books (rustc book and implementors guide, cargo book, etc.) so it isn't that they are completely undocumented, but if you want to use these as libraries, the auto-generated API docs are useless.