-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking issue for the GlobalAlloc trait and related APIs #49668
Copy link
Copy link
Closed
Labels
A-allocatorsArea: Custom and system allocatorsArea: Custom and system allocatorsB-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Metadata
Metadata
Assignees
Labels
A-allocatorsArea: Custom and system allocatorsArea: Custom and system allocatorsB-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
PR #49669 adds a
GlobalAlloctrait, separate fromAlloc. This issue track the stabilization of this trait and some related APIs, to provide the ability to change the global allocator, as well as allocating memory without abusingVec::with_capacity+mem::forget.Defined in or reexported from the
std::allocmodule:Update: below is the API proposed when this issue was first opened. The one being stabilized is at #49668 (comment).
Details
CC @rust-lang/libs, @glandium
Unresolved questions or otherwise blocking
Globaltype.GlobalAllocator?Name of theRenamed toVoidtype. Lower-casevoidwould match C (our*mut voidis very close to C’svoid*type), but violates the convension of camel-case for non-primitive types. ButVoidin camel-case is already the name of an empty enum (not an extern type like here) in a popular crate. (An extern type is desirable so that<*mut _>::offsetcannot be called without first casting to another pointer type.) Maybe call itOpaque?Unknown?Opaque.TakingLayoutby reference, or making itCopyAlloc methods should take layout by reference #48458.Copy: Implement Copy for std::alloc::Layout #50109Not to be required by this trait since glibc and Windows do not support this.GlobalAlloc::owns: Alloc: Add owns method #44302 proposes making it required for allocators to be able to tell if it “owns” a given pointer.Settle semantics of layout "fit" and other safety conditions.Without anusable_sizemethod (for now), the layout passed to dealloc must be the same as was passed to alloc. (Same as withAlloc::usable_size’s default impl returning(layout.size(), layout.size()).)AnReplace {Alloc,GlobalAlloc}::oom with a lang item. #50144oommethod is part ofGlobalAllocso that implementation-specific printing to stderr does not need to be part of liballoc and instead goes through#[global_allocator], but this does not really belong in theGlobalAlloctrait. Should another mechanism like#[global_allocator]be added to have pluggable OOM handling?Not proposed (yet) for stabilization
AlloctraitLayoutmethodsAllocErrtypeWe’re not ready to settle on a design for collections generic over the allocation type. Discussion of this use case should continue on the tracking issue for the
Alloctrait: #32838.