about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/util/common.rs3
-rw-r--r--src/librustdoc/html/render.rs2
-rw-r--r--src/libstd/fs.rs10
3 files changed, 8 insertions, 7 deletions
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs
index 96b77d351e2..6b896a889e3 100644
--- a/src/librustc/util/common.rs
+++ b/src/librustc/util/common.rs
@@ -244,7 +244,8 @@ fn get_resident() -> Option<usize> {
     use std::fs;
 
     let field = 1;
-    let contents = fs::read_string("/proc/self/statm").ok()?;
+    let contents = fs::read("/proc/self/statm").ok()?;
+    let contents = String::from_utf8(contents).ok()?;
     let s = contents.split_whitespace().nth(field)?;
     let npages = s.parse::<usize>().ok()?;
     Some(npages * 4096)
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index ff6cc56e5b4..d915bab7919 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1067,7 +1067,7 @@ impl<'a> SourceCollector<'a> {
             return Ok(());
         }
 
-        let contents = fs::read_string(&p)?;
+        let contents = fs::read_to_string(&p)?;
 
         // Remove the utf-8 BOM if any
         let contents = if contents.starts_with("\u{feff}") {
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index 1b2ed2f6eb6..479e4d08f4b 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -297,12 +297,12 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
 /// use std::net::SocketAddr;
 ///
 /// fn main() -> Result<(), Box<std::error::Error + 'static>> {
-///     let foo: SocketAddr = fs::read_string("address.txt")?.parse()?;
+///     let foo: SocketAddr = fs::read_to_string("address.txt")?.parse()?;
 ///     Ok(())
 /// }
 /// ```
-#[unstable(feature = "fs_read_write", issue = "46588")]
-pub fn read_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
+#[stable(feature = "fs_read_write", since = "1.26.0")]
+pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
     let mut file = File::open(path)?;
     let mut string = String::with_capacity(initial_buffer_size(&file));
     file.read_to_string(&mut string)?;
@@ -3122,12 +3122,12 @@ mod tests {
         assert!(v == &bytes[..]);
 
         check!(fs::write(&tmpdir.join("not-utf8"), &[0xFF]));
-        error_contains!(fs::read_string(&tmpdir.join("not-utf8")),
+        error_contains!(fs::read_to_string(&tmpdir.join("not-utf8")),
                         "stream did not contain valid UTF-8");
 
         let s = "𐁁𐀓𐀠𐀴𐀍";
         check!(fs::write(&tmpdir.join("utf8"), s.as_bytes()));
-        let string = check!(fs::read_string(&tmpdir.join("utf8")));
+        let string = check!(fs::read_to_string(&tmpdir.join("utf8")));
         assert_eq!(string, s);
     }