title: The size for values of type `T` cannot be known at compilation time when using mem::size_of::<T> as an array length
body: <p>Consider the following function:</p>
  
  <pre><code>fn make_array&lt;T&gt;()
  where
      T: Sized,
  {
      let bytes = [0u8; std::mem::size_of::&lt;T&gt;()];
  }
  </code></pre>
  
  <p>For whatever reason it fails to compile </p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the size for values of type `T` cannot be known at compilation time
   --&gt; src/lib.rs:5:23
    |
  5 |     let bytes = [0u8; std::mem::size_of::&lt;T&gt;()];
    |                       ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
    = help: the trait `std::marker::Sized` is not implemented for `T`
    = note: to learn more, visit &lt;https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait&gt;
    = help: consider adding a `where T: std::marker::Sized` bound
    = note: required by `std::mem::size_of`
  </code></pre>
  
  <p>This is despite the fact that there is a <code>Sized</code> trait bound for the generic parameter <code>T</code>. It doesn't make any sense to me.</p>
  
  <p>Why is this happening and how do I work around it?</p>