Skip to content

Commit

Permalink
Merge pull request #586 from RalfJung/rustc_const_stable_indirect
Browse files Browse the repository at this point in the history
mark const fn constructors as rustc_const_stable_indirect
  • Loading branch information
Amanieu authored Nov 13, 2024
2 parents e3311d9 + 855feb0 commit 1baa359
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")]
Expand Down
2 changes: 2 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ impl<K, V, S> HashMap<K, V, S> {
/// 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,
Expand Down Expand Up @@ -538,6 +539,7 @@ impl<K, V, S, A: Allocator> HashMap<K, V, S, A> {
/// 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,
Expand Down
2 changes: 2 additions & 0 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ impl<T> RawTable<T, Global> {
/// 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,
Expand All @@ -702,6 +703,7 @@ impl<T, A: Allocator> RawTable<T, A> {
/// 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,
Expand Down
2 changes: 2 additions & 0 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ impl<T, S> HashSet<T, S, Global> {
/// 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),
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 1baa359

Please sign in to comment.