Non-Lexical Lifetimes (NLL) is a Rust compiler feature that determines reference validity based on actual usage points rather than the entire lexical scope of a variable. This allows references to be used after other variables in the same scope have been dropped, as long as those variables are no longer needed. The compiler implements this via the mir_borrowck query and Borrowck analysis in rustc_borrowck to track borrows precisely.
fn main() {
let mut s = String::from("hello");
let r1 = &s;
let r2 = &s;
// Without NLL, r1 would be invalid here because s is still "in scope"
// With NLL, r1 is valid because it's not used after this point
println!("{}", r2);
}