From 2464f025ad1cfccd9d49904adbda813ef1cafdda Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 2 Jun 2023 14:29:52 +0200 Subject: [PATCH] clarification --- personal/_posts/2023-06-02-tree-borrows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/personal/_posts/2023-06-02-tree-borrows.md b/personal/_posts/2023-06-02-tree-borrows.md index e651835..ef7f803 100644 --- a/personal/_posts/2023-06-02-tree-borrows.md +++ b/personal/_posts/2023-06-02-tree-borrows.md @@ -152,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` 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)`, TB allows mutating the first field, since it just treats the entire reference as "this allows aliasing". +In particular, for `&(i32, Cell)`, 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). -- 2.30.2