Closed
Description
The following snippet should be rejected for allowing a value to be mutated while it is borrowed, but it is accepted on nightly when non-lexical lifetimes are enabled (playground):
#![feature(nll)]
fn flatten<'a, 'b, T>(x: &'a &'b T) -> &'a T {
x
}
fn main() {
let mut x = "original";
let y = &x;
let z = &y;
let w = flatten(z);
x = "modified";
println!("{}", w); // prints "modified"
}
Metadata
Metadata
Assignees
Labels
Area: Non-lexical lifetimes (NLL)Area: The borrow checkerCategory: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessWorking towards the "invalid code does not compile" goalRelevant to the compiler team, which will review and decide on the PR/issue.