@@ -16,6 +16,7 @@ For more background, see the following blog-posts:
16
16
Changes compared to the latest post (2.1):
17
17
18
18
* 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.
19
20
20
21
[ Miri ] : https://github.com/solson/miri/
21
22
[ 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:
286
287
- For mutable raw pointers and two - phase `Unique `, the permission is `SharedReadWrite `.
287
288
- For `Shared `, the permission is different for locations inside of and outside of `UnsafeCell `.
288
289
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 .
289
295
- For immutable raw pointers , the rules are the same as for `Shared `.
290
296
291
297
So , basically , for every location , we call `grant ` like this :
0 commit comments