Borrow error resolved with new variable not fixed by NLL?

How come this builds:

let len = buf)?;
let curslice = &buf[..len];


But this doesn't?

let curslice = &buf[ buf)?];


I mean, sure, I get that the mutable borrow is held for the entire duration of the statement so the immutable borrow can't happen, but... the mutable borrow clearly isn't needed anymore so why not just end its lifetime before the immutable starts? I thought Non-Lexical Lifetimes was implemented to fix things like that. What gives?

This is basically the same as this, but with the borrow types flipped

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.