diff --git a/src/lib.rs b/src/lib.rs index a2d0d03b8..c4a0532ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,7 @@ strict_provenance_lints ) )] +#![cfg_attr(feature = "rustc-dep-of-std", feature(rustc_attrs))] #![allow( clippy::doc_markdown, clippy::module_name_repetitions, @@ -52,6 +53,7 @@ pub enum DefaultHashBuilder {} extern crate std; #[cfg_attr(test, macro_use)] +#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))] extern crate alloc; #[cfg(feature = "nightly")] diff --git a/src/map.rs b/src/map.rs index 1969bff54..c373d5958 100644 --- a/src/map.rs +++ b/src/map.rs @@ -453,6 +453,7 @@ impl HashMap { /// map.insert(1, 2); /// ``` #[cfg_attr(feature = "inline-more", inline)] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] pub const fn with_hasher(hash_builder: S) -> Self { Self { hash_builder, @@ -538,6 +539,7 @@ impl HashMap { /// map.insert(1, 2); /// ``` #[cfg_attr(feature = "inline-more", inline)] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] pub const fn with_hasher_in(hash_builder: S, alloc: A) -> Self { Self { hash_builder, diff --git a/src/raw/mod.rs b/src/raw/mod.rs index 1c4a5f42e..e4b25e166 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -677,6 +677,7 @@ impl RawTable { /// leave the data pointer dangling since that bucket is never written to /// due to our load factor forcing us to always have at least 1 free bucket. #[inline] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] pub const fn new() -> Self { Self { table: RawTableInner::NEW, @@ -702,6 +703,7 @@ impl RawTable { /// leave the data pointer dangling since that bucket is never written to /// due to our load factor forcing us to always have at least 1 free bucket. #[inline] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] pub const fn new_in(alloc: A) -> Self { Self { table: RawTableInner::NEW, diff --git a/src/set.rs b/src/set.rs index 819d01c66..d57390f67 100644 --- a/src/set.rs +++ b/src/set.rs @@ -465,6 +465,7 @@ impl HashSet { /// set.insert(2); /// ``` #[cfg_attr(feature = "inline-more", inline)] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] pub const fn with_hasher(hasher: S) -> Self { Self { map: HashMap::with_hasher(hasher), @@ -552,6 +553,7 @@ where /// set.insert(2); /// ``` #[cfg_attr(feature = "inline-more", inline)] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] pub const fn with_hasher_in(hasher: S, alloc: A) -> Self { Self { map: HashMap::with_hasher_in(hasher, alloc),