Interisting analysis. My next question: Would that mean it’s not a valid optimization for a compiler when given code like
let x = [0; 10000];
let y = &x[0..10]
// ... rest of code only uses y, not x
to argue, “only the first 10 entries of x
are ever used, let’s save loads of stack space and turn this into
let x = [0; 10];
let y = &x[0..10]
// ... rest of code only uses y, not x
”?