Skip to content

Commit 3cbd39f

Browse files
authored
Rollup merge of rust-lang#87993 - kornelski:try_reserve_stable, r=joshtriplett
Stabilize try_reserve Stabilization PR for the [`try_reserve` feature](rust-lang#48043 (comment)).
2 parents 003d8d3 + 00152d8 commit 3cbd39f

File tree

16 files changed

+14
-42
lines changed

16 files changed

+14
-42
lines changed

compiler/rustc_data_structures/src/sso/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const SSO_ARRAY_SIZE: usize = 8;
3131
//
3232
// Missing HashMap API:
3333
// all hasher-related
34-
// try_reserve (unstable)
34+
// try_reserve
3535
// shrink_to (unstable)
3636
// drain_filter (unstable)
3737
// into_keys/into_values (unstable)

compiler/rustc_data_structures/src/sso/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use super::map::SsoHashMap;
1313
//
1414
// Missing HashSet API:
1515
// all hasher-related
16-
// try_reserve (unstable)
16+
// try_reserve
1717
// shrink_to (unstable)
1818
// drain_filter (unstable)
1919
// replace

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#![feature(thread_local_const_init)]
5353
#![feature(trusted_step)]
5454
#![feature(try_blocks)]
55-
#![feature(try_reserve)]
5655
#![feature(try_reserve_kind)]
5756
#![feature(nonzero_ops)]
5857
#![recursion_limit = "512"]

library/alloc/src/collections/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use core::fmt::Display;
5757

5858
/// The error type for `try_reserve` methods.
5959
#[derive(Clone, PartialEq, Eq, Debug)]
60-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
60+
#[stable(feature = "try_reserve", since = "1.57.0")]
6161
pub struct TryReserveError {
6262
kind: TryReserveErrorKind,
6363
}
@@ -126,7 +126,7 @@ impl From<LayoutError> for TryReserveErrorKind {
126126
}
127127
}
128128

129-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
129+
#[stable(feature = "try_reserve", since = "1.57.0")]
130130
impl Display for TryReserveError {
131131
fn fmt(
132132
&self,

library/alloc/src/collections/vec_deque/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,6 @@ impl<T, A: Allocator> VecDeque<T, A> {
711711
/// # Examples
712712
///
713713
/// ```
714-
/// #![feature(try_reserve)]
715714
/// use std::collections::TryReserveError;
716715
/// use std::collections::VecDeque;
717716
///
@@ -730,7 +729,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
730729
/// }
731730
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
732731
/// ```
733-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
732+
#[stable(feature = "try_reserve", since = "1.57.0")]
734733
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
735734
self.try_reserve(additional)
736735
}
@@ -749,7 +748,6 @@ impl<T, A: Allocator> VecDeque<T, A> {
749748
/// # Examples
750749
///
751750
/// ```
752-
/// #![feature(try_reserve)]
753751
/// use std::collections::TryReserveError;
754752
/// use std::collections::VecDeque;
755753
///
@@ -768,7 +766,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
768766
/// }
769767
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
770768
/// ```
771-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
769+
#[stable(feature = "try_reserve", since = "1.57.0")]
772770
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
773771
let old_cap = self.cap();
774772
let used_cap = self.len() + 1;

library/alloc/src/string.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,6 @@ impl String {
10091009
/// # Examples
10101010
///
10111011
/// ```
1012-
/// #![feature(try_reserve)]
10131012
/// use std::collections::TryReserveError;
10141013
///
10151014
/// fn process_data(data: &str) -> Result<String, TryReserveError> {
@@ -1025,7 +1024,7 @@ impl String {
10251024
/// }
10261025
/// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?");
10271026
/// ```
1028-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
1027+
#[stable(feature = "try_reserve", since = "1.57.0")]
10291028
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
10301029
self.vec.try_reserve(additional)
10311030
}
@@ -1049,7 +1048,6 @@ impl String {
10491048
/// # Examples
10501049
///
10511050
/// ```
1052-
/// #![feature(try_reserve)]
10531051
/// use std::collections::TryReserveError;
10541052
///
10551053
/// fn process_data(data: &str) -> Result<String, TryReserveError> {
@@ -1065,7 +1063,7 @@ impl String {
10651063
/// }
10661064
/// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?");
10671065
/// ```
1068-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
1066+
#[stable(feature = "try_reserve", since = "1.57.0")]
10691067
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
10701068
self.vec.try_reserve_exact(additional)
10711069
}

library/alloc/src/vec/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ impl<T, A: Allocator> Vec<T, A> {
849849
/// # Examples
850850
///
851851
/// ```
852-
/// #![feature(try_reserve)]
853852
/// use std::collections::TryReserveError;
854853
///
855854
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
@@ -867,7 +866,7 @@ impl<T, A: Allocator> Vec<T, A> {
867866
/// }
868867
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
869868
/// ```
870-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
869+
#[stable(feature = "try_reserve", since = "1.57.0")]
871870
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
872871
self.buf.try_reserve(self.len, additional)
873872
}
@@ -892,7 +891,6 @@ impl<T, A: Allocator> Vec<T, A> {
892891
/// # Examples
893892
///
894893
/// ```
895-
/// #![feature(try_reserve)]
896894
/// use std::collections::TryReserveError;
897895
///
898896
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
@@ -910,7 +908,7 @@ impl<T, A: Allocator> Vec<T, A> {
910908
/// }
911909
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
912910
/// ```
913-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
911+
#[stable(feature = "try_reserve", since = "1.57.0")]
914912
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
915913
self.buf.try_reserve_exact(self.len, additional)
916914
}

library/alloc/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![feature(new_uninit)]
99
#![feature(pattern)]
1010
#![feature(trusted_len)]
11-
#![feature(try_reserve)]
1211
#![feature(try_reserve_kind)]
1312
#![feature(unboxed_closures)]
1413
#![feature(associated_type_bounds)]

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,13 @@ where
625625
/// # Examples
626626
///
627627
/// ```
628-
/// #![feature(try_reserve)]
629628
/// use std::collections::HashMap;
630629
///
631630
/// let mut map: HashMap<&str, isize> = HashMap::new();
632631
/// map.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?");
633632
/// ```
634633
#[inline]
635-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
634+
#[stable(feature = "try_reserve", since = "1.57.0")]
636635
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
637636
self.base.try_reserve(additional).map_err(map_try_reserve_error)
638637
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,12 @@ where
423423
/// # Examples
424424
///
425425
/// ```
426-
/// #![feature(try_reserve)]
427426
/// use std::collections::HashSet;
428427
/// let mut set: HashSet<i32> = HashSet::new();
429428
/// set.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?");
430429
/// ```
431430
#[inline]
432-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
431+
#[stable(feature = "try_reserve", since = "1.57.0")]
433432
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
434433
self.base.try_reserve(additional).map_err(map_try_reserve_error)
435434
}

library/std/src/collections/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ pub use self::hash_map::HashMap;
420420
#[stable(feature = "rust1", since = "1.0.0")]
421421
pub use self::hash_set::HashSet;
422422

423-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
423+
#[stable(feature = "try_reserve", since = "1.57.0")]
424424
pub use alloc_crate::collections::TryReserveError;
425425
#[unstable(
426426
feature = "try_reserve_kind",

library/std/src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl Error for char::ParseCharError {
595595
}
596596
}
597597

598-
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
598+
#[stable(feature = "try_reserve", since = "1.57.0")]
599599
impl Error for alloc::collections::TryReserveError {}
600600

601601
#[unstable(feature = "duration_checked_float", issue = "83400")]

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@
331331
#![feature(total_cmp)]
332332
#![feature(trace_macros)]
333333
#![feature(try_blocks)]
334-
#![feature(try_reserve)]
335334
#![feature(try_reserve_kind)]
336335
#![feature(unboxed_closures)]
337336
#![feature(unwrap_infallible)]

src/test/ui/closures/issue-87814-2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// check-pass
2-
#![feature(try_reserve)]
32

43
fn main() {
54
let mut schema_all: (Vec<String>, Vec<String>) = (vec![], vec![]);

src/test/ui/feature-gates/feature-gate-try_reserve.rs

-4
This file was deleted.

src/test/ui/feature-gates/feature-gate-try_reserve.stderr

-12
This file was deleted.

0 commit comments

Comments
 (0)