-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove common usage pattern from AllocRef
#69026
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
80ece94
to
25de80a
Compare
cc @rust-lang/libs @bors r+ |
📌 Commit 25de80a has been approved by |
Remove common usage pattern from `AllocRef` This removes the common usage patterns from `AllocRef`: - `alloc_one` - `dealloc_one` - `alloc_array` - `realloc_array` - `dealloc_array` Actually, they add nothing to `AllocRef` except a [convenience wrapper around `Layout` and other methods in this trait](https://doc.rust-lang.org/1.41.0/src/core/alloc.rs.html#1076-1240) but have a major flaw: The documentation of `AllocRefs` notes, that > some higher-level allocation methods (`alloc_one`, `alloc_array`) are well-defined on zero-sized types and can optionally support them: it is left up to the implementor whether to return `Err`, or to return `Ok` with some pointer. With the current API, `GlobalAlloc` does not have those methods, so they cannot be overridden for `liballoc::Global`, which means that even if the global allocator would support zero-sized allocations, `alloc_one`, `alloc_array`, and `realloc_array` for `liballoc::Global` will error, while calling `alloc` with a zeroed-size `Layout` could succeed. Even worse: allocating with `alloc` and deallocating with `dealloc_{one,array}` could end up with not calling `dealloc` at all! For the full discussion please see rust-lang/wg-allocators#18 r? @Amanieu
Rollup of 11 pull requests Successful merges: - #67695 (Added dyn and true keyword docs) - #68487 ([experiment] Support linking from a .rlink file) - #68554 (Split lang_items to crates `rustc_hir` and `rustc_passes`.) - #68937 (Test failure of unchecked arithmetic intrinsics in const eval) - #68947 (Python script PEP8 style guide space formatting and minor Python source cleanup) - #68999 (remove dependency on itertools) - #69026 (Remove common usage pattern from `AllocRef`) - #69027 (Add missing `_zeroed` varants to `AllocRef`) - #69058 (Preparation for allocator aware `Box`) - #69070 (Add self to .mailmap) - #69077 (Fix outdated doc comment.) Failed merges: r? @ghost
This removes the common usage patterns from
AllocRef
:alloc_one
dealloc_one
alloc_array
realloc_array
dealloc_array
Actually, they add nothing to
AllocRef
except a convenience wrapper aroundLayout
and other methods in this trait but have a major flaw: The documentation ofAllocRefs
notes, thatWith the current API,
GlobalAlloc
does not have those methods, so they cannot be overridden forliballoc::Global
, which means that even if the global allocator would support zero-sized allocations,alloc_one
,alloc_array
, andrealloc_array
forliballoc::Global
will error, while callingalloc
with a zeroed-sizeLayout
could succeed. Even worse: allocating withalloc
and deallocating withdealloc_{one,array}
could end up with not callingdealloc
at all!For the full discussion please see rust-lang/wg-allocators#18
r? @Amanieu