diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 13742ad273b59..79a0486c8c58b 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -992,8 +992,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { // `extern` functions, and these have no way to get marked `const`. So instead we // use `rustc_const_(un)stable` attributes to mean that the intrinsic is `const` if self.ccx.is_const_stable_const_fn() || tcx.is_intrinsic(callee) { - self.check_op(ops::FnCallUnstable(callee, None)); - return; + if !super::rustc_allow_const_fn_unstable(tcx, caller, sym::any) { + self.check_op(ops::FnCallUnstable(callee, None)); + return; + } } } trace!("permitting call"); diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 39e94902cfe5f..de4d3f02b77e3 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -279,7 +279,18 @@ impl HashMap { /// ``` #[inline] #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] - #[rustc_const_unstable(feature = "const_collections_with_hasher", issue = "102575")] + #[cfg_attr( + bootstrap, + rustc_const_unstable(feature = "const_collections_with_hasher", issue = "102575") + )] + #[cfg_attr( + not(bootstrap), + rustc_const_stable( + feature = "const_collections_with_hasher", + since = "CURRENT_RUSTC_VERSION" + ) + )] + #[rustc_allow_const_fn_unstable(any)] pub const fn with_hasher(hash_builder: S) -> HashMap { HashMap { base: base::HashMap::with_hasher(hash_builder) } } diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 8bc5960829066..7dff64198b8e2 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -369,7 +369,18 @@ impl HashSet { /// ``` #[inline] #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] - #[rustc_const_unstable(feature = "const_collections_with_hasher", issue = "102575")] + #[cfg_attr( + bootstrap, + rustc_const_unstable(feature = "const_collections_with_hasher", issue = "102575") + )] + #[cfg_attr( + not(bootstrap), + rustc_const_stable( + feature = "const_collections_with_hasher", + since = "CURRENT_RUSTC_VERSION" + ) + )] + #[rustc_allow_const_fn_unstable(any)] pub const fn with_hasher(hasher: S) -> HashSet { HashSet { base: base::HashSet::with_hasher(hasher) } } diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index d06012c14dcfe..66f4439cb6a49 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -297,6 +297,7 @@ #![feature(no_sanitize)] #![feature(platform_intrinsics)] #![feature(prelude_import)] +#![feature(rustc_allow_const_fn_unstable)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] #![feature(staged_api)] @@ -308,6 +309,7 @@ // // Library features (core): // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(const_collections_with_hasher))] #![feature(char_internals)] #![feature(core_intrinsics)] #![feature(core_io_borrowed_buf)] @@ -388,7 +390,6 @@ // // Only for const-ness: // tidy-alphabetical-start -#![feature(const_collections_with_hasher)] #![feature(const_hash)] #![feature(const_io_structs)] #![feature(const_ip)]