Skip to content

Commit aa35ab8

Browse files
committed
Stabilize const BTree{Map,Set}::new
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.
1 parent 4d44e09 commit aa35ab8

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

compiler/rustc_hir/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
#![feature(associated_type_defaults)]
66
#![feature(closure_track_caller)]
7-
#![feature(const_btree_new)]
7+
#![feature(const_btree_len)]
88
#![cfg_attr(bootstrap, feature(let_else))]
99
#![feature(once_cell)]
1010
#![feature(min_specialization)]

library/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
}

library/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
}

library/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)]

library/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)]

src/test/ui/consts/issue-88071.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
//
33
// regression test for #88071
44

5-
#![feature(const_btree_new)]
6-
75
use std::collections::BTreeMap;
86

97
pub struct CustomMap<K, V>(BTreeMap<K, V>);

src/tools/clippy/tests/ui/crashes/ice-7126.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// This test requires a feature gated const fn and will stop working in the future.
22

3-
#![feature(const_btree_new)]
3+
#![feature(const_btree_len)]
44

55
use std::collections::BTreeMap;
66

7-
struct Foo(BTreeMap<i32, i32>);
7+
struct Foo(usize);
88
impl Foo {
99
fn new() -> Self {
10-
Self(BTreeMap::new())
10+
Self(BTreeMap::len(&BTreeMap::<u8, u8>::new()))
1111
}
1212
}
1313

0 commit comments

Comments
 (0)