Skip to content

Commit b422373

Browse files
committed
auto merge of #15426 : aochagavia/rust/str, r=alexcrichton
* Deprecated `str::from_utf8_owned` in favor of `String::from_utf8` * Deprecated `str::from_utf8_lossy` in favor of `String::from_utf8_lossy` * Deprecated `str::from_utf16` in favor of `String::from_utf16` * Deprecated `str::from_utf16_lossy` in favor of `String::from_utf16_lossy` * Deprecated `str::from_chars` in favor of `String::from_chars` * Deprecated `str::from_char` in favor of `String::from_char` and `.to_string()` * Deprecated `str::from_byte` in favor of `String::from_byte` [breaking-change]
2 parents cd54321 + 584fbde commit b422373

File tree

41 files changed

+534
-563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+534
-563
lines changed

src/compiletest/procsrv.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::str;
1211
use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
1312
use std::dynamic_lib::DynamicLibrary;
1413

@@ -25,7 +24,7 @@ fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
2524
// Add the new dylib search path var
2625
let var = DynamicLibrary::envvar();
2726
let newpath = DynamicLibrary::create_path(path.as_slice());
28-
let newpath = str::from_utf8(newpath.as_slice()).unwrap().to_string();
27+
let newpath = String::from_utf8(newpath).unwrap();
2928
cmd.env(var.to_string(), newpath);
3029
}
3130

@@ -55,8 +54,8 @@ pub fn run(lib_path: &str,
5554

5655
Some(Result {
5756
status: status,
58-
out: str::from_utf8(output.as_slice()).unwrap().to_string(),
59-
err: str::from_utf8(error.as_slice()).unwrap().to_string()
57+
out: String::from_utf8(output).unwrap(),
58+
err: String::from_utf8(error).unwrap()
6059
})
6160
},
6261
Err(..) => None

src/compiletest/runtest.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
158158
match props.pp_exact { Some(_) => 1, None => 2 };
159159

160160
let src = File::open(testfile).read_to_end().unwrap();
161-
let src = str::from_utf8(src.as_slice()).unwrap().to_string();
161+
let src = String::from_utf8(src.clone()).unwrap();
162162
let mut srcs = vec!(src);
163163

164164
let mut round = 0;
@@ -185,10 +185,10 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
185185
Some(ref file) => {
186186
let filepath = testfile.dir_path().join(file);
187187
let s = File::open(&filepath).read_to_end().unwrap();
188-
str::from_utf8(s.as_slice()).unwrap().to_string()
189-
}
190-
None => { (*srcs.get(srcs.len() - 2u)).clone() }
191-
};
188+
String::from_utf8(s).unwrap()
189+
}
190+
None => { (*srcs.get(srcs.len() - 2u)).clone() }
191+
};
192192
let mut actual = (*srcs.get(srcs.len() - 1u)).clone();
193193

194194
if props.pp_exact.is_some() {
@@ -582,8 +582,8 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
582582
process.wait_with_output().unwrap();
583583

584584
(status,
585-
str::from_utf8(output.as_slice()).unwrap().to_string(),
586-
str::from_utf8(error.as_slice()).unwrap().to_string())
585+
String::from_utf8(output).unwrap(),
586+
String::from_utf8(error).unwrap())
587587
},
588588
Err(e) => {
589589
fatal(format!("Failed to setup Python process for \
@@ -813,7 +813,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
813813
c
814814
}
815815
} ).collect();
816-
str::from_chars(c.as_slice()).to_string()
816+
String::from_chars(c.as_slice())
817817
}
818818

819819
#[cfg(target_os = "win32")]

0 commit comments

Comments
 (0)