Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnsafePinned: allow aliasing of pinned mutable references #3467
UnsafePinned: allow aliasing of pinned mutable references #3467
Changes from 1 commit
51bed0f
d599c1e
c2bbec7
60ca0fa
6910494
a1a05fb
a10d70c
9535a37
06b52df
0369352
3e97a7e
a8f2516
a55adde
5f03b25
ce937b8
60c255f
9881c94
36b694d
7158ce2
5ff0df8
086412d
7190a78
d793712
9327537
86e0188
14b9019
5b2d690
1f31c7b
76a4035
bfb8c4b
e98f367
474389f
3efb695
519aeb6
b950de5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
UnsafeAliased
be!Unpin
? This (negative) impl listed isn't in the sketch, but it must be for the earlier guide-level line aboutPin<&mut S>
soundness to be accurate.By analogy to how the other autotraits are treated, I argue that yes, it should be not-
Unpin
. The user can always implementUnpin
if desired.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's clear that
&UnsafeAliased<T>
carries aShared
tag, and that mutating through it is UB (assuming noUnsafeCell
is present). What's not clear is how retagging impacts extant sibling write-capable provenance.This very much gets into some undecided specifics to specify precisely, but some specifics are needed. Namely, if I do
is this guaranteed to be permitted? If it is, then IIUC,
&UnsafeAliased<T>
can protect the bytes such that writing to them would be UB, but must not retag them in such a way as to completely invalidate sibling write-capable provenance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea where existing siblings matter in your example.
In SB, each
as_mut
creates a new SRW child ofs
. Eachas_ref
creates a new SRO child. Both of these actions preserve existing SRW and SRO children ofs
.In TB,
as_mut
will just return the original provenance -- no retagging for!Unique
mutable references.as_ref
will create a read-only child that lives as long as there is no write.Your example doesn't even exploit any of that though. It would be allowed even if creating a new SRW or SRO child first killed all previously created children, since you are creating new pointer with calls to
as_mut
/as_ref
all the time. Did you mean to keep the firstas_mut
pointer around and use it again after theas_ref
?