refactor(allocator/fixed-size): return Result from allocation instead of panicking#17022
Conversation
camc314
left a comment
There was a problem hiding this comment.
I didn't mark this as breaking as I don't believe FixedSizeAllocator is public
There was a problem hiding this comment.
Pull request overview
This PR refactors the fixed-size allocator to return a Result from allocation instead of panicking directly, making error handling more explicit while maintaining backward compatibility through immediate unwrapping at call sites. The change introduces a new AllocError type that captures allocation layout information for better error reporting.
Key Changes
- Introduced
AllocErrorstruct withDisplayandErrortrait implementations for descriptive allocation failure messages - Converted
FixedSizeAllocator::new()totry_new()returningResult<Self, AllocError> - Updated panic documentation in the public API to reflect allocation failure conditions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_allocator/src/pool/mod.rs | Updated documentation for the public get() method to document panic conditions for fixed-size allocator allocation failures |
| crates/oxc_allocator/src/pool/fixed_size.rs | Added AllocError type, refactored new() to try_new() returning Result, and removed direct panic via alloc::handle_alloc_error() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #17022 will not alter performanceComparing Summary
Footnotes
|
4f715fe to
477d0fd
Compare
49217f5 to
efa712a
Compare
efa712a to
63c3286
Compare
overlookmotel
left a comment
There was a problem hiding this comment.
Pushed a nit commit. Otherwise, all good.

No description provided.