Skip to content

feat: expand allocator support in specialization.rs (#710) - #759

Open
Ankit-cs wants to merge 2 commits into
servo:v2from
Ankit-cs:fix/710-allocator-specialization
Open

Ankit-cs wants to merge 2 commits into
servo:v2from
Ankit-cs:fix/710-allocator-specialization

Conversation

@Ankit-cs

@Ankit-cs Ankit-cs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR addresses the allocator expansion task for specialization.rs (#710).

The following specialization traits have been updated to be generic over Heap: Allocator rather than being hardcoded to the Global allocator:

  • SpecFromElem (for both Clone and Copy item implementations)
  • SpecFromSlice (for both Clone and Copy item implementations)

Note on SpecFromIterator:
As discussed in the main allocator tracking issue by @bolshoytoster and @alejandro-vaz, expanding FromIterator to custom allocators would awkwardly require A: Allocator + Default. To stay consistent with standard library patterns, SpecFromIterator was intentionally left untouched and remains bound to Global.

Related Issue

Fixes #710

@Ankit-cs

Ankit-cs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

lookin for feedback for the above pr @alejandro-vaz

Comment thread benches/bench.rs
const SPILLED_SIZE: usize = 100;

trait Vector<T>: for<'a> From<&'a [T]> + Extend<T> + FromIterator<T> {
/// A trait defining common vector operations, implemented by vectors taking items from a slice of lifetime 'slice.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove the doc comment, we really aren't reading them at all

we will figure out in rc what doc comments we really need

Comment thread fuzz/fuzz_targets/main.rs
// Bounded `usize` between `0..=CAP`
impl<'a, const CAP: usize> Arbitrary<'a> for Bounded<usize, CAP> {
impl<'data, const CAP: usize> Arbitrary<'data> for Bounded<usize, CAP> {
/// Generates an arbitrary bounded usize value using the unstructured fuzzing data of lifetime 'data.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

Comment thread fuzz/fuzz_targets/main.rs
where T: Arbitrary<'data>
{
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
/// Generates an arbitrary bounded vector by consuming items from the unstructured data stream of lifetime 'data.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

above

Comment thread tests/main.rs
fn splice_reserve_panic() {
struct CountDrop<'a>(&'a Cell<usize>);
/// A helper struct that increments a counter when dropped, bound to the cell's lifetime 'cell.
struct CountDrop<'cell>(&'cell Cell<usize>);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

change this to 'valid

Comment thread tests/main.rs
struct DropCounter<'cell>(&'cell Cell<i32>);

impl<'a> Drop for DropCounter<'a> {
impl<'cell> Drop for DropCounter<'cell> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

and this

Comment thread tests/main.rs
#[test]
fn splice_reserve_panic() {
struct CountDrop<'a>(&'a Cell<usize>);
/// A helper struct that increments a counter when dropped, bound to the cell's lifetime 'cell.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no doc comment

Comment thread tests/main.rs
#[test]
fn into_iter_drop() {
struct DropCounter<'a>(&'a Cell<i32>);
/// A helper struct that increments a counter when dropped, bound to the cell's lifetime 'cell.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

neither

@alejandro-vaz

Copy link
Copy Markdown
Collaborator

also half of the checks fail

@Ankit-cs

Ankit-cs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Ooh sorry for that I will to solve this fully by tomorrow morning and make sure every checks passes

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.

allocator expansion for specialization.rs

2 participants