-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Separate dealloc
from AllocRef
into DeallocRef
#69065
Conversation
I am still somewhat hesitant to merge this since I feel that the use cases are limited (basically just cc @rust-lang/libs |
The current name sounds like it only supports deallocation, not allocation. |
I have two objections to this PR, and feel it should not land as-is or at all:
The only reason to have separate traits is to have separate types that implement them: (If But how do you create that Just passing two parameters Or maybe there could be some kind of of "downgrade" operation to convert a value of Either way, PR is useless without some other APIs that don’t even have a sketch of a design proposal. This makes significant API complexity: two traits, an associated type to convert between them, corresponding constructors on containers. All only relevant if:
Everyone would else still need to deal with the complexity of separate traits when reading https://doc.rust-lang.org/std/alloc/ By the way, is anyone involved here actually using an allocator like this? How did we get here? A separate |
☔ The latest upstream changes (presumably #69666) made this pull request unmergeable. Please resolve the merge conflicts. |
As there are too many unresolved question as pointed out by @SimonSapin I'll close this. For further discussion on this topic, I guess the WG repository is better suited. |
This creates a new trait
DeallocRef
, makes it a supertrait ofAllocRef
and movesdealloc
into the new trait.With this way, it is possible to have allocators, which cannot allocate new memory, but free old one. This comes in handy when dealing with FFI interfaces, which returns a pointer and a
free
function.For a full discussion on this topic please see rust-lang/wg-allocators#9
r? @Amanieu
closes rust-lang/wg-allocators#9