Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions compiler/rustc_data_structures/src/fx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,18 @@ macro_rules! define_stable_id_collections {
pub type $entry_name<'a, T> = $crate::fx::IndexEntry<'a, $key, T>;
};
}

pub mod default {
use super::{FxBuildHasher, FxHashMap, FxHashSet};

// FIXME: These two functions will become unnecessary after
// <https://github.com/rust-lang/rustc-hash/pull/63> lands and we start using the corresponding
// `rustc-hash` version. After that we can use `Default::default()` instead.
pub const fn fx_hash_map<K, V>() -> FxHashMap<K, V> {
FxHashMap::with_hasher(FxBuildHasher)
}

pub const fn fx_hash_set<V>() -> FxHashSet<V> {
FxHashSet::with_hasher(FxBuildHasher)
}
}
2 changes: 2 additions & 0 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#![feature(assert_matches)]
#![feature(auto_traits)]
#![feature(cfg_select)]
#![feature(const_default)]
#![feature(const_trait_impl)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(extend_one)]
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_data_structures/src/unord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::hash::Hash;
use std::iter::{Product, Sum};
use std::ops::Index;

use rustc_hash::{FxHashMap, FxHashSet};
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
use rustc_macros::{Decodable_NoContext, Encodable_NoContext};

use crate::fingerprint::Fingerprint;
Expand Down Expand Up @@ -241,10 +241,10 @@ pub struct UnordSet<V: Eq + Hash> {

impl<V: Eq + Hash> UnordCollection for UnordSet<V> {}

impl<V: Eq + Hash> Default for UnordSet<V> {
impl<V: Eq + Hash> const Default for UnordSet<V> {
#[inline]
fn default() -> Self {
Self { inner: FxHashSet::default() }
Self { inner: FxHashSet::with_hasher(FxBuildHasher) }
}
}

Expand Down Expand Up @@ -438,10 +438,10 @@ pub struct UnordMap<K: Eq + Hash, V> {

impl<K: Eq + Hash, V> UnordCollection for UnordMap<K, V> {}

impl<K: Eq + Hash, V> Default for UnordMap<K, V> {
impl<K: Eq + Hash, V> const Default for UnordMap<K, V> {
#[inline]
fn default() -> Self {
Self { inner: FxHashMap::default() }
Self { inner: FxHashMap::with_hasher(FxBuildHasher) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub struct DisambiguatorState {
}

impl DisambiguatorState {
pub fn new() -> Self {
pub const fn new() -> Self {
Self { next: Default::default() }
}

Expand Down
Loading
Loading