title: How to put explicit lifetime bound on Self for associated constant?
body: <p>I have a trait which I want to have an associated constant on, where the constant will be a slice of the type that implements the trait. Something like this:</p>
  
  <pre class="lang-rust prettyprint-override"><code>trait A: Sized {
      const VALUES: &amp;'static [Self];
  }
  
  #[derive(Debug)]
  struct B {
      b: u8,
  }
  
  impl A for B {
      const VALUES: &amp;'static [B] = &amp;[B { b: 1 }];
  }
  
  #[derive(Debug)]
  struct C {
      c: usize,
  }
  
  impl A for C {
      const VALUES: &amp;'static [C] = &amp;[C { c: 4 }];
  }
  
  fn main() {
      println!("{:?}", B::VALUES);
      println!("{:?}", C::VALUES);
  }
  
  </code></pre>
  
  <p>This fails to compile with the error:</p>
  
  <pre><code>error[E0310]: the parameter type `Self` may not live long enough
   --&gt; src/main.rs:2:5
    |
  2 |     const VALUES: &amp;'static [Self];
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider adding an explicit lifetime bound `Self: 'static`...
  note: ...so that the reference type `&amp;'static [Self]` does not outlive the data it points at
  </code></pre>
  
  <p>How is that lifetime bound expressed for an associated constant? If it's relevant, I'm using latest <code>rustc</code> stable (<code>1.42.0</code>), and the 2018 edition.</p>