clarification
[web.git] / personal / _posts / 2023-06-02-tree-borrows.md
index 3c4f0c7fd43fca3f2e2a8a5883a3388d50a50b15..ef7f8034e4e0c148ae599e8ae05ddf1fa7e2c7a0 100644 (file)
@@ -1,6 +1,7 @@
 ---
 title: "From Stacks to Trees: A new aliasing model for Rust"
 categories: rust research
+reddit: /rust/comments/13y8a9b/from_stacks_to_trees_a_new_aliasing_model_for_rust/
 ---
 
 Since last fall, [Neven](https://perso.crans.org/vanille/) has been doing an internship to develop a new aliasing model for Rust: Tree Borrows.
@@ -151,7 +152,7 @@ First of all, another [major issue](https://github.com/rust-lang/unsafe-code-gui
 This falls out of how TB handles the aliasing allowed with `UnsafeCell`: they are treated like casts to raw pointers, so reborrowing an `&Cell<i32>` just inherits the tag (and therefore the permissions) of the parent pointer.
 
 More controversially, TB also changes how precisely things become read-only when an `&T` involves `UnsafeCell` somewhere inside `T`.
-In particular, for `&(i32, Cell<i32>)`, TB allows mutating the first field, since it just treats the entire reference as "this allows aliasing".
+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".
 In contrast, SB actually figured out that the first 4 bytes are read-only and only the last 4 bytes allow mutation via aliased pointers.
 
 The reason for this design decision is that the general philosophy with TB was to err on the side of allowing more code, having less UB (which is the opposite direction than what I used with SB).