Skip to content

Commit 49f3c12

Browse files
authored
Merge pull request #200 from RalfJung/stacked_borrows
update for no longer recursing below enums
2 parents 636d140 + 15305ff commit 49f3c12

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

wip/stacked-borrows.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ For more background, see the following blog-posts:
1616
Changes 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

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

0 commit comments

Comments
 (0)