Skip to content

Hashbrown fails to compile if 0.14.x and 0.15.x are in the same project, only one with the nightly feature #564

@orlp

Description

@orlp

If a project (most likely indirectly through dependencies) depends on both version 0.14.x and 0.15.x of hashbrown, and only one of the two dependencies has the nightly feature flag set, the project will fail to compile due to using the allocator_api without enabling the unstable feature for it:

error[E0658]: use of unstable library feature 'allocator_api'
    --> /Users/orlp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.14.5/src/raw/mod.rs:4329:23
     |
4329 |                 alloc.deallocate(ptr, layout);
     |                       ^^^^^^^^^^
     |
     = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
     = help: add `#![feature(allocator_api)]` to the crate attributes to enable
     = note: this compiler was built on 2024-10-02; consider upgrading it if it is out of date

This can be reproduced by making a clean new project and adding the following two lines to Cargo.toml:

hashbrown_14 = { package = "hashbrown", version = "=0.14.5", features = [] }
hashbrown_15 = { package = "hashbrown", version = "=0.15.0", features = ["nightly"] }

If it's just one of the two the project compiles fine, regardless of the nightly feature flag. If neither or both have the nightly feature flag everything compiles fine as well. However if one has the nightly feature flag and the other does not, the project doesn't compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions