title: Weird borrow checker error
body: <p>The following code won't compile:</p>
  
  <pre><code>fn test&lt;'a&gt;(index: usize, v: &amp;'a mut Vec&lt;i32&gt;) -&gt; Option&lt;&amp;'a i32&gt; {
      {
          let t = v.get(index);
          if t.is_some() {
              return t
          }
          //return t
      }
      v.insert(index, index as i32 + 1);
      v.get(index)
  }
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable
    --&gt; src/main.rs:9:5
     |
  3  |         let t = v.get(index);
     |                 - immutable borrow occurs here
  ...
  9  |     v.insert(index, index as i32 + 1);
     |     ^ mutable borrow occurs here
  10 |     v.get(index)
  11 | }
     | - immutable borrow ends here
  </code></pre>
  
  <p>I thought this code would be fine because the immutable borrow occurs in an inner block. What's weird is that if I remove the if-clause and just return "t" in the inner block then the code compiles fine.</p>
  
  <p>Am I missing something here? I am using Rust 1.22.1 on Linux.</p>