Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hashbrown to version 0.15, with changes that were blocked by that release #131178

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl CheckCfg {
] = self
.expecteds
.get_many_mut(VALUES)
.expect("unable to get all the check-cfg values buckets");
.map(|x| x.expect("unable to get all the check-cfg values buckets"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried updating this code in a few different ways but ultimately, this felt like the least-invasive way to make the change. I don't fully understand what this code is doing (and didn't really bother to figure out), so, someone else can change this code later if they find a better way of doing it.

Plus, a panic is an ICE anyway, so, if this causes any noticeable difference in behaviour it was a bug anyway.


for target in TARGETS
.iter()
Expand Down
10 changes: 5 additions & 5 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4

[[package]]
name = "addr2line"
Expand Down Expand Up @@ -42,9 +42,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"

[[package]]
name = "cc"
version = "1.1.22"
version = "1.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938"
dependencies = [
"shlex",
]
Expand Down Expand Up @@ -135,9 +135,9 @@ dependencies = [

[[package]]
name = "hashbrown"
version = "0.14.5"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
dependencies = [
"allocator-api2",
"compiler_builtins",
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ core = { path = "../core", public = true }
compiler_builtins = { version = "0.1.130" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
hashbrown = { version = "0.14", default-features = false, features = [
hashbrown = { version = "0.15", default-features = false, features = [
'rustc-dep-of-std',
] }
# FIXME(#127890): `object` depends on `memchr`, but `memchr` > v2.5 causes
Expand Down
126 changes: 66 additions & 60 deletions library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ where
/// ```
#[inline]
#[unstable(feature = "map_many_mut", issue = "97601")]
pub fn get_many_mut<Q: ?Sized, const N: usize>(&mut self, ks: [&Q; N]) -> Option<[&'_ mut V; N]>
pub fn get_many_mut<Q: ?Sized, const N: usize>(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N]
where
K: Borrow<Q>,
Q: Hash + Eq,
Expand Down Expand Up @@ -1011,7 +1011,7 @@ where
pub unsafe fn get_many_unchecked_mut<Q: ?Sized, const N: usize>(
&mut self,
ks: [&Q; N],
) -> Option<[&'_ mut V; N]>
) -> [Option<&'_ mut V>; N]
where
K: Borrow<Q>,
Q: Hash + Eq,
Expand Down Expand Up @@ -1407,6 +1407,14 @@ impl<K, V> Clone for Iter<'_, K, V> {
}
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for Iter<'_, K, V> {
#[inline]
fn default() -> Self {
Iter { base: Default::default() }
}
}

#[stable(feature = "std_debug", since = "1.16.0")]
impl<K: Debug, V: Debug> fmt::Debug for Iter<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -1445,6 +1453,14 @@ impl<'a, K, V> IterMut<'a, K, V> {
}
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for IterMut<'_, K, V> {
#[inline]
fn default() -> Self {
IterMut { base: Default::default() }
}
}

/// An owning iterator over the entries of a `HashMap`.
///
/// This `struct` is created by the [`into_iter`] method on [`HashMap`]
Expand Down Expand Up @@ -1475,6 +1491,14 @@ impl<K, V> IntoIter<K, V> {
}
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for IntoIter<K, V> {
#[inline]
fn default() -> Self {
IntoIter { base: Default::default() }
}
}

/// An iterator over the keys of a `HashMap`.
///
/// This `struct` is created by the [`keys`] method on [`HashMap`]. See its
Expand Down Expand Up @@ -1507,6 +1531,14 @@ impl<K, V> Clone for Keys<'_, K, V> {
}
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for Keys<'_, K, V> {
#[inline]
fn default() -> Self {
Keys { inner: Default::default() }
}
}

#[stable(feature = "std_debug", since = "1.16.0")]
impl<K: Debug, V> fmt::Debug for Keys<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -1546,6 +1578,14 @@ impl<K, V> Clone for Values<'_, K, V> {
}
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for Values<'_, K, V> {
#[inline]
fn default() -> Self {
Values { inner: Default::default() }
}
}

#[stable(feature = "std_debug", since = "1.16.0")]
impl<K, V: Debug> fmt::Debug for Values<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -1634,6 +1674,14 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
inner: IterMut<'a, K, V>,
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for ValuesMut<'_, K, V> {
#[inline]
fn default() -> Self {
ValuesMut { inner: Default::default() }
}
}

/// An owning iterator over the keys of a `HashMap`.
///
/// This `struct` is created by the [`into_keys`] method on [`HashMap`].
Expand All @@ -1656,6 +1704,14 @@ pub struct IntoKeys<K, V> {
inner: IntoIter<K, V>,
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for IntoKeys<K, V> {
#[inline]
fn default() -> Self {
IntoKeys { inner: Default::default() }
}
}

/// An owning iterator over the values of a `HashMap`.
///
/// This `struct` is created by the [`into_values`] method on [`HashMap`].
Expand All @@ -1678,6 +1734,14 @@ pub struct IntoValues<K, V> {
inner: IntoIter<K, V>,
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for IntoValues<K, V> {
#[inline]
fn default() -> Self {
IntoValues { inner: Default::default() }
}
}

/// A builder for computing where in a HashMap a key-value pair would be stored.
///
/// See the [`HashMap::raw_entry_mut`] docs for usage examples.
Expand Down Expand Up @@ -2978,64 +3042,6 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
pub fn remove(self) -> V {
self.base.remove()
}

/// Replaces the entry, returning the old key and value. The new key in the hash map will be
/// the key used to create this entry.
///
/// # Examples
///
/// ```
/// #![feature(map_entry_replace)]
/// use std::collections::hash_map::{Entry, HashMap};
/// use std::rc::Rc;
///
/// let mut map: HashMap<Rc<String>, u32> = HashMap::new();
/// map.insert(Rc::new("Stringthing".to_string()), 15);
///
/// let my_key = Rc::new("Stringthing".to_string());
///
/// if let Entry::Occupied(entry) = map.entry(my_key) {
/// // Also replace the key with a handle to our other key.
/// let (old_key, old_value): (Rc<String>, u32) = entry.replace_entry(16);
/// }
///
/// ```
#[inline]
#[unstable(feature = "map_entry_replace", issue = "44286")]
pub fn replace_entry(self, value: V) -> (K, V) {
self.base.replace_entry(value)
}

/// Replaces the key in the hash map with the key used to create this entry.
///
/// # Examples
///
/// ```
/// #![feature(map_entry_replace)]
/// use std::collections::hash_map::{Entry, HashMap};
/// use std::rc::Rc;
///
/// let mut map: HashMap<Rc<String>, u32> = HashMap::new();
/// let known_strings: Vec<Rc<String>> = Vec::new();
///
/// // Initialise known strings, run program, etc.
///
/// reclaim_memory(&mut map, &known_strings);
///
/// fn reclaim_memory(map: &mut HashMap<Rc<String>, u32>, known_strings: &[Rc<String>] ) {
/// for s in known_strings {
/// if let Entry::Occupied(entry) = map.entry(Rc::clone(s)) {
/// // Replaces the entry's key with our version of it in `known_strings`.
/// entry.replace_key();
/// }
/// }
/// }
/// ```
#[inline]
#[unstable(feature = "map_entry_replace", issue = "44286")]
pub fn replace_key(self) -> K {
self.base.replace_key()
}
}

impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> {
Expand Down
48 changes: 16 additions & 32 deletions library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,38 +724,6 @@ where
self.base.get_or_insert(value)
}

/// Inserts an owned copy of the given `value` into the set if it is not
/// present, then returns a reference to the value in the set.
///
/// # Examples
///
/// ```
/// #![feature(hash_set_entry)]
///
/// use std::collections::HashSet;
///
/// let mut set: HashSet<String> = ["cat", "dog", "horse"]
/// .iter().map(|&pet| pet.to_owned()).collect();
///
/// assert_eq!(set.len(), 3);
/// for &pet in &["cat", "dog", "fish"] {
/// let value = set.get_or_insert_owned(pet);
/// assert_eq!(value, pet);
/// }
/// assert_eq!(set.len(), 4); // a new "fish" was inserted
/// ```
#[inline]
#[unstable(feature = "hash_set_entry", issue = "60896")]
pub fn get_or_insert_owned<Q: ?Sized>(&mut self, value: &Q) -> &T
where
T: Borrow<Q>,
Q: Hash + Eq + ToOwned<Owned = T>,
{
// Although the raw entry gives us `&mut T`, we only return `&T` to be consistent with
// `get`. Key mutation is "raw" because you're not supposed to affect `Eq` or `Hash`.
self.base.get_or_insert_owned(value)
}

/// Inserts a value computed from `f` into the set if the given `value` is
/// not present, then returns a reference to the value in the set.
///
Expand Down Expand Up @@ -1276,6 +1244,14 @@ pub struct Iter<'a, K: 'a> {
base: base::Iter<'a, K>,
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K> Default for Iter<'_, K> {
#[inline]
fn default() -> Self {
Iter { base: Default::default() }
}
}

/// An owning iterator over the items of a `HashSet`.
///
/// This `struct` is created by the [`into_iter`] method on [`HashSet`]
Expand All @@ -1297,6 +1273,14 @@ pub struct IntoIter<K> {
base: base::IntoIter<K>,
}

#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
impl<K> Default for IntoIter<K> {
#[inline]
fn default() -> Self {
IntoIter { base: Default::default() }
}
}

/// A draining iterator over the items of a `HashSet`.
///
/// This `struct` is created by the [`drain`] method on [`HashSet`].
Expand Down
Loading