about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-05-09 03:10:05 +0200
committerGitHub <noreply@github.com>2020-05-09 03:10:05 +0200
commitf16c27f1c4821a0d763cb4a5a2c1d518126f024b (patch)
tree32b0dd504c1b7a5d8e2dfb415210b2ac38919a49 /src/liballoc
parent62374ee4ad00a4cc8a4807ed13823a49e2e8422d (diff)
parent707cfd167236cf6bffb7bb60e98cd5eb44f678c7 (diff)
downloadrust-f16c27f1c4821a0d763cb4a5a2c1d518126f024b.tar.gz
rust-f16c27f1c4821a0d763cb4a5a2c1d518126f024b.zip
Rollup merge of #71839 - LG3696:master, r=cramertj
Make BTreeMap::new and BTreeSet::new const
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/collections/btree/map.rs3
-rw-r--r--src/liballoc/collections/btree/set.rs3
-rw-r--r--src/liballoc/lib.rs1
3 files changed, 5 insertions, 2 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs
index 98a94d695f7..113df80d0c2 100644
--- a/src/liballoc/collections/btree/map.rs
+++ b/src/liballoc/collections/btree/map.rs
@@ -556,7 +556,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
     /// map.insert(1, "a");
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn new() -> BTreeMap<K, V> {
+    #[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
+    pub const fn new() -> BTreeMap<K, V> {
         BTreeMap { root: None, length: 0 }
     }
 
diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs
index 9bf483f269f..dee5fb878ff 100644
--- a/src/liballoc/collections/btree/set.rs
+++ b/src/liballoc/collections/btree/set.rs
@@ -309,7 +309,8 @@ impl<T: Ord> BTreeSet<T> {
     /// let mut set: BTreeSet<i32> = BTreeSet::new();
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn new() -> BTreeSet<T> {
+    #[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
+    pub const fn new() -> BTreeSet<T> {
         BTreeSet { map: BTreeMap::new() }
     }
 
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index ecec1fb039b..5365c9d0168 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -82,6 +82,7 @@
 #![feature(cfg_sanitize)]
 #![feature(cfg_target_has_atomic)]
 #![feature(coerce_unsized)]
+#![feature(const_btree_new)]
 #![feature(const_generic_impls_guard)]
 #![feature(const_generics)]
 #![feature(const_in_array_repeat_expressions)]