rustc_arena: handle recursive allocation, don't trust size_hint#79154
rustc_arena: handle recursive allocation, don't trust size_hint#79154tgnottingham wants to merge 1 commit intorust-lang:masterfrom
Conversation
In `DroplessArena::alloc_from_iter`, handle allocating from iterators whose `next` calls may themselves allocate on the arena. Also, do not trust the iterator's `size_hint` implementation for correctness. These changes were already made for `TypedArena` in rust-lang#67003.
|
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
|
I attempted to implement a performance mitigation to avoid the extra copying in certain cases, but it didn't work out. If an exact size hint was available, the mitigation would copy into an appropriately-sized It managed to worsen performance, probably due to a combination of complexity, that it doesn't avoid allocating sometimes like the |
|
Is this PR a good idea? First, next allocating doesn't cause any issues for the dropless arena. We do Regarding the second point, if cc @bugadani |
|
Ah, okay. I see I missed the critical difference as to why this was safe for With Nevermind then. :) |
Yup, that's the logic! |
In
DroplessArena::alloc_from_iter, handle allocating from iteratorswhose
nextcalls may themselves allocate on the arena. Also, do nottrust the iterator's
size_hintimplementation for correctness.These changes were already made for
TypedArenain #67003.