]> git.lizzy.rs Git - rust.git/commitdiff
Replace usage of String::from_str with String:from
authorSimon Sapin <simon.sapin@exyr.org>
Mon, 8 Jun 2015 14:55:35 +0000 (16:55 +0200)
committerSimon Sapin <simon.sapin@exyr.org>
Mon, 8 Jun 2015 14:55:35 +0000 (16:55 +0200)
29 files changed:
src/compiletest/runtest.rs
src/grammar/verify.rs
src/libcollections/string.rs
src/libcollectionstest/str.rs
src/libcollectionstest/string.rs
src/librustc/middle/infer/error_reporting.rs
src/librustc_trans/back/link.rs
src/librustc_trans/save/dump_csv.rs
src/librustc_trans/save/mod.rs
src/librustc_trans/save/recorder.rs
src/librustc_trans/save/span_utils.rs
src/librustc_trans/trans/builder.rs
src/librustc_trans/trans/debuginfo/mod.rs
src/librustc_trans/trans/debuginfo/namespace.rs
src/librustdoc/clean/mod.rs
src/librustdoc/html/format.rs
src/librustdoc/html/render.rs
src/librustdoc/html/toc.rs
src/librustdoc/plugins.rs
src/libserialize/json.rs
src/libstd/error.rs
src/libstd/sys/common/wtf8.rs
src/libtest/lib.rs
src/test/run-pass/issue-19811-escape-unicode.rs
src/test/run-pass/istr.rs
src/test/run-pass/new-unicode-escapes.rs
src/test/run-pass/overloaded-autoderef.rs
src/test/run-pass/overloaded-deref.rs
src/test/run-pass/while-prelude-drop.rs

index 87b6f8f0df6b34ab604428d33124fa23b8d50366..185a969cbc6270d1497532a8a38eda43ef6ba869 100644 (file)
@@ -651,7 +651,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
 
     // Write debugger script:
     // We don't want to hang when calling `quit` while the process is still running
-    let mut script_str = String::from_str("settings set auto-confirm true\n");
+    let mut script_str = String::from("settings set auto-confirm true\n");
 
     // Make LLDB emit its version, so we have it documented in the test output
     script_str.push_str("version\n");
index 0d8fb312d11315c3a52d0e4fe6d7075a126c11f1..3235389f1d19309bf83d68418185ef987a36b18f 100644 (file)
@@ -287,7 +287,7 @@ fn next(r: &mut lexer::StringReader) -> TokenAndSpan {
     let options = config::basic_options();
     let session = session::build_session(options, None,
                                          syntax::diagnostics::registry::Registry::new(&[]));
-    let filemap = session.parse_sess.codemap().new_filemap(String::from_str("<n/a>"), code);
+    let filemap = session.parse_sess.codemap().new_filemap(String::from("<n/a>"), code);
     let mut lexer = lexer::StringReader::new(session.diagnostic(), filemap);
     let cm = session.codemap();
 
index 86f77510e47509ff273685766bbde585712e782c..4194ac63d39fad2bbd2dda65610e18cf1380a99e 100644 (file)
@@ -89,7 +89,7 @@ pub fn with_capacity(capacity: usize) -> String {
     ///
     /// ```
     /// # #![feature(collections)]
-    /// let s = String::from_str("hello");
+    /// let s = String::from("hello");
     /// assert_eq!(&s[..], "hello");
     /// ```
     #[inline]
@@ -1002,7 +1002,7 @@ pub fn as_string<'a>(x: &'a str) -> DerefString<'a> {
     DerefString { x: as_vec(x.as_bytes()) }
 }
 
-/// Error returned from `String::from_str`
+/// Error returned from `String::from`
 #[unstable(feature = "str_parse_error", reason = "may want to be replaced with \
                                                   Void if it ever exists")]
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
@@ -1013,7 +1013,7 @@ impl FromStr for String {
     type Err = ParseError;
     #[inline]
     fn from_str(s: &str) -> Result<String, ParseError> {
-        Ok(String::from_str(s))
+        Ok(String::from(s))
     }
 }
 
index 170f49ab15be553d5177122d4033da1e65bbaf85..1019e98153e6baa1703755d548123daccc7a1b13 100644 (file)
@@ -71,17 +71,17 @@ fn test_rfind() {
 
 #[test]
 fn test_collect() {
-    let empty = String::from_str("");
+    let empty = String::from("");
     let s: String = empty.chars().collect();
     assert_eq!(empty, s);
-    let data = String::from_str("ประเทศไทย中");
+    let data = String::from("ประเทศไทย中");
     let s: String = data.chars().collect();
     assert_eq!(data, s);
 }
 
 #[test]
 fn test_into_bytes() {
-    let data = String::from_str("asdf");
+    let data = String::from("asdf");
     let buf = data.into_bytes();
     assert_eq!(buf, b"asdf");
 }
@@ -98,7 +98,7 @@ fn test_find_str() {
     assert!(data[2..4].find("ab").is_none());
 
     let string = "ประเทศไทย中华Việt Nam";
-    let mut data = String::from_str(string);
+    let mut data = String::from(string);
     data.push_str(string);
     assert!(data.find("ไท华").is_none());
     assert_eq!(data[0..43].find(""), Some(0));
@@ -211,7 +211,7 @@ fn half_a_million_letter_a() -> String {
     }
     let letters = a_million_letter_a();
     assert!(half_a_million_letter_a() ==
-        unsafe {String::from_str(letters.slice_unchecked(
+        unsafe {String::from(letters.slice_unchecked(
                                  0,
                                  500000))});
 }
@@ -247,13 +247,13 @@ fn test_is_empty() {
 #[test]
 fn test_replace() {
     let a = "a";
-    assert_eq!("".replace(a, "b"), String::from_str(""));
-    assert_eq!("a".replace(a, "b"), String::from_str("b"));
-    assert_eq!("ab".replace(a, "b"), String::from_str("bb"));
+    assert_eq!("".replace(a, "b"), String::from(""));
+    assert_eq!("a".replace(a, "b"), String::from("b"));
+    assert_eq!("ab".replace(a, "b"), String::from("bb"));
     let test = "test";
     assert!(" test test ".replace(test, "toast") ==
-        String::from_str(" toast toast "));
-    assert_eq!(" test test ".replace(test, ""), String::from_str("   "));
+        String::from(" toast toast "));
+    assert_eq!(" test test ".replace(test, ""), String::from("   "));
 }
 
 #[test]
@@ -328,7 +328,7 @@ fn half_a_million_letter_x() -> String {
     }
     let letters = a_million_letter_x();
     assert!(half_a_million_letter_x() ==
-        String::from_str(&letters[0..3 * 500000]));
+        String::from(&letters[0..3 * 500000]));
 }
 
 #[test]
@@ -581,7 +581,7 @@ fn test_as_bytes() {
 fn test_as_bytes_fail() {
     // Don't double free. (I'm not sure if this exercises the
     // original problem code path anymore.)
-    let s = String::from_str("");
+    let s = String::from("");
     let _bytes = s.as_bytes();
     panic!();
 }
@@ -623,10 +623,10 @@ fn test_subslice_offset_2() {
 
 #[test]
 fn vec_str_conversions() {
-    let s1: String = String::from_str("All mimsy were the borogoves");
+    let s1: String = String::from("All mimsy were the borogoves");
 
     let v: Vec<u8> = s1.as_bytes().to_vec();
-    let s2: String = String::from_str(from_utf8(&v).unwrap());
+    let s2: String = String::from(from_utf8(&v).unwrap());
     let mut i = 0;
     let n1 = s1.len();
     let n2 = v.len();
@@ -691,39 +691,39 @@ fn test_char_at_reverse() {
 #[test]
 fn test_escape_unicode() {
     assert_eq!("abc".escape_unicode(),
-               String::from_str("\\u{61}\\u{62}\\u{63}"));
+               String::from("\\u{61}\\u{62}\\u{63}"));
     assert_eq!("a c".escape_unicode(),
-               String::from_str("\\u{61}\\u{20}\\u{63}"));
+               String::from("\\u{61}\\u{20}\\u{63}"));
     assert_eq!("\r\n\t".escape_unicode(),
-               String::from_str("\\u{d}\\u{a}\\u{9}"));
+               String::from("\\u{d}\\u{a}\\u{9}"));
     assert_eq!("'\"\\".escape_unicode(),
-               String::from_str("\\u{27}\\u{22}\\u{5c}"));
+               String::from("\\u{27}\\u{22}\\u{5c}"));
     assert_eq!("\x00\x01\u{fe}\u{ff}".escape_unicode(),
-               String::from_str("\\u{0}\\u{1}\\u{fe}\\u{ff}"));
+               String::from("\\u{0}\\u{1}\\u{fe}\\u{ff}"));
     assert_eq!("\u{100}\u{ffff}".escape_unicode(),
-               String::from_str("\\u{100}\\u{ffff}"));
+               String::from("\\u{100}\\u{ffff}"));
     assert_eq!("\u{10000}\u{10ffff}".escape_unicode(),
-               String::from_str("\\u{10000}\\u{10ffff}"));
+               String::from("\\u{10000}\\u{10ffff}"));
     assert_eq!("ab\u{fb00}".escape_unicode(),
-               String::from_str("\\u{61}\\u{62}\\u{fb00}"));
+               String::from("\\u{61}\\u{62}\\u{fb00}"));
     assert_eq!("\u{1d4ea}\r".escape_unicode(),
-               String::from_str("\\u{1d4ea}\\u{d}"));
+               String::from("\\u{1d4ea}\\u{d}"));
 }
 
 #[test]
 fn test_escape_default() {
-    assert_eq!("abc".escape_default(), String::from_str("abc"));
-    assert_eq!("a c".escape_default(), String::from_str("a c"));
-    assert_eq!("\r\n\t".escape_default(), String::from_str("\\r\\n\\t"));
-    assert_eq!("'\"\\".escape_default(), String::from_str("\\'\\\"\\\\"));
+    assert_eq!("abc".escape_default(), String::from("abc"));
+    assert_eq!("a c".escape_default(), String::from("a c"));
+    assert_eq!("\r\n\t".escape_default(), String::from("\\r\\n\\t"));
+    assert_eq!("'\"\\".escape_default(), String::from("\\'\\\"\\\\"));
     assert_eq!("\u{100}\u{ffff}".escape_default(),
-               String::from_str("\\u{100}\\u{ffff}"));
+               String::from("\\u{100}\\u{ffff}"));
     assert_eq!("\u{10000}\u{10ffff}".escape_default(),
-               String::from_str("\\u{10000}\\u{10ffff}"));
+               String::from("\\u{10000}\\u{10ffff}"));
     assert_eq!("ab\u{fb00}".escape_default(),
-               String::from_str("ab\\u{fb00}"));
+               String::from("ab\\u{fb00}"));
     assert_eq!("\u{1d4ea}\r".escape_default(),
-               String::from_str("\\u{1d4ea}\\r"));
+               String::from("\\u{1d4ea}\\r"));
 }
 
 #[test]
@@ -1490,12 +1490,12 @@ fn sum_len(v: &[&str]) -> usize {
         v.iter().map(|x| x.len()).sum()
     }
 
-    let s = String::from_str("01234");
+    let s = String::from("01234");
     assert_eq!(5, sum_len(&["012", "", "34"]));
-    assert_eq!(5, sum_len(&[&String::from_str("01"),
-                            &String::from_str("2"),
-                            &String::from_str("34"),
-                            &String::from_str("")]));
+    assert_eq!(5, sum_len(&[&String::from("01"),
+                            &String::from("2"),
+                            &String::from("34"),
+                            &String::from("")]));
     assert_eq!(5, sum_len(&[&s]));
 }
 
index d4e2ebf4fd137e31a49fb1caa967bae1347f1d8c..a21906f2f93a0c417f4c9bb89135f5819cf5ff97 100644 (file)
@@ -37,11 +37,11 @@ fn test_unsized_to_string() {
 fn test_from_utf8() {
     let xs = b"hello".to_vec();
     assert_eq!(String::from_utf8(xs).unwrap(),
-               String::from_str("hello"));
+               String::from("hello"));
 
     let xs = "ศไทย中华Việt Nam".as_bytes().to_vec();
     assert_eq!(String::from_utf8(xs).unwrap(),
-               String::from_str("ศไทย中华Việt Nam"));
+               String::from("ศไทย中华Việt Nam"));
 
     let xs = b"hello\xFF".to_vec();
     let err = String::from_utf8(xs).err().unwrap();
@@ -60,44 +60,44 @@ fn test_from_utf8_lossy() {
 
     let xs = b"Hello\xC2 There\xFF Goodbye";
     assert_eq!(String::from_utf8_lossy(xs),
-               String::from_str("Hello\u{FFFD} There\u{FFFD} Goodbye").into_cow());
+               String::from("Hello\u{FFFD} There\u{FFFD} Goodbye").into_cow());
 
     let xs = b"Hello\xC0\x80 There\xE6\x83 Goodbye";
     assert_eq!(String::from_utf8_lossy(xs),
-               String::from_str("Hello\u{FFFD}\u{FFFD} There\u{FFFD} Goodbye").into_cow());
+               String::from("Hello\u{FFFD}\u{FFFD} There\u{FFFD} Goodbye").into_cow());
 
     let xs = b"\xF5foo\xF5\x80bar";
     assert_eq!(String::from_utf8_lossy(xs),
-               String::from_str("\u{FFFD}foo\u{FFFD}\u{FFFD}bar").into_cow());
+               String::from("\u{FFFD}foo\u{FFFD}\u{FFFD}bar").into_cow());
 
     let xs = b"\xF1foo\xF1\x80bar\xF1\x80\x80baz";
     assert_eq!(String::from_utf8_lossy(xs),
-               String::from_str("\u{FFFD}foo\u{FFFD}bar\u{FFFD}baz").into_cow());
+               String::from("\u{FFFD}foo\u{FFFD}bar\u{FFFD}baz").into_cow());
 
     let xs = b"\xF4foo\xF4\x80bar\xF4\xBFbaz";
     assert_eq!(String::from_utf8_lossy(xs),
-               String::from_str("\u{FFFD}foo\u{FFFD}bar\u{FFFD}\u{FFFD}baz").into_cow());
+               String::from("\u{FFFD}foo\u{FFFD}bar\u{FFFD}\u{FFFD}baz").into_cow());
 
     let xs = b"\xF0\x80\x80\x80foo\xF0\x90\x80\x80bar";
-    assert_eq!(String::from_utf8_lossy(xs), String::from_str("\u{FFFD}\u{FFFD}\u{FFFD}\u{FFFD}\
+    assert_eq!(String::from_utf8_lossy(xs), String::from("\u{FFFD}\u{FFFD}\u{FFFD}\u{FFFD}\
                                            foo\u{10000}bar").into_cow());
 
     // surrogates
     let xs = b"\xED\xA0\x80foo\xED\xBF\xBFbar";
-    assert_eq!(String::from_utf8_lossy(xs), String::from_str("\u{FFFD}\u{FFFD}\u{FFFD}foo\
+    assert_eq!(String::from_utf8_lossy(xs), String::from("\u{FFFD}\u{FFFD}\u{FFFD}foo\
                                            \u{FFFD}\u{FFFD}\u{FFFD}bar").into_cow());
 }
 
 #[test]
 fn test_from_utf16() {
     let pairs =
-        [(String::from_str("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"),
+        [(String::from("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"),
           vec![0xd800, 0xdf45, 0xd800, 0xdf3f,
             0xd800, 0xdf3b, 0xd800, 0xdf46,
             0xd800, 0xdf39, 0xd800, 0xdf3b,
             0xd800, 0xdf30, 0x000a]),
 
-         (String::from_str("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"),
+         (String::from("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"),
           vec![0xd801, 0xdc12, 0xd801,
             0xdc49, 0xd801, 0xdc2e, 0xd801,
             0xdc40, 0xd801, 0xdc32, 0xd801,
@@ -105,7 +105,7 @@ fn test_from_utf16() {
             0xd801, 0xdc32, 0xd801, 0xdc4d,
             0x000a]),
 
-         (String::from_str("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"),
+         (String::from("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"),
           vec![0xd800, 0xdf00, 0xd800, 0xdf16,
             0xd800, 0xdf0b, 0xd800, 0xdf04,
             0xd800, 0xdf11, 0xd800, 0xdf09,
@@ -114,7 +114,7 @@ fn test_from_utf16() {
             0xdf04, 0xd800, 0xdf0b, 0xd800,
             0xdf09, 0xd800, 0xdf11, 0x000a ]),
 
-         (String::from_str("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n"),
+         (String::from("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n"),
           vec![0xd801, 0xdc8b, 0xd801, 0xdc98,
             0xd801, 0xdc88, 0xd801, 0xdc91,
             0xd801, 0xdc9b, 0xd801, 0xdc92,
@@ -127,7 +127,7 @@ fn test_from_utf16() {
             0xd801, 0xdc95, 0xd801, 0xdc86,
             0x000a ]),
          // Issue #12318, even-numbered non-BMP planes
-         (String::from_str("\u{20000}"),
+         (String::from("\u{20000}"),
           vec![0xD840, 0xDC00])];
 
     for p in &pairs {
@@ -165,22 +165,22 @@ fn test_utf16_invalid() {
 fn test_from_utf16_lossy() {
     // completely positive cases tested above.
     // lead + eof
-    assert_eq!(String::from_utf16_lossy(&[0xD800]), String::from_str("\u{FFFD}"));
+    assert_eq!(String::from_utf16_lossy(&[0xD800]), String::from("\u{FFFD}"));
     // lead + lead
     assert_eq!(String::from_utf16_lossy(&[0xD800, 0xD800]),
-               String::from_str("\u{FFFD}\u{FFFD}"));
+               String::from("\u{FFFD}\u{FFFD}"));
 
     // isolated trail
-    assert_eq!(String::from_utf16_lossy(&[0x0061, 0xDC00]), String::from_str("a\u{FFFD}"));
+    assert_eq!(String::from_utf16_lossy(&[0x0061, 0xDC00]), String::from("a\u{FFFD}"));
 
     // general
     assert_eq!(String::from_utf16_lossy(&[0xD800, 0xd801, 0xdc8b, 0xD800]),
-               String::from_str("\u{FFFD}𐒋\u{FFFD}"));
+               String::from("\u{FFFD}𐒋\u{FFFD}"));
 }
 
 #[test]
 fn test_push_bytes() {
-    let mut s = String::from_str("ABC");
+    let mut s = String::from("ABC");
     unsafe {
         let mv = s.as_mut_vec();
         mv.push_all(&[b'D']);
@@ -201,7 +201,7 @@ fn test_push_str() {
 
 #[test]
 fn test_push() {
-    let mut data = String::from_str("ประเทศไทย中");
+    let mut data = String::from("ประเทศไทย中");
     data.push('华');
     data.push('b'); // 1 byte
     data.push('¢'); // 2 byte
@@ -212,7 +212,7 @@ fn test_push() {
 
 #[test]
 fn test_pop() {
-    let mut data = String::from_str("ประเทศไทย中华b¢€𤭢");
+    let mut data = String::from("ประเทศไทย中华b¢€𤭢");
     assert_eq!(data.pop().unwrap(), '𤭢'); // 4 bytes
     assert_eq!(data.pop().unwrap(), '€'); // 3 bytes
     assert_eq!(data.pop().unwrap(), '¢'); // 2 bytes
@@ -223,7 +223,7 @@ fn test_pop() {
 
 #[test]
 fn test_str_truncate() {
-    let mut s = String::from_str("12345");
+    let mut s = String::from("12345");
     s.truncate(5);
     assert_eq!(s, "12345");
     s.truncate(3);
@@ -231,7 +231,7 @@ fn test_str_truncate() {
     s.truncate(0);
     assert_eq!(s, "");
 
-    let mut s = String::from_str("12345");
+    let mut s = String::from("12345");
     let p = s.as_ptr();
     s.truncate(3);
     s.push_str("6");
@@ -242,20 +242,20 @@ fn test_str_truncate() {
 #[test]
 #[should_panic]
 fn test_str_truncate_invalid_len() {
-    let mut s = String::from_str("12345");
+    let mut s = String::from("12345");
     s.truncate(6);
 }
 
 #[test]
 #[should_panic]
 fn test_str_truncate_split_codepoint() {
-    let mut s = String::from_str("\u{FC}"); // ü
+    let mut s = String::from("\u{FC}"); // ü
     s.truncate(1);
 }
 
 #[test]
 fn test_str_clear() {
-    let mut s = String::from_str("12345");
+    let mut s = String::from("12345");
     s.clear();
     assert_eq!(s.len(), 0);
     assert_eq!(s, "");
@@ -263,7 +263,7 @@ fn test_str_clear() {
 
 #[test]
 fn test_str_add() {
-    let a = String::from_str("12345");
+    let a = String::from("12345");
     let b = a + "2";
     let b = b + "2";
     assert_eq!(b.len(), 7);
@@ -473,7 +473,7 @@ fn bench_from_str(b: &mut Bencher) {
     let s = "Hello there, the quick brown fox jumped over the lazy dog! \
              Lorem ipsum dolor sit amet, consectetur. ";
     b.iter(|| {
-        String::from_str(s)
+        String::from(s)
     })
 }
 
index 4ec5cf03364973d241a6c1a19242dc62a522f617..c9a863c096352a944a26f9f8b3e9b490ae80666e 100644 (file)
@@ -1783,7 +1783,7 @@ fn inc_counter(&self) {
     fn give_lifetime(&self) -> ast::Lifetime {
         let mut lifetime;
         loop {
-            let mut s = String::from_str("'");
+            let mut s = String::from("'");
             s.push_str(&num_to_string(self.counter.get()));
             if !self.taken.contains(&s) {
                 lifetime = name_to_dummy_lifetime(
index c416a9810eb0ebedee7b449dc3f3ef106ee2f856..3de91d58740b802fa2031b6cd59fd432463edacb 100644 (file)
@@ -210,7 +210,7 @@ fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
     symbol_hasher.input_str("-");
     symbol_hasher.input_str(&encoder::encoded_ty(tcx, t));
     // Prefix with 'h' so that it never blends into adjacent digits
-    let mut hash = String::from_str("h");
+    let mut hash = String::from("h");
     hash.push_str(&truncated_hash_result(symbol_hasher));
     hash
 }
@@ -294,7 +294,7 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(path: PI,
     // To be able to work on all platforms and get *some* reasonable output, we
     // use C++ name-mangling.
 
-    let mut n = String::from_str("_ZN"); // _Z == Begin name-sequence, N == nested
+    let mut n = String::from("_ZN"); // _Z == Begin name-sequence, N == nested
 
     fn push(n: &mut String, s: &str) {
         let sani = sanitize(s);
index 0513653eb24f5d26bdbb5dbaae59cc58a0624e57..30c72d68fb0e8a690fac2a6ea508ad675de136de 100644 (file)
@@ -318,7 +318,7 @@ fn process_method(&mut self, sig: &ast::MethodSig,
                     scope_id = item.id;
                     match item.node {
                         ast::ItemImpl(_, _, _, _, ref ty, _) => {
-                            let mut result = String::from_str("<");
+                            let mut result = String::from("<");
                             result.push_str(&ty_to_string(&**ty));
 
                             match ty::trait_of_item(&self.analysis.ty_cx,
@@ -1341,7 +1341,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
                     return
                 }
 
-                let mut id = String::from_str("$");
+                let mut id = String::from("$");
                 id.push_str(&ex.id.to_string());
                 self.process_formals(&decl.inputs, &id);
 
index c6dc1c9b7074eff3c8c1be70086f09c0445fae25..1249d22946f65b08f9c36af36fefab1a304be505 100644 (file)
@@ -152,7 +152,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Data {
 
                 // If the variable is immutable, save the initialising expression.
                 let (value, keyword) = match mt {
-                    ast::MutMutable => (String::from_str("<mutable>"), keywords::Mut),
+                    ast::MutMutable => (String::from("<mutable>"), keywords::Mut),
                     ast::MutImmutable => (self.span_utils.snippet(expr.span), keywords::Static),
                 };
 
@@ -326,7 +326,7 @@ pub fn process_crate(sess: &Session,
         Some(name) => name.to_string(),
         None => {
             info!("Could not find crate name, using 'unknown_crate'");
-            String::from_str("unknown_crate")
+            String::from("unknown_crate")
         },
     };
 
index 193902d981d690b30cf3795d6f58af419818038e..c7759f4266ba5901efc5f0f7f906ee9e09e224dd 100644 (file)
@@ -178,7 +178,7 @@ pub fn make_values_str(&self,
         });
 
         let pairs = fields.iter().zip(values);
-        let strs = pairs.map(|(f, v)| format!(",{},\"{}\"", f, escape(String::from_str(v))));
+        let strs = pairs.map(|(f, v)| format!(",{},\"{}\"", f, escape(String::from(v))));
         Some(strs.fold(String::new(), |mut s, ss| {
             s.push_str(&ss[..]);
             s
@@ -207,7 +207,7 @@ pub fn record_without_span(&mut self,
             None => return,
         };
 
-        let mut result = String::from_str(label);
+        let mut result = String::from(label);
         result.push_str(&values_str[..]);
         result.push_str("\n");
         self.recorder.record(&result[..]);
@@ -269,7 +269,7 @@ pub fn variable_str(&mut self,
         // the local case they can be overridden in one block and there is no nice way
         // to refer to such a scope in english, so we just hack it by appending the
         // variable def's node id
-        let mut qualname = String::from_str(name);
+        let mut qualname = String::from(name);
         qualname.push_str("$");
         qualname.push_str(&id.to_string());
         self.check_and_record(Variable,
@@ -286,7 +286,7 @@ pub fn formal_str(&mut self,
                       fn_name: &str,
                       name: &str,
                       typ: &str) {
-        let mut qualname = String::from_str(fn_name);
+        let mut qualname = String::from(fn_name);
         qualname.push_str("::");
         qualname.push_str(name);
         self.check_and_record(Variable,
index c3ac805af27ec1fcd6b5d684af0f353cb987b93d..08cbd777c095cdefc09644f86761b0c7b4ffb050 100644 (file)
@@ -83,7 +83,7 @@ pub fn retokenise_span(&self, span: Span) -> StringReader<'a> {
         // the codemap as a new filemap. This is mostly OK, but means we should
         // not iterate over the codemap. Also, any spans over the new filemap
         // are incompatible with spans over other filemaps.
-        let filemap = self.sess.codemap().new_filemap(String::from_str("<anon-dxr>"),
+        let filemap = self.sess.codemap().new_filemap(String::from("<anon-dxr>"),
                                                       self.snippet(span));
         let s = self.sess;
         lexer::StringReader::new(s.diagnostic(), filemap)
index 497e0ae422c1fa3659c17eadb3e0140b518f5956..9ba1f84407c51eb4327144db0fa9b55d65b022a5 100644 (file)
@@ -71,7 +71,7 @@ pub fn count_insn(&self, category: &str) {
                 // Pass 2: concat strings for each elt, skipping
                 // forwards over any cycles by advancing to rightmost
                 // occurrence of each element in path.
-                let mut s = String::from_str(".");
+                let mut s = String::from(".");
                 i = 0;
                 while i < len {
                     i = mm[v[i]];
index f9ad3d1a857f11cd751f3e3977a2daa27b472a2e..71312bb60a2a59b4692e782278412b8c309f68d5 100644 (file)
@@ -331,7 +331,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
     // Get_template_parameters() will append a `<...>` clause to the function
     // name if necessary.
-    let mut function_name = String::from_str(&token::get_name(name));
+    let mut function_name = String::from(&*token::get_name(name));
     let template_parameters = get_template_parameters(cx,
                                                       generics,
                                                       param_substs,
index 0aa0408c0ef33c31a89fd1566901207dfa7b56cb..a41a62dcd4cfafab3ef1bad2608e476119babb19 100644 (file)
@@ -41,7 +41,7 @@ fn fill_nested(node: &NamespaceTreeNode, output: &mut String) {
             output.push_str(&string);
         }
 
-        let mut name = String::from_str("_ZN");
+        let mut name = String::from("_ZN");
         fill_nested(self, &mut name);
         name.push_str(&format!("{}", item_name.len()));
         name.push_str(item_name);
index 0be8570f904835875ba883c47360f12bf6d37c93..088ada74872553c620290aacc94c5db1a63c3d85 100644 (file)
@@ -2521,7 +2521,7 @@ fn lit_to_string(lit: &ast::Lit) -> String {
         ast::LitStr(ref st, _) => st.to_string(),
         ast::LitBinary(ref data) => format!("{:?}", data),
         ast::LitByte(b) => {
-            let mut res = String::from_str("b'");
+            let mut res = String::from("b'");
             for c in (b as char).escape_default() {
                 res.push(c);
             }
index 3929630267ac1469513dd543d23377e421dd4c0d..9439fc3c5f405ffedf729376462f0dc3f5c491e6 100644 (file)
@@ -335,8 +335,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, path: &clean::Path,
     if print_all {
         let amt = path.segments.len() - 1;
         match rel_root {
-            Some(root) => {
-                let mut root = String::from_str(&root);
+            Some(mut root) => {
                 for seg in &path.segments[..amt] {
                     if "super" == seg.name || "self" == seg.name {
                         try!(write!(w, "{}::", seg.name));
index c4f2c7207ac39520aa2aa72da7db49df88812572..ebf4b29a69664f49c2975eee8d733190899a9e14 100644 (file)
@@ -817,7 +817,7 @@ fn emit_source(&mut self, filename: &str) -> io::Result<()> {
 
         // Create the intermediate directories
         let mut cur = self.dst.clone();
-        let mut root_path = String::from_str("../../");
+        let mut root_path = String::from("../../");
         clean_srcpath(&self.cx.src_root, &p, false, |component| {
             cur.push(component);
             mkdir(&cur).unwrap();
index 93aa74d7005f6d8989cbae865218d8d421165596..8f3e63820dac9ca30382c143a562278539b9e0b8 100644 (file)
@@ -145,7 +145,7 @@ pub fn push<'a>(&'a mut self, level: u32, name: String, id: String) -> &'a str {
                     (0, &self.top_level)
                 }
                 Some(entry) => {
-                    sec_number = String::from_str(&entry.sec_number);
+                    sec_number = entry.sec_number.clone();
                     sec_number.push_str(".");
                     (entry.level, &entry.children)
                 }
index d4d214f449d5921733ca9c2c9c9140e23b02fd9b..e48651a154eb067ecbfb7990c1c04c6b0ac17484 100644 (file)
@@ -90,7 +90,7 @@ fn libname(mut n: String) -> String {
 
 #[cfg(all(not(target_os="windows"), not(target_os="macos")))]
 fn libname(n: String) -> String {
-    let mut i = String::from_str("lib");
+    let mut i = String::from("lib");
     i.push_str(&n);
     i.push_str(".so");
     i
index 24cc7fe878af471ff13af8c73e9127175bce8402..0096d8d22ae8a1827f43d558713873e86f281976 100644 (file)
@@ -457,7 +457,7 @@ fn spaces(wr: &mut fmt::Write, mut n: usize) -> EncodeResult {
 
 fn fmt_number_or_null(v: f64) -> string::String {
     match v.classify() {
-        Fp::Nan | Fp::Infinite => string::String::from_str("null"),
+        Fp::Nan | Fp::Infinite => string::String::from("null"),
         _ if v.fract() != 0f64 => v.to_string(),
         _ => v.to_string() + ".0",
     }
index 6d23df970000cab16ce5dbfa8473788abcb16875..328c75b6d9e20b92097a1f8af038b7242ab99f08 100644 (file)
@@ -121,7 +121,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, 'b> From<&'b str> for Box<Error + Send + Sync + 'a> {
     fn from(err: &'b str) -> Box<Error + Send + Sync + 'a> {
-        From::from(String::from_str(err))
+        From::from(String::from(err))
     }
 }
 
index cb9239ed7ba57032fb320a6614d68adac27ee1b3..b2dc01e3ccb199a52c0af28ee8052f66f0fc70e8 100644 (file)
@@ -906,8 +906,8 @@ fn wtf8buf_from_str() {
 
     #[test]
     fn wtf8buf_from_string() {
-        assert_eq!(Wtf8Buf::from_string(String::from_str("")).bytes, b"");
-        assert_eq!(Wtf8Buf::from_string(String::from_str("aé 💩")).bytes,
+        assert_eq!(Wtf8Buf::from_string(String::from("")).bytes, b"");
+        assert_eq!(Wtf8Buf::from_string(String::from("aé 💩")).bytes,
                    b"a\xC3\xA9 \xF0\x9F\x92\xA9");
     }
 
@@ -1049,7 +1049,7 @@ fn wtf8buf_truncate_fail_longer() {
     #[test]
     fn wtf8buf_into_string() {
         let mut string = Wtf8Buf::from_str("aé 💩");
-        assert_eq!(string.clone().into_string(), Ok(String::from_str("aé 💩")));
+        assert_eq!(string.clone().into_string(), Ok(String::from("aé 💩")));
         string.push(CodePoint::from_u32(0xD800).unwrap());
         assert_eq!(string.clone().into_string(), Err(string));
     }
@@ -1057,9 +1057,9 @@ fn wtf8buf_into_string() {
     #[test]
     fn wtf8buf_into_string_lossy() {
         let mut string = Wtf8Buf::from_str("aé 💩");
-        assert_eq!(string.clone().into_string_lossy(), String::from_str("aé 💩"));
+        assert_eq!(string.clone().into_string_lossy(), String::from("aé 💩"));
         string.push(CodePoint::from_u32(0xD800).unwrap());
-        assert_eq!(string.clone().into_string_lossy(), String::from_str("aé 💩�"));
+        assert_eq!(string.clone().into_string_lossy(), String::from("aé 💩�"));
     }
 
     #[test]
@@ -1226,7 +1226,7 @@ fn wtf8_to_string_lossy() {
         assert_eq!(Wtf8::from_str("aé 💩").to_string_lossy(), Cow::Borrowed("aé 💩"));
         let mut string = Wtf8Buf::from_str("aé 💩");
         string.push(CodePoint::from_u32(0xD800).unwrap());
-        let expected: Cow<str> = Cow::Owned(String::from_str("aé 💩�"));
+        let expected: Cow<str> = Cow::Owned(String::from("aé 💩�"));
         assert_eq!(string.to_string_lossy(), expected);
     }
 
index da86e727c6874bb028e9de02c705462fbf88a708..ab513f0105b41d5a245c744ea576784c4ecb15a8 100644 (file)
@@ -127,7 +127,7 @@ enum NamePadding {
 
 impl TestDesc {
     fn padded_name(&self, column_count: usize, align: NamePadding) -> String {
-        let mut name = String::from_str(self.name.as_slice());
+        let mut name = String::from(self.name.as_slice());
         let fill = column_count.saturating_sub(name.len());
         let pad = repeat(" ").take(fill).collect::<String>();
         match align {
index e6e9bf6e6367fabf04e5340592982b3938824b3d..cff431065ffedc951206df31122a9355b17a4043 100644 (file)
@@ -12,7 +12,7 @@
 #![feature(collections)]
 
 fn main() {
-    let mut escaped = String::from_str("");
+    let mut escaped = String::from("");
     for c in '\u{10401}'.escape_unicode() {
         escaped.push(c);
     }
index 0013cb292e1c7d87c4914b711910be61dfc55d52..6cc8751c554ca6ce01b6990f745258621e4e8b22 100644 (file)
@@ -41,12 +41,12 @@ fn test_append() {
     s.push_str("a");
     assert_eq!(s, "a");
 
-    let mut s = String::from_str("a");
+    let mut s = String::from("a");
     s.push_str("b");
     println!("{}", s.clone());
     assert_eq!(s, "ab");
 
-    let mut s = String::from_str("c");
+    let mut s = String::from("c");
     s.push_str("offee");
     assert!(s == "coffee");
 
index bfad79e92d2c2c71eb38343ae66d8e83ead6afba..83c2dadcd2f7c35a5d6772c7b3c3ca242c32709b 100644 (file)
@@ -19,7 +19,7 @@ pub fn main() {
     assert_eq!(s, "⨐⨁⪠");
 
     let s = "\\{20}";
-    let mut correct_s = String::from_str("\\");
+    let mut correct_s = String::from("\\");
     correct_s.push_str("{20}");
     assert_eq!(s, correct_s);
 }
index 5e924d015b619ca712aa6101f2c89794d21199a5..ed3ddb43b261734b1911d838e6d68cdde2cccfc2 100644 (file)
@@ -34,7 +34,7 @@ pub fn main() {
     let s = Rc::new("foo".to_string());
     assert_eq!(&**s, "foo");
 
-    let mut_s = Rc::new(RefCell::new(String::from_str("foo")));
+    let mut_s = Rc::new(RefCell::new(String::from("foo")));
     mut_s.borrow_mut().push_str("bar");
     // HACK assert_eq! would panic here because it stores the LHS and RHS in two locals.
     assert!(&**mut_s.borrow() == "foobar");
index 6d8bb30c83755ffd37a5928d6f4ee5ec61ec53d2..3590b7c616cffe37d899e93502300162afecb57b 100644 (file)
@@ -34,7 +34,7 @@ pub fn main() {
     assert_eq!(*s, "foo".to_string());
     assert_eq!((*s), "foo");
 
-    let mut_s = Rc::new(RefCell::new(String::from_str("foo")));
+    let mut_s = Rc::new(RefCell::new(String::from("foo")));
     (*(*mut_s).borrow_mut()).push_str("bar");
     // assert_eq! would panic here because it stores the LHS and RHS in two locals.
     assert!((*(*mut_s).borrow()) == "foobar");
index 7ff770327742baaf8c36e0d24126dda278073581..e4ca5515653cbb5035b19489d385f023a3888a71 100644 (file)
@@ -17,7 +17,7 @@ enum t { a, b(String), }
 
 fn make(i: isize) -> t {
     if i > 10 { return t::a; }
-    let mut s = String::from_str("hello");
+    let mut s = String::from("hello");
     // Ensure s is non-const.
 
     s.push_str("there");