Skip to content

Commit c7436ca

Browse files
authored
Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
Stabilize const `BTree{Map,Set}::new` The FCP was completed in #71835. Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.
2 parents 9579046 + b0722b5 commit c7436ca

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

‎alloc/src/collections/btree/map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ impl<K, V> BTreeMap<K, V> {
580580
/// map.insert(1, "a");
581581
/// ```
582582
#[stable(feature = "rust1", since = "1.0.0")]
583-
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
583+
#[rustc_const_stable(feature = "const_btree_new", since = "CURRENT_RUSTC_VERSION")]
584584
#[must_use]
585585
pub const fn new() -> BTreeMap<K, V> {
586586
BTreeMap { root: None, length: 0, alloc: ManuallyDrop::new(Global), _marker: PhantomData }
@@ -2392,7 +2392,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
23922392
/// ```
23932393
#[must_use]
23942394
#[stable(feature = "rust1", since = "1.0.0")]
2395-
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
2395+
#[rustc_const_unstable(feature = "const_btree_len", issue = "71835")]
23962396
pub const fn len(&self) -> usize {
23972397
self.length
23982398
}
@@ -2413,7 +2413,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
24132413
/// ```
24142414
#[must_use]
24152415
#[stable(feature = "rust1", since = "1.0.0")]
2416-
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
2416+
#[rustc_const_unstable(feature = "const_btree_len", issue = "71835")]
24172417
pub const fn is_empty(&self) -> bool {
24182418
self.len() == 0
24192419
}

‎alloc/src/collections/btree/set.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<T> BTreeSet<T> {
343343
/// let mut set: BTreeSet<i32> = BTreeSet::new();
344344
/// ```
345345
#[stable(feature = "rust1", since = "1.0.0")]
346-
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
346+
#[rustc_const_stable(feature = "const_btree_new", since = "CURRENT_RUSTC_VERSION")]
347347
#[must_use]
348348
pub const fn new() -> BTreeSet<T> {
349349
BTreeSet { map: BTreeMap::new() }
@@ -1174,7 +1174,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
11741174
/// ```
11751175
#[must_use]
11761176
#[stable(feature = "rust1", since = "1.0.0")]
1177-
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
1177+
#[rustc_const_unstable(feature = "const_btree_len", issue = "71835")]
11781178
pub const fn len(&self) -> usize {
11791179
self.map.len()
11801180
}
@@ -1193,7 +1193,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
11931193
/// ```
11941194
#[must_use]
11951195
#[stable(feature = "rust1", since = "1.0.0")]
1196-
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
1196+
#[rustc_const_unstable(feature = "const_btree_len", issue = "71835")]
11971197
pub const fn is_empty(&self) -> bool {
11981198
self.len() == 0
11991199
}

‎alloc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
#![feature(coerce_unsized)]
100100
#![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))]
101101
#![feature(const_box)]
102-
#![cfg_attr(not(no_global_oom_handling), feature(const_btree_new))]
102+
#![cfg_attr(not(no_global_oom_handling), feature(const_btree_len))]
103103
#![feature(const_cow_is_borrowed)]
104104
#![feature(const_convert)]
105105
#![feature(const_size_of_val)]

‎alloc/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#![feature(slice_group_by)]
3333
#![feature(slice_partition_dedup)]
3434
#![feature(string_remove_matches)]
35-
#![feature(const_btree_new)]
35+
#![feature(const_btree_len)]
3636
#![feature(const_default_impls)]
3737
#![feature(const_trait_impl)]
3838
#![feature(const_str_from_utf8)]

0 commit comments

Comments
 (0)