about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorF001 <changchun.fan@qq.com>2018-05-05 16:34:43 +0800
committerF001 <changchun.fan@qq.com>2018-05-05 16:38:27 +0800
commit160063aad2206a35e6312bfaa159f0f4475af0ae (patch)
treecfd992dac840404b7921f39670bdc27ef6d82f20 /src/liballoc
parent1d168261a1bc0031ef27de735992a4842fd62553 (diff)
downloadrust-160063aad2206a35e6312bfaa159f0f4475af0ae.tar.gz
rust-160063aad2206a35e6312bfaa159f0f4475af0ae.zip
make `String::new()` const
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/lib.rs1
-rw-r--r--src/liballoc/string.rs3
2 files changed, 3 insertions, 1 deletions
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index da4b76a4d52..bb78c14b905 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -125,6 +125,7 @@
 #![feature(inclusive_range_methods)]
 #![cfg_attr(stage0, feature(generic_param_attrs))]
 #![feature(rustc_const_unstable)]
+#![feature(const_vec_new)]
 
 #![cfg_attr(not(test), feature(fn_traits, i128))]
 #![cfg_attr(test, feature(test))]
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 2f84d5f7f86..da9afdd2ca3 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -380,7 +380,8 @@ impl String {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn new() -> String {
+    #[rustc_const_unstable(feature = "const_string_new")]
+    pub const fn new() -> String {
         String { vec: Vec::new() }
     }