title: Fn as trait concrete lifetime required
body: <p>I want to use an API that I can modify <code>reg</code>:</p>
  
  <pre><code>struct Ctx;
  trait Foo {}
  
  trait Ex {
      fn do_&lt;'a&gt;(&amp;self, cx: &amp;'a mut Ctx) -&gt; Box&lt;Foo + 'a&gt;;
  }
  
  impl&lt;F&gt; Ex for F
  where
      F: for&lt;'a&gt; Fn(&amp;'a mut Ctx) -&gt; Box&lt;Foo + 'a&gt;,
  {
      fn do_&lt;'a&gt;(&amp;self, ecx: &amp;'a mut Ctx) -&gt; Box&lt;Foo + 'a&gt; {
          (*self)(ecx)
      }
  }
  
  fn reg&lt;F&gt;(name: &amp;str, ext: F)
  where
      F: Ex + 'static,
  {
  }
  
  //My code starts here
  struct Boo;
  
  impl Boo {
      fn f1&lt;'a&gt;(&amp;self, cx: &amp;'a mut Ctx) -&gt; Box&lt;Foo + 'a&gt; {
          unimplemented!();
      }
  }
  
  fn main() {
      let boo = Boo;
      reg("aaa", move |cx| boo.f1(cx));
  }
  </code></pre>
  
  <p>But I got an error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0271]: type mismatch resolving `for&lt;'a&gt; &lt;[closure@src/main.rs:33:16: 33:36 boo:_] as std::ops::FnOnce&lt;(&amp;'a mut Ctx,)&gt;&gt;::Output == std::boxed::Box&lt;Foo + 'a&gt;`
    --&gt; src/main.rs:33:5
     |
  33 |     reg("aaa", move |cx| boo.f1(cx));
     |     ^^^ expected bound lifetime parameter 'a, found concrete lifetime
     |
     = note: concrete lifetime that was found is lifetime '_#9r
     = note: required because of the requirements on the impl of `Ex` for `[closure@src/main.rs:33:16: 33:36 boo:_]`
     = note: required by `reg`
  
  error[E0281]: type mismatch: `[closure@src/main.rs:33:16: 33:36 boo:_]` implements the trait `std::ops::Fn&lt;(&amp;mut Ctx,)&gt;`, but the trait `for&lt;'a&gt; std::ops::Fn&lt;(&amp;'a mut Ctx,)&gt;` is required
    --&gt; src/main.rs:33:5
     |
  33 |     reg("aaa", move |cx| boo.f1(cx));
     |     ^^^        -------------------- implements `std::ops::Fn&lt;(&amp;mut Ctx,)&gt;`
     |     |
     |     requires `for&lt;'a&gt; std::ops::Fn&lt;(&amp;'a mut Ctx,)&gt;`
     |     expected concrete lifetime, found bound lifetime parameter 'a
     |
     = note: required because of the requirements on the impl of `Ex` for `[closure@src/main.rs:33:16: 33:36 boo:_]`
     = note: required by `reg`
  </code></pre>
  
  <p>How can I fix this? </p>
  
  <p>In real code my <code>struct Boo</code> contains some data,
  and want to call <code>reg</code> for it twice, so I not implement <code>trait Ex</code>, but
  try to use closure.</p>