Skip to content

Commit ae47b93

Browse files
committed
also document the !Unpin exception
1 parent 919180b commit ae47b93

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

wip/stacked-borrows.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Changes from to the latest post (2.1) to the paper:
2222

2323
Changes since publication of the paper:
2424

25+
* HACK: Mutable references to `!Unpin` types do not make uniqueness assumptions.
2526
* Items with `SharedReadWrite` permission are not protected even with `FnEntry` retagging.
2627

2728
[Miri]: https://github.com./solson/miri/
@@ -288,8 +289,9 @@ fn reborrow(
288289
We will grant `new_tag` permission for all the locations covered by this place, by calling `grant` for each location.
289290
The parent tag (`derived_from`) is given by the place.
290291
The interesting question is which permission to use for the new item:
291-
- For non-two-phase `Unique`, the permission is `Unique`.
292-
- For mutable raw pointers and two-phase `Unique`, the permission is `SharedReadWrite`.
292+
- For non-two-phase `Unique` to an `Unpin` type, the permission is `Unique`.
293+
(The `Unpin` exception is a special hack to avoid soundness issues due to self-referential generators.)
294+
- For mutable raw pointers and the remaining `Unique`, the permission is `SharedReadWrite`.
293295
- For `Shared` and immutable raw pointers, the permission is different for locations inside of and outside of `UnsafeCell`.
294296
Inside `UnsafeCell`, it is `SharedReadWrite`; outside it is `SharedReadOnly`.
295297
- The `UnsafeCell` detection is entirely static: it recurses through structs,
@@ -306,10 +308,10 @@ Otherwise the new item will not have a protector.
306308
So, basically, for every location, we call `grant` like this:
307309
```rust
308310
let (perm, protect) = match ref_kind {
309-
RefKind::Unique { two_phase: false } =>
311+
RefKind::Unique { two_phase: false } if unpin =>
310312
(Permission::Unique, protect),
311313
RefKind::Raw { mutable: true } |
312-
RefKind::Unique { two_phase: true } =>
314+
RefKind::Unique { .. } =>
313315
(Permission::SharedReadWrite, protect),
314316
RefKind::Raw { mutable: false } |
315317
RefKind::Shared =>

0 commit comments

Comments
 (0)