Skip to content

Refactored allocator-api2 reexports #171

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

Merged
merged 3 commits into from
Jul 10, 2025

Conversation

bavshin-f5
Copy link
Member

See individual commits.

unsize_box is a temporary solution, I'll revert and properly reexport it once I have time to send a patch to the upstream project.

@bavshin-f5 bavshin-f5 requested review from xeioex and Copilot July 9, 2025 05:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR centralizes and cleans up allocator-api2 reexports by introducing a dedicated collections module, adjusting allocator exports, and updating associated imports and examples.

  • Added a top-level collections module to reexport collection types from allocator-api2.
  • Updated internal core imports and example code to use the new collections paths.
  • Refactored allocator reexports (moved Global, narrowed boxed export to Box) and added a custom unsize_box macro.
  • Enhanced Cargo.toml with a new serde feature flag for serialization support.

Reviewed Changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib.rs Added pub mod collections to expose the new collections module.
src/core/string.rs Switched imports to crate::collections::{TryReserveError, Vec}.
src/core/mod.rs Removed pub mod rbtree and its pub use in favor of reexports from the collections module.
src/collections/mod.rs Introduced collections module reexporting TryReserveError, Vec, and RbTreeMap.
src/allocator.rs Adjusted Global and Box exports, removed broad collections/vec exports, and added unsize_box.
examples/shared_dict.rs Updated example imports to use ngx::collections::RbTreeMap.
Cargo.toml Added serde feature for allocator-api2/serde.
Comments suppressed due to low confidence (4)

src/core/mod.rs:3

  • Removing the rbtree export from core is a breaking API change. Consider documenting this in the CHANGELOG or providing a deprecation path for downstream users.
pub mod slab;

src/allocator.rs:98

  • The new unsize_box macro is public API—consider adding unit tests or examples to validate its behavior and edge cases.
#[macro_export]

Cargo.toml:45

  • [nitpick] Indentation for the serde feature block differs from the surrounding feature definitions. Align formatting with alloc and std blocks for consistency.
serde = [

Currently it only reexports serde support for allocator-api2 types.
In the future we can start implementing Serialize/Deserialize for our
own types.
Protect allocator_api2::alloc::Global reexport with "alloc".
Reimplement allocator_api2::unsize_box, as the original macro is not
reexportable.
Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@bavshin-f5 bavshin-f5 merged commit 713074f into nginx:master Jul 10, 2025
15 checks passed
@bavshin-f5 bavshin-f5 deleted the alloc-reexports branch July 10, 2025 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants