Skip to content

Commit 6df1002

Browse files
authored
Rollup merge of rust-lang#136152 - Urgau:stabilize-map_many_mut, r=joshtriplett
Stabilize `map_many_mut` feature This PR stabilize `HashMap::get_many_mut` as `HashMap::get_disjoint_mut` and `HashMap::get_many_unchecked_mut` as `HashMap::get_disjoint_unchecked_mut` per FCP. FCP at rust-lang#97601 (comment) Fixes rust-lang#97601 r? libs
2 parents 1e60a70 + 6b7b547 commit 6df1002

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

compiler/rustc_session/src/config/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ impl CheckCfg {
427427
Some(values_target_os),
428428
Some(values_target_pointer_width),
429429
Some(values_target_vendor),
430-
] = self.expecteds.get_many_mut(VALUES)
430+
] = self.expecteds.get_disjoint_mut(VALUES)
431431
else {
432432
panic!("unable to get all the check-cfg values buckets");
433433
};

compiler/rustc_session/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![allow(internal_features)]
33
#![feature(iter_intersperse)]
44
#![feature(let_chains)]
5-
#![feature(map_many_mut)]
65
#![feature(rustc_attrs)]
76
// To generate CodegenOptionsTargetModifiers and UnstableOptionsTargetModifiers enums
87
// with macro_rules, it is necessary to use recursive mechanic ("Incremental TT Munchers").

library/std/src/collections/hash/map.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,6 @@ where
969969
/// # Examples
970970
///
971971
/// ```
972-
/// #![feature(map_many_mut)]
973972
/// use std::collections::HashMap;
974973
///
975974
/// let mut libraries = HashMap::new();
@@ -979,13 +978,13 @@ where
979978
/// libraries.insert("Library of Congress".to_string(), 1800);
980979
///
981980
/// // Get Athenæum and Bodleian Library
982-
/// let [Some(a), Some(b)] = libraries.get_many_mut([
981+
/// let [Some(a), Some(b)] = libraries.get_disjoint_mut([
983982
/// "Athenæum",
984983
/// "Bodleian Library",
985984
/// ]) else { panic!() };
986985
///
987986
/// // Assert values of Athenæum and Library of Congress
988-
/// let got = libraries.get_many_mut([
987+
/// let got = libraries.get_disjoint_mut([
989988
/// "Athenæum",
990989
/// "Library of Congress",
991990
/// ]);
@@ -998,7 +997,7 @@ where
998997
/// );
999998
///
1000999
/// // Missing keys result in None
1001-
/// let got = libraries.get_many_mut([
1000+
/// let got = libraries.get_disjoint_mut([
10021001
/// "Athenæum",
10031002
/// "New York Public Library",
10041003
/// ]);
@@ -1012,21 +1011,24 @@ where
10121011
/// ```
10131012
///
10141013
/// ```should_panic
1015-
/// #![feature(map_many_mut)]
10161014
/// use std::collections::HashMap;
10171015
///
10181016
/// let mut libraries = HashMap::new();
10191017
/// libraries.insert("Athenæum".to_string(), 1807);
10201018
///
10211019
/// // Duplicate keys panic!
1022-
/// let got = libraries.get_many_mut([
1020+
/// let got = libraries.get_disjoint_mut([
10231021
/// "Athenæum",
10241022
/// "Athenæum",
10251023
/// ]);
10261024
/// ```
10271025
#[inline]
1028-
#[unstable(feature = "map_many_mut", issue = "97601")]
1029-
pub fn get_many_mut<Q: ?Sized, const N: usize>(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N]
1026+
#[doc(alias = "get_many_mut")]
1027+
#[stable(feature = "map_many_mut", since = "CURRENT_RUSTC_VERSION")]
1028+
pub fn get_disjoint_mut<Q: ?Sized, const N: usize>(
1029+
&mut self,
1030+
ks: [&Q; N],
1031+
) -> [Option<&'_ mut V>; N]
10301032
where
10311033
K: Borrow<Q>,
10321034
Q: Hash + Eq,
@@ -1040,7 +1042,7 @@ where
10401042
/// Returns an array of length `N` with the results of each query. `None` will be used if
10411043
/// the key is missing.
10421044
///
1043-
/// For a safe alternative see [`get_many_mut`](`HashMap::get_many_mut`).
1045+
/// For a safe alternative see [`get_disjoint_mut`](`HashMap::get_disjoint_mut`).
10441046
///
10451047
/// # Safety
10461048
///
@@ -1052,7 +1054,6 @@ where
10521054
/// # Examples
10531055
///
10541056
/// ```
1055-
/// #![feature(map_many_mut)]
10561057
/// use std::collections::HashMap;
10571058
///
10581059
/// let mut libraries = HashMap::new();
@@ -1062,13 +1063,13 @@ where
10621063
/// libraries.insert("Library of Congress".to_string(), 1800);
10631064
///
10641065
/// // SAFETY: The keys do not overlap.
1065-
/// let [Some(a), Some(b)] = (unsafe { libraries.get_many_unchecked_mut([
1066+
/// let [Some(a), Some(b)] = (unsafe { libraries.get_disjoint_unchecked_mut([
10661067
/// "Athenæum",
10671068
/// "Bodleian Library",
10681069
/// ]) }) else { panic!() };
10691070
///
10701071
/// // SAFETY: The keys do not overlap.
1071-
/// let got = unsafe { libraries.get_many_unchecked_mut([
1072+
/// let got = unsafe { libraries.get_disjoint_unchecked_mut([
10721073
/// "Athenæum",
10731074
/// "Library of Congress",
10741075
/// ]) };
@@ -1081,16 +1082,17 @@ where
10811082
/// );
10821083
///
10831084
/// // SAFETY: The keys do not overlap.
1084-
/// let got = unsafe { libraries.get_many_unchecked_mut([
1085+
/// let got = unsafe { libraries.get_disjoint_unchecked_mut([
10851086
/// "Athenæum",
10861087
/// "New York Public Library",
10871088
/// ]) };
10881089
/// // Missing keys result in None
10891090
/// assert_eq!(got, [Some(&mut 1807), None]);
10901091
/// ```
10911092
#[inline]
1092-
#[unstable(feature = "map_many_mut", issue = "97601")]
1093-
pub unsafe fn get_many_unchecked_mut<Q: ?Sized, const N: usize>(
1093+
#[doc(alias = "get_many_unchecked_mut")]
1094+
#[stable(feature = "map_many_mut", since = "CURRENT_RUSTC_VERSION")]
1095+
pub unsafe fn get_disjoint_unchecked_mut<Q: ?Sized, const N: usize>(
10941096
&mut self,
10951097
ks: [&Q; N],
10961098
) -> [Option<&'_ mut V>; N]

0 commit comments

Comments
 (0)