Skip to content

Commit 74d656a

Browse files
committed
update for no longer recursing below enums
1 parent e7395e0 commit 74d656a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

wip/stacked-borrows.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ The interesting question is which permission to use for the new item:
286286
- For mutable raw pointers and two-phase `Unique`, the permission is `SharedReadWrite`.
287287
- For `Shared`, the permission is different for locations inside of and outside of `UnsafeCell`.
288288
Inside `UnsafeCell`, it is `SharedReadWrite`; outside it is `SharedReadOnly`.
289+
- The `UnsafeCell` detection is entirely static: it recurses through structs,
290+
tuples and the like, but when hitting an `enum` or `union` or so, it treats
291+
the entire field as an `UnsafeCell` unless its type is frozen. This avoids
292+
hard-to-analyze recursive behavior caused by Stacked Borrows itself doing
293+
memory accesses that are subject to Stacked Borrows rules.
289294
- For immutable raw pointers, the rules are the same as for `Shared`.
290295

291296
So, basically, for every location, we call `grant` like this:

0 commit comments

Comments
 (0)