News for hackers. Stuff that matters.
Re:From Stacks to Trees: A new aliasing model for Rust by PoignardAzur on Sunday June 11, 2023 @07:26PM (#36286786)
To be clear, this doesn't change what programs get accepted by the borrow checker, so for most rust users it changes absolutely nothing.

It changes the abstract rules behind rust's safety model, which impacts which unsafe functions are considered sound, and which optimizations the compiler is allowed to perform.

Re:From Stacks to Trees: A new aliasing model for Rust by saghm on Sunday June 11, 2023 @10:44PM (#36287875)
Ah, I guess I did misunderstand then. I see now rereading that the "don't treat as a mutable borrow until first write" is already how things behave today and have since NLL.
Re:From Stacks to Trees: A new aliasing model for Rust by k1t on Monday June 12, 2023 @02:36AM (#36289232)
That's not really true. If it were, this would compile since there are no writes.

  fn main() {
    let mut x = [1,2,3,4,5];
    let y = &mut x[0];
    let z = &x[1];
    println!("y {}... z {} ", y,  z);
  }
But it doesn't.
Re:From Stacks to Trees: A new aliasing model for Rust by chrismorgan on Sunday June 11, 2023 @11:02PM (#36287980)
To expand a little on this, by pulling out one key piece of the article:

This is what the footnote of the bit about &(i32, Cell<i32>) clarifies (which footnote was added due to this misunderstanding, discussed in https://old.reddit.com/r/rust/comments/13y8a9b/from_stacks_t...).

> In particular, for &(i32, Cell<i32>), TB allows mutating both fields, including the first field which is a regular i32, since it just treats the entire reference as “this allows aliasing”.¹

> ¹ This does not mean that we bless such mutation! It just means that the compiler cannot use immutability of the first field for its optimizations. Basically, immutability of that field becomes a safety invariant instead of a validity invariant […]

This matter of safety versus validity invariants is key (https://www.ralfj.de/blog/2018/08/22/two-kinds-of-invariants...).