Skip to content

Commit 3ea4165

Browse files
committed
Make BuildHasher const_trait
1 parent 1bcf9fa commit 3ea4165

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/core/src/hash/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
#![stable(feature = "rust1", since = "1.0.0")]
8787

8888
use crate::fmt;
89-
use crate::marker;
89+
use crate::marker::{self, Destruct};
9090

9191
#[stable(feature = "rust1", since = "1.0.0")]
9292
#[allow(deprecated)]
@@ -648,6 +648,7 @@ impl<H: ~const Hasher + ?Sized> const Hasher for &mut H {
648648
/// [`build_hasher`]: BuildHasher::build_hasher
649649
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
650650
#[stable(since = "1.7.0", feature = "build_hasher")]
651+
#[const_trait]
651652
pub trait BuildHasher {
652653
/// Type of the hasher that will be created.
653654
#[stable(since = "1.7.0", feature = "build_hasher")]
@@ -708,9 +709,10 @@ pub trait BuildHasher {
708709
/// );
709710
/// ```
710711
#[unstable(feature = "build_hasher_simple_hash_one", issue = "86161")]
711-
fn hash_one<T: Hash>(&self, x: T) -> u64
712+
fn hash_one<T: ~const Hash + ~const Destruct>(&self, x: T) -> u64
712713
where
713714
Self: Sized,
715+
Self::Hasher: ~const Hasher + ~const Destruct,
714716
{
715717
let mut hasher = self.build_hasher();
716718
x.hash(&mut hasher);
@@ -774,7 +776,8 @@ impl<H> fmt::Debug for BuildHasherDefault<H> {
774776
}
775777

776778
#[stable(since = "1.7.0", feature = "build_hasher")]
777-
impl<H: Default + Hasher> BuildHasher for BuildHasherDefault<H> {
779+
#[rustc_const_unstable(feature = "const_hash", issue = "none")]
780+
impl<H: ~const Default + Hasher> const BuildHasher for BuildHasherDefault<H> {
778781
type Hasher = H;
779782

780783
fn build_hasher(&self) -> H {

0 commit comments

Comments
 (0)