Open
Description
The following code works without NLL but not with NLL enabled:
https://play.rust-lang.org/?gist=9b797f941b3aa419991e15fd5a2d07a0&version=nightly&mode=debug
//#![feature(nll)]
struct S {
a: &'static str,
}
fn f(_: &mut S, _: &str) {
}
fn main() {
let mut s = S {
a: "a",
};
f(&mut s, s.a);
}
NLL is not wrong to reject this code. This is #38899. However, it could plausibly be accepted if we expanded two-phase borrows ever so slightly... actually, I'm not sure about this exact source, or it least it wouldn't quite fit into what I had in mind.
I had in mind an expansion for arguments of type &mut
, basically, so that foo(bar)
, if bar
is an &mut
that is being reborrowed, would reborrow using a 2-phase borrow.