Skip to content

Put the Allocator impls behind allocator-api and lower the MSRV to 1.88 - #3

Merged
clabby merged 1 commit into
mainfrom
allocator-api-feature
Nov 14, 2026
Merged

clabby merged 1 commit into
mainfrom
allocator-api-feature

Conversation

@clabby

@clabby clabby commented Nov 14, 2026

Copy link
Copy Markdown
Owner

The standard library's Allocator trait became stable in Rust 1.100, and that set the crate's minimum Rust version. This PR moves the trait behind a feature, so the rest of the library builds on older compilers.

  • allocator-api feature. The Allocator implementations for Bcmalloc and Heap, with their Backend plumbing, move into src/allocator.rs. That module compiles only with the new feature, which is off by default. Clippy's incompatible_msrv lint is allowed in that module, with a reason.
  • MSRV 1.88. bcmalloc declares rust-version = "1.88". The older toolchains failed on let chains and on const Cell::get, both stable since 1.88. The internal crates (C library, benchmarks, bench data) keep the workspace's 1.100.
  • testing helper. The helper that zeroes slices used Box::new_zeroed_slice, which needs 1.92. It now allocates with alloc_zeroed and hands the memory to Box::from_raw.
  • Tests and docs. Tests and doc examples that use the trait are gated on the feature: the README and Bcmalloc examples use hidden #[cfg] lines. The flush_thread test now allocates through GlobalAlloc, so it runs without the feature. The README badge and the Limits section give 1.88, and say that allocator-api needs 1.100.
  • just msrv and CI. The new recipe runs cargo hack --feature-powerset --exclude-features allocator-api --rust-version check --lib, which installs the 1.88 toolchain if it is missing. CI runs it as a new "Minimum Rust version" job.

Breaking: code that used Vec::new_in(&allocator) or Box::new_in with bcmalloc needs features = ["allocator-api"].

Checks run locally:

  • just lint, just lint-docs, just hack (now 20 combinations), and just msrv on 1.88 (10 combinations).
  • Tests with every feature (132) and with default features (111).
  • Doc tests with and without the feature.
  • The allocator and heap tests under Miri with strict provenance.

The standard library's Allocator trait became stable in Rust 1.100, which set
the crate's minimum version. Its implementations for Bcmalloc and Heap now
live in the allocator module, compiled only with the new allocator-api
feature, and the rest of the library builds on Rust 1.88, where let chains
and const Cell::get became stable. The testing helper that zeroes slices
allocates them with alloc_zeroed instead of Box::new_zeroed_slice (1.92).

The library declares rust-version 1.88; the internal crates keep the
workspace's 1.100. just msrv checks every feature combination but
allocator-api on the declared version through cargo-hack, which installs the
toolchain, and CI runs it.
@clabby
clabby merged commit e7a6d42 into main Nov 14, 2026
12 of 13 checks passed
@clabby
clabby deleted the allocator-api-feature branch November 14, 2026 21:03
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.

1 participant