A Rust compiler must also implement unsafe, of course, which disables a lot of the checks that the compiler makes.
This is just wrong, and it’s frustrating to hear it repeated so often. unsafe permits calling other unsafe code, dereferencing raw pointers, reinterpreting unions, and implementing unsafe traits like Send and Sync. It does not “turn off” the type system, borrow checker, or anything else.
This is just wrong, and it’s frustrating to hear it repeated so often.
unsafe
permits calling otherunsafe
code, dereferencing raw pointers, reinterpretingunion
s, and implementingunsafe trait
s likeSend
andSync
. It does not “turn off” the type system, borrow checker, or anything else.Was also quite unhappy seeing this incorrect understanding of
unsafe
repeated.My favorite explanation is Steve Klabnik’s “You can’t ‘turn off the borrow checker’ in Rust”.
Though you can do:
Which makes Rust forget that
myref
is borrowingself
. Not turning off borrow checker, but at least limiting how much it “knows”.