Closed zakarumych closed 1 year ago
Apparently this would require bumping MSRV to 1.63
How do you suggest enabling "nightly" in allocator-api2
?
I found a problem with the approach in allocator-api2
- replacing stable mirror API with unstable API re-export with a feature makes all dependent crates manually enable unstable feature(allocator_api)
.
If some other crate would enable "allocator-api2/nightly"
feature and not enable "bumpalo/nightly"
then bumpalo
won't compile.
So I changed it.
allocator-api2
is now always stable mirror and crates choose from using allocator-api2
and alloc
crate, picking alloc
when they enable nightly Rust feature allocator_api
.
I tried to forward "nightly" feature back from allocator-api2
into bumpalo
, but it requires other unstable features.
It was made like this originally.
However this doesn't work since user would have to enable unstable #![feature(allocator_api)] if any crate enables "nightly" in allocator-api2.
I found no way to enable #![feature(allocator_api)] conditionally based on allocator-api2 features. Tried using macro, but inner macro attributes are unstable. It's also impossible to get custom cfg flag from dependency.
I tried different route and make blanket impls of allocator_api2::Allocator for core::alloc::Allocator types. This way allocators that implement core::alloc::Allocator would be compatible. Allocators that use allocator-api2 would implement core::alloc::Allocator with "nightly" feature as well.
Unfortunately I got stuck on conflicting impls for references. Tried using specialization feature to resolve the conflict, but with no luck.
So currently PR is blocked on resolving this issue. I'll return to it later when I have free time again.
Ok. I think it should be consistent and usable now.
allocator-api2
re-exports core
, alloc
and std
with "nightly" feature.
Other crates that use it should have means to enable #![feature(allocator_api)]
to avoid compilation errors on nightly channel.
bumpalo
does. Even if direct dependent crates won't enable it since it doesn't care about nightly, indirect dependent crates would be able to enable it if they encounter compilation error when some other crate in the tree enable "allocator-api2/nightly".
It does look like this needs a little rebase to deal with CHANGELOG.md
conflicts, and in that case can you also remove the now-obsolete bits in the changelog about the "nightly" feature? I was going to do that myself, but since it needs a rebase anyways...
It's ready for merge now
@fitzgen can you provide ETA for next release with this?
Published!
This change allows to use mirror of the allocator-api on stable channel. Types imported from
allocator-api2
are reexports fromcore
andalloc
crates when"nightly"
feature is enabled. Otherwiseallocator-api2
defines types to mimic unstablecore
andalloc
types and functions, stable stuff is re-exported.The goal is to add support for
allocator-api2
into as many crates as possible. Thebumpalo
crate is first on the list.