Why doesn't a mutable borrow of self change to immutable?
<p>This code fails the dreaded borrow checker (<a href="https://play.rust-lang.org/?gist=81b5445c6ddaa5b089ce27a751e5b0a3&amp;version=stable&amp;backtrace=0" rel="nofollow noreferrer">playground</a>):</p>

<pre><code>struct Data {
    a: i32,
    b: i32,
    c: i32,
}

impl Data {
    fn reference_to_a(&amp;mut self) -&gt; &amp;i32 {
        self.c = 1;
        &amp;self.a
    }
    fn get_b(&amp;self) -&gt; i32 {
        self.b
    }
}

fn main() {
    let mut dat = Data{ a: 1, b: 2, c: 3 };
    let aref = dat.reference_to_a();
    println!("{}", dat.get_b());
}
</code></pre>

<p>Since non-lexical lifetimes were implemented, this is required to trigger the error:</p>

<pre><code>fn main() {
    let mut dat = Data { a: 1, b: 2, c: 3 };
    let aref = dat.reference_to_a();
    let b = dat.get_b();
    println!("{:?}, {}", aref, b);
}
</code></pre>

<p>Error:</p>

<pre class="lang-none prettyprint-override"><code>error[E0502]: cannot borrow `dat` as immutable because it is also borrowed as mutable
  --&gt; &lt;anon&gt;:19:20
   |
18 |     let aref = dat.reference_to_a();
   |                --- mutable borrow occurs here
19 |     println!("{}", dat.get_b());
   |                    ^^^ immutable borrow occurs here
20 | }
   | - mutable borrow ends here
</code></pre>

<p>Why is this? I would have thought that the mutable borrow of <code>dat</code> is converted into an immutable one when <code>reference_to_a()</code> returns, because that function only returns an immutable reference. Is the borrow checker just not clever enough yet? Is this planned? Is there a way around it?</p>