-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Restrict Allocator
impl to &'static A
#94069
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
r? @yaahc |
This comment has been minimized.
This comment has been minimized.
8c21c1b
to
cdf8314
Compare
Arbitrary &'_ Allocators cannot satisfy the safety requirement that memory blocks returned by an Allocator must remain valid until the instance and all of its clones are dropped. &'static Allocators can still satisfy this safety requirement because their lifetime ensures that they are never moved or dropped.
cdf8314
to
9c24afd
Compare
I think this is @rustbot label -T-compiler +t-libs |
I'm reassigning this PR because I'm taking a break from the review rotation for a little while. Thank you for your patience. r? rust-lang/libs-api |
Couldn't the documentation just be updated to clarify that the allocated blocks are only valid for |
#94114 has a more extensive change that pursues a similar goal. |
Triage: |
This PR is meant as a minimal fix to unsoundness in the changed impl. The other PR is a more extensive change that provides more flexibility, so if we'd like to go forward with #94114 then I can close this one. |
Ping from triage. @djkoloski looks like your other PR has more traction, do you want to close this one? |
Note that we did not go forward with the other PR. We should probably focus on merging this and closing the soundness hole. |
I'm nominating this for team discussion. The question is whether to maintain the current guarantee that
which would require allocators to have @rustbot label +I-libs-api-nominated |
Closing in favor of #118890. |
Arbitrary
&'_ Allocator
s cannot satisfy the safety requirement thatmemory blocks returned by an
Allocator
must remain valid until theinstance and all of its clones are dropped.
&'static Allocator
s canstill satisfy this safety requirement because their lifetime ensures
that they are never moved or dropped.
See #90822 and this comment in particular for additional context.