about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-03-13 03:40:14 -0700
committerbors <bors@rust-lang.org>2016-03-13 03:40:14 -0700
commitdb6dd8e4fecd365157ecf51fc492c366359d4064 (patch)
tree9333e8783f5e5f1a7b04700a431ee39175f7d4cd
parent06074ac004701bff42c625247c4764b2ae6fca6c (diff)
parentec39a76a3e8a96563845eca4eb77f3ba2a2090a9 (diff)
downloadrust-db6dd8e4fecd365157ecf51fc492c366359d4064.tar.gz
rust-db6dd8e4fecd365157ecf51fc492c366359d4064.zip
Auto merge of #32182 - bluss:string-from-is-str-owned, r=alexcrichton
Call str::to_owned in String::from and uninline it

Call str::to_owned in String::from and uninline it

These methods were already effectively equal, but now one calls
the other, and neither is marked inline.
String::from does not need to be inlined, it can be without it just like
str::to_owned and String::clone are.

Fixes #32163
-rw-r--r--src/libcollections/string.rs16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index beb12ff58af..98225dd3dda 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -66,7 +66,7 @@ use core::str::pattern::Pattern;
 use rustc_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
 use rustc_unicode::str as unicode_str;
 
-use borrow::Cow;
+use borrow::{Cow, ToOwned};
 use range::RangeArgument;
 use str::{self, FromStr, Utf8Error, Chars};
 use vec::Vec;
@@ -1797,20 +1797,8 @@ impl AsRef<[u8]> for String {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> From<&'a str> for String {
-    #[cfg(not(test))]
-    #[inline]
     fn from(s: &'a str) -> String {
-        String { vec: <[_]>::to_vec(s.as_bytes()) }
-    }
-
-    // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is
-    // required for this method definition, is not available. Since we don't
-    // require this method for testing purposes, I'll just stub it
-    // NB see the slice::hack module in slice.rs for more information
-    #[inline]
-    #[cfg(test)]
-    fn from(_: &str) -> String {
-        panic!("not available with cfg(test)");
+        s.to_owned()
     }
 }