title: Why does std::rc::Rc need PhantomData?
body: <p>I know that <code>PhantomData</code> is intended to consume a lifetime or type parameter in a data type definition that would otherwise go unused. I was recently looking over the definition of <code>Rc</code> in the <a href="https://github.com/rust-lang/rust/blob/dee08ba55accecc13ed600e0fb6559fb28e7f480/src/liballoc/rc.rs#L278-L281" rel="noreferrer">Rust std lib</a> and noticed that it seems to employ <code>PhantomData</code>, but it looks like <code>T</code> is being used in the sibling field <code>ptr</code> as an <a href="https://github.com/rust-lang/rust/blob/dee08ba55accecc13ed600e0fb6559fb28e7f480/src/liballoc/rc.rs#L259-L263" rel="noreferrer"><code>NonNull&lt;RcBox&lt;T&gt;&gt;</code></a>. The docs say that <code>NonNull</code> is <a href="https://doc.rust-lang.org/beta/std/ptr/struct.NonNull.html" rel="noreferrer">"*mut T but non-zero and covariant."</a> and go on to further extend that definition with the statement:</p>
  
  <blockquote>
    <p>Unlike <code>*mut T</code>, <code>NonNull&lt;T&gt;</code> is covariant over T. If this is incorrect for your use case, you should include some <code>PhantomData</code> in your type to provide invariance, such as <code>PhantomData&lt;Cell&lt;T&gt;&gt;</code> or <code>PhantomData&lt;&amp;'a mut T&gt;</code>.</p>
  </blockquote>
  
  <p>Hence, is it needed for variance or is it more because <code>NonNull</code> is effectively a raw pointer and <code>PhantomData</code> is needed to consume the elided lifetime as <a href="https://stackoverflow.com/a/57846101/2748415">this answer seems to imply</a>?</p>