title: Why is casting a const reference directly to a mutable reference invalid in Rust?
body: <p>This piece of code is correct:</p>
  
  <pre><code>fn f() {
      let mut x = 11;
      b(&amp;x as *const u8 as *mut u8);
  }
  
  fn b(x: *mut u8) {}
  </code></pre>
  
  <p>Why is <code>b(&amp;x as *const u8 as *mut u8)</code> is valid whereas <code>b(&amp;x as *mut u8)</code> is invalid? The compiler complains about: </p>
  
  <blockquote>
    <p>error[E0606]: casting <code>&amp;u8</code> as <code>*mut u8</code> is invalid</p>
  </blockquote>