title: "cannot infer an appropriate lifetime for pattern due to conflicting requirements" in `ref mut` pattern
body: <pre><code>struct RefWrap&lt;'a&gt; {
      wrap: &amp;'a mut Option&lt;String&gt;,
  }
  
  impl&lt;'a&gt; RefWrap&lt;'a&gt; {
      fn unwrap(&amp;mut self) -&gt; &amp;'a mut String {
          match *self.wrap {
              Some(ref mut s) =&gt; s,
              None =&gt; panic!(),
          }
      }
  }
  </code></pre>
  
  <p>(<a href="https://play.rust-lang.org/?gist=fd85a8da40b1cdb333ff190b99fcd77a&amp;version=stable&amp;backtrace=0" rel="nofollow noreferrer">Playground</a>)</p>
  
  <p>As far as I understand, this code is correct (the returned reference really has the lifetime <code>'a</code>. But Rust produces the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0495]: cannot infer an appropriate lifetime for pattern due to conflicting requirements
   --&gt; &lt;anon&gt;:8:18
    |
  8 |             Some(ref mut s) =&gt; s,
    |                  ^^^^^^^^^
  </code></pre>
  
  <p><a href="https://play.rust-lang.org/?gist=1f7ea385c6556746d3a3305afd526a50&amp;version=stable&amp;backtrace=0" rel="nofollow noreferrer">Using immutable references</a>, it works without an error.</p>
  
  <p>There has been <a href="https://stackoverflow.com/questions/28089695/lifetime-of-variable-in-a-match-pattern">one similar question</a>, but I'm pretty sure it's not helpful in this case.</p>