1. 19
    1. 23

      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.

      1. 9

        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”.

        1. 3

          Though you can do:

          let myref = unsafe {
              let ptr = &self.some_thing as *const SomeThing;

          Which makes Rust forget that myref is borrowing self. Not turning off borrow checker, but at least limiting how much it “knows”.