Repository navigation
Conversation
|
|
|
this is in line with the discussion on Zulip. cc @rust-lang/libs-ping - should we FCP this? I think this is mostly formalising the semantics we already wanted but may be worth doing regardless |
|
idk about fcp, but i think this should be backported to beta |
21a7dfe to
993247b
Compare
|
Well, 1.100 is out now, and we're definitely not doing a point release for a doc backport. |
bold of you to assume that the version won't need a point release. but anyway yeah ofc, hence why i only suggested beta ^^ If only we could make doc.rust-lang.org default to nightly 🙃 |
|
I think this should definitely be FCP'd, it's making a material change to the contract of a now-stable trait. That's not to say it's likely to be a breaking change for implementers in practice, but it is changing a stable and very subtle contract, so more scrutiny is good. If this is obviously what everyone meant all along when stabilizing the trait, then it should be an easy FCP. But also, everything to do with allocator contract has been extremely subtle, so let's not be too hasty IMO. |
993247b to
eea9a39
Compare
|
ty :D |
eea9a39 to
8320498
Compare
We have another 4/3 of a month until the next release cycle. As long as this doesn't get stuck in proposed-fcp for 3 months despite no concerns (like one of my other PRs, which is still waiting), i don't see any downside to doing one here. |
342ced6 to
50562bb
Compare
|
@rfcbot fcp merge libs |
|
@nia-e has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/libs-ping: FCP proposed for libs, please feel free to register concerns. |
50562bb to
61febb6
Compare
This comment has been minimized.
This comment has been minimized.
249f34b to
cbf59ab
Compare
This comment has been minimized.
This comment has been minimized.
ac167ca to
80d9e3a
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
80d9e3a to
2c4b6f2
Compare
|
Alright, as per this discussion, I've removed the concepts of "currently allocated" and "invalidating" from the allocator contract and replaced them with talking about ownership directly, as they do not make sense in situations where ownership is passed through a cyclic chain of allocators (unless "memory block" != "block of memory"). The word "invalidate" is still used the way we usually use it: something becomes invalid at a language level. |
ee43e64 to
b2724ee
Compare
This comment has been minimized.
This comment has been minimized.
6887fdd to
6b947ae
Compare
6b947ae to
734ef2e
Compare
734ef2e to
e6fadb3
Compare
View all comments
Discussion on zulip
The disjointness requirement is incorrect (for any reasonable interpretation), and makes it unsound to compose allocators. We really want our types to be composable; allocators handing out memory acquired from other allocators makes a lot of sense.
The problem is that such "wrapper allocators" can be composed into a cycle, in which case they end up handing out memory from themselves, in a manner that other wrappers can observe is non-disjoint (see the example from @theemathas in the zulip thread).
This PR removes the disjointness part of the docs and replaces it with an overall contract about ownership: An allocator generally cannot return the same memory twice, but not because it overlaps; instead, the argument is that it lacks ownership of the memory it has already returned, similar to how we already documented that it cannot modify the memory it has returned; that memory is owned by the caller.
The ownership system also implies memory disjointness in cases where you can observe two memory blocks being exclusively owned; see #165921 (comment). This is necessary for
&mutandcopy_nonoverlappingto be sound to use on them, e.g. throughBox.As a result of this rephrasing, it is okay for cyclically composed allocators to return the same memory reentrantly, because they have transferred ownership of it to themselves (the caller), and are thus free to pass it on, as if it was from any other allocator.
cc @theemathas
r? @nia-e