From ad8a0bdbaa646ff309e9dec08900f6043591a764 Mon Sep 17 00:00:00 2001 From: Pedro Nobre Date: Mon, 14 Sep 2026 03:25:26 +0100 Subject: [PATCH 1/3] ci: add testing and benchmarking steps with no default features --- .github/workflows/rust.yml | 8 ++++++++ Cargo.lock | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 72614fa..2a83694 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -61,6 +61,10 @@ jobs: if: ${{ !matrix.no_std }} run: cargo test --verbose + - name: Cargo test no default features + if: matrix.nightly + run: cargo test --verbose --no-default-features + - name: Cargo test all features if: matrix.nightly run: cargo test --verbose --all-features @@ -69,6 +73,10 @@ jobs: if: matrix.nightly run: cargo doc --all-features --verbose + - name: Cargo bench no default features + if: matrix.nightly + run: cargo clean && cargo bench --verbose --no-default-features + - name: Cargo bench all features if: matrix.nightly run: cargo clean && cargo bench --verbose --all-features diff --git a/Cargo.lock b/Cargo.lock index 08d6e29..a2ff25d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,12 @@ dependencies = [ "cc", ] +[[package]] +name = "allocator-api2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c880a97d28a3681c0267bd29cff89621202715b065127cd445fa0f0fe0aa2880" + [[package]] name = "anes" version = "0.1.6" @@ -639,6 +645,7 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" name = "smallvec" version = "2.0.0-alpha.13" dependencies = [ + "allocator-api2", "arbitrary", "borsh", "bytes", From 339f01f1e625d91c5b3c8d23a1c1ecb61a1addce Mon Sep 17 00:00:00 2001 From: Pedro Nobre Date: Mon, 14 Sep 2026 03:48:22 +0100 Subject: [PATCH 2/3] fix: fixed allocator usage if not under `allocator-api2` feature --- Cargo.toml | 2 +- src/lib.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4b3c7d5..49759a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ debug = false strip = true [features] -default = ["allocator-api2"] +default = [] internals = [] may_dangle = [] rayon = ["std", "dep:rayon"] diff --git a/src/lib.rs b/src/lib.rs index 6197324..2c222be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,15 +5,14 @@ // except according to those terms. #![doc = include_str!("../README.md")] -#![no_std] +#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(feature = "specialization", allow(incomplete_features))] #![cfg_attr(feature = "specialization", feature(specialization, trusted_len))] #![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))] +#![cfg_attr(not(feature = "allocator-api2"), feature(allocator_api))] extern crate alloc; -#[cfg(feature = "std")] -extern crate std; #[cfg(feature = "borsh")] mod borsh; @@ -33,7 +32,7 @@ mod specialization; mod taggedlen; #[cfg(not(feature = "allocator-api2"))] -use alloc::{ +use alloc::alloc::{ Allocator, Global }; From 84ab6a7d108736d92d9390c7f202dcc200625db5 Mon Sep 17 00:00:00 2001 From: Pedro Nobre Date: Mon, 14 Sep 2026 03:53:50 +0100 Subject: [PATCH 3/3] fix: re-enable 'allocator-api2' feature by default (pushed by mistake under testing) Signed-off-by: Pedro Nobre --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 49759a3..4b3c7d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ debug = false strip = true [features] -default = [] +default = ["allocator-api2"] internals = [] may_dangle = [] rayon = ["std", "dep:rayon"]