Skip to content

Commit e1f6b0e

Browse files
committed
Auto merge of #96 - jethrogb:patch-1, r=Amanieu
Don't use std crate at all Fixes #95 We're running into rust-lang/rust#54010 but I don't think it's a problem.
2 parents 03da6ab + 0978366 commit e1f6b0e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ keywords = ["hash", "no_std", "hashmap", "swisstable"]
1010
categories = ["data-structures", "no-std"]
1111
exclude = [".travis.yml", "bors.toml", "/ci/*"]
1212
edition = "2018"
13+
build = "build.rs"
1314

1415
[dependencies]
1516
# For external trait impls
@@ -21,6 +22,9 @@ core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core
2122
compiler_builtins = { version = "0.1.2", optional = true }
2223
alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" }
2324

25+
[build-dependencies]
26+
autocfg = "0.1.4"
27+
2428
[dev-dependencies]
2529
lazy_static = "1.2"
2630
rand = "0.5.1"

build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let nightly = std::env::var_os("CARGO_FEATURE_NIGHTLY").is_some();
3+
let has_stable_alloc = || autocfg::new().probe_rustc_version(1, 36);
4+
5+
if nightly || has_stable_alloc() {
6+
autocfg::emit("has_extern_crate_alloc")
7+
}
8+
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#[macro_use]
3030
extern crate std;
3131

32-
#[cfg(feature = "nightly")]
32+
#[cfg(has_extern_crate_alloc)]
3333
#[cfg_attr(test, macro_use)]
3434
extern crate alloc;
35-
#[cfg(not(feature = "nightly"))]
35+
#[cfg(not(has_extern_crate_alloc))]
3636
extern crate std as alloc;
3737

3838
#[macro_use]

0 commit comments

Comments
 (0)