@@ -16,6 +16,7 @@ For more background, see the following blog-posts:
1616Changes compared to the latest post (2.1):
1717
1818* Retags are "shallow" instead of recursively looking for references inside compound types.
19+ * Reborrowing of a shared reference, when searching for ` UnsafeCell ` , no longer reads enum discriminants. It treats enums like unions now.
1920
2021[ Miri ] : https://github.com/solson/miri/
2122[ all-hands ] : https://paper.dropbox.com/doc/Topic-Stacked-borrows--AXAkoFfUGViWL_PaSryqKK~hAg-2q57v4UM7cIkxCq9PQc22
@@ -286,6 +287,11 @@ The interesting question is which permission to use for the new item:
286287- For mutable raw pointers and two - phase `Unique `, the permission is `SharedReadWrite `.
287288- For `Shared `, the permission is different for locations inside of and outside of `UnsafeCell `.
288289 Inside `UnsafeCell `, it is `SharedReadWrite `; outside it is `SharedReadOnly `.
290+ - The `UnsafeCell ` detection is entirely static : it recurses through structs ,
291+ tuples and the like , but when hitting an `enum ` or `union ` or so , it treats
292+ the entire field as an `UnsafeCell ` unless its type is frozen . This avoids
293+ hard - to - analyze recursive behavior caused by Stacked Borrows itself doing
294+ memory accesses that are subject to Stacked Borrows rules .
289295- For immutable raw pointers , the rules are the same as for `Shared `.
290296
291297So , basically , for every location , we call `grant ` like this :
0 commit comments