Closed yanchith closed 2 years ago
@yanchith thanks for filing an issue! Yes, I think that Bump::grow
should take a new layout so that it can handle the new alignment requirements (if any) as well.
Would you be up for making these changes and sending a pull request?
If you mean just the lazy version of returning AllocError
, if the new alignment isn't automatically satisfied, then sure! I think this might also apply to Bump::shrink
, so I'll look into that as well. I'll be afk for the rest of the week, but I think I could send the PR afterwards.
Btw are you privy to what lead to the decision of letting the caller request a different alignment when growing/shrinking in the allocator api?
If you mean just the lazy version of returning
AllocError
, if the new alignment isn't automatically satisfied, then sure!
That's a good place to start, but it shouldn't be hard to add the more general support (just call alloc
again).
Btw are you privy to what lead to the decision of letting the caller request a different alignment when growing/shrinking in the allocator api?
I am not. Might be worth bringing up with the wg-allocators
folks, if you feel like going down the rabbit hole.
FYI I asked around and got pointed here regarding the design history: https://github.com/rust-lang/wg-allocators/issues/5
I think we can now close this - feel free reopen if you want this for documentation.
Was doing some relaxing reading of bumpalo's source (commit https://github.com/fitzgen/bumpalo/commit/b22416cfae42ad3c13814c5c97364725196f07ab) when I found the following:
Allocator::grow
receivesnew_layout
, but the Allocator trait impl in bumpalo only passesnew_size
toBump::grow
.What happens, if
Allocator::grow
gets called with a new layout that has a greater alignment requirement? Docs ofAllocator::grow
say:So I guess it would be ok to return
AllocError
if the alignment requirements got stricter with the new layout, but the trait impl currently ignores that.I also could be missing something 😂