about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2014-03-26 09:24:16 -0700
committerSteven Fackler <sfackler@gmail.com>2014-04-06 15:39:56 -0700
commitd0e60b72ee3f5fb07b01143d82362cb42307f32d (patch)
treeed0161843da862f7b40a01b76a81ced97c1e67da
parent94a055c7295bd5822219b86243c2af6fff9d21d3 (diff)
downloadrust-d0e60b72ee3f5fb07b01143d82362cb42307f32d.tar.gz
rust-d0e60b72ee3f5fb07b01143d82362cb42307f32d.zip
De-~[] Reader and Writer
There's a little more allocation here and there now since
from_utf8_owned can't be used with Vec.
-rw-r--r--src/compiletest/procsrv.rs4
-rw-r--r--src/compiletest/runtest.rs6
-rw-r--r--src/librustc/back/archive.rs8
-rw-r--r--src/librustc/back/link.rs11
-rw-r--r--src/librustc/lib.rs2
-rw-r--r--src/librustdoc/html/render.rs2
-rw-r--r--src/librustdoc/markdown.rs2
-rw-r--r--src/librustdoc/test.rs3
-rw-r--r--src/libserialize/json.rs4
-rw-r--r--src/libstd/io/buffered.rs8
-rw-r--r--src/libstd/io/extensions.rs24
-rw-r--r--src/libstd/io/fs.rs10
-rw-r--r--src/libstd/io/mem.rs12
-rw-r--r--src/libstd/io/mod.rs28
-rw-r--r--src/libstd/io/net/tcp.rs4
-rw-r--r--src/libstd/io/process.rs44
-rw-r--r--src/libstd/io/util.rs12
-rw-r--r--src/libsyntax/ext/source_util.rs4
-rw-r--r--src/libsyntax/parse/comments.rs2
-rw-r--r--src/libsyntax/parse/mod.rs7
-rw-r--r--src/libterm/terminfo/parser/compiled.rs4
-rw-r--r--src/libworkcache/lib.rs4
-rw-r--r--src/test/bench/shootout-reverse-complement.rs4
-rw-r--r--src/test/run-make/unicode-input/multiple_files.rs2
-rw-r--r--src/test/run-make/unicode-input/span_length.rs2
-rw-r--r--src/test/run-pass/backtrace.rs8
-rw-r--r--src/test/run-pass/out-of-stack.rs4
27 files changed, 117 insertions, 108 deletions
diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs
index 34918e39182..aa0fb838284 100644
--- a/src/compiletest/procsrv.rs
+++ b/src/compiletest/procsrv.rs
@@ -84,8 +84,8 @@ pub fn run(lib_path: &str,
 
             Some(Result {
                 status: status,
-                out: str::from_utf8_owned(output).unwrap(),
-                err: str::from_utf8_owned(error).unwrap()
+                out: str::from_utf8(output.as_slice()).unwrap().to_owned(),
+                err: str::from_utf8(error.as_slice()).unwrap().to_owned()
             })
         },
         Err(..) => None
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index e057909a06c..b290bd2838a 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -153,7 +153,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
         match props.pp_exact { Some(_) => 1, None => 2 };
 
     let src = File::open(testfile).read_to_end().unwrap();
-    let src = str::from_utf8_owned(src).unwrap();
+    let src = str::from_utf8(src.as_slice()).unwrap().to_owned();
     let mut srcs = vec!(src);
 
     let mut round = 0;
@@ -177,7 +177,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
         Some(ref file) => {
             let filepath = testfile.dir_path().join(file);
             let s = File::open(&filepath).read_to_end().unwrap();
-            str::from_utf8_owned(s).unwrap()
+            str::from_utf8(s.as_slice()).unwrap().to_owned()
           }
           None => { (*srcs.get(srcs.len() - 2u)).clone() }
         };
@@ -1163,7 +1163,7 @@ fn disassemble_extract(config: &config, _props: &TestProps,
 
 fn count_extracted_lines(p: &Path) -> uint {
     let x = File::open(&p.with_extension("ll")).read_to_end().unwrap();
-    let x = str::from_utf8_owned(x).unwrap();
+    let x = str::from_utf8(x.as_slice()).unwrap();
     x.lines().len()
 }
 
diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs
index 6de7bb59b61..eeba816f439 100644
--- a/src/librustc/back/archive.rs
+++ b/src/librustc/back/archive.rs
@@ -59,8 +59,10 @@ fn run_ar(sess: &Session, args: &str, cwd: Option<&Path>,
             if !o.status.success() {
                 sess.err(format!("{} {} failed with: {}", ar, args.connect(" "),
                                  o.status));
-                sess.note(format!("stdout ---\n{}", str::from_utf8(o.output).unwrap()));
-                sess.note(format!("stderr ---\n{}", str::from_utf8(o.error).unwrap()));
+                sess.note(format!("stdout ---\n{}",
+                                  str::from_utf8(o.output.as_slice()).unwrap()));
+                sess.note(format!("stderr ---\n{}",
+                                  str::from_utf8(o.error.as_slice()).unwrap()));
                 sess.abort_if_errors();
             }
             o
@@ -129,7 +131,7 @@ impl<'a> Archive<'a> {
     /// Lists all files in an archive
     pub fn files(&self) -> Vec<~str> {
         let output = run_ar(self.sess, "t", None, [&self.dst]);
-        let output = str::from_utf8(output.output).unwrap();
+        let output = str::from_utf8(output.output.as_slice()).unwrap();
         // use lines_any because windows delimits output with `\r\n` instead of
         // just `\n`
         output.lines_any().map(|s| s.to_owned()).collect()
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index e9292f54a4b..a9fad13fb60 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -337,7 +337,9 @@ pub mod write {
                 if !prog.status.success() {
                     sess.err(format!("linking with `{}` failed: {}", cc, prog.status));
                     sess.note(format!("{} arguments: '{}'", cc, args.connect("' '")));
-                    sess.note(str::from_utf8_owned(prog.error + prog.output).unwrap());
+                    let mut note = prog.error.clone();
+                    note.push_all(prog.output.as_slice());
+                    sess.note(str::from_utf8(note.as_slice()).unwrap().to_owned());
                     sess.abort_if_errors();
                 }
             },
@@ -929,7 +931,8 @@ fn link_rlib<'a>(sess: &'a Session,
             let bc = obj_filename.with_extension("bc");
             let bc_deflated = obj_filename.with_extension("bc.deflate");
             match fs::File::open(&bc).read_to_end().and_then(|data| {
-                fs::File::create(&bc_deflated).write(flate::deflate_bytes(data).as_slice())
+                fs::File::create(&bc_deflated)
+                    .write(flate::deflate_bytes(data.as_slice()).as_slice())
             }) {
                 Ok(()) => {}
                 Err(e) => {
@@ -1025,7 +1028,9 @@ fn link_natively(sess: &Session, dylib: bool, obj_filename: &Path,
             if !prog.status.success() {
                 sess.err(format!("linking with `{}` failed: {}", cc_prog, prog.status));
                 sess.note(format!("{} arguments: '{}'", cc_prog, cc_args.connect("' '")));
-                sess.note(str::from_utf8_owned(prog.error + prog.output).unwrap());
+                let mut output = prog.error.clone();
+                output.push_all(prog.output.as_slice());
+                sess.note(str::from_utf8(output.as_slice()).unwrap().to_owned());
                 sess.abort_if_errors();
             }
         },
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 893cc019ca7..b9c3ef2f266 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -272,7 +272,7 @@ pub fn run_compiler(args: &[~str]) {
         let ifile = matches.free.get(0).as_slice();
         if ifile == "-" {
             let contents = io::stdin().read_to_end().unwrap();
-            let src = str::from_utf8_owned(contents).unwrap();
+            let src = str::from_utf8(contents.as_slice()).unwrap().to_owned();
             (d::StrInput(src), None)
         } else {
             (d::FileInput(Path::new(ifile)), Some(Path::new(ifile)))
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 94b0b21dc9e..a2e2a032a0c 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -487,7 +487,7 @@ impl<'a> SourceCollector<'a> {
                        filename.ends_with("macros>") => return Ok(()),
             Err(e) => return Err(e)
         };
-        let contents = str::from_utf8_owned(contents).unwrap();
+        let contents = str::from_utf8(contents.as_slice()).unwrap();
 
         // Remove the utf-8 BOM if any
         let contents = if contents.starts_with("\ufeff") {
diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs
index d04d39bcee5..be912798442 100644
--- a/src/librustdoc/markdown.rs
+++ b/src/librustdoc/markdown.rs
@@ -22,7 +22,7 @@ use test::Collector;
 fn load_string(input: &Path) -> io::IoResult<Option<~str>> {
     let mut f = try!(io::File::open(input));
     let d = try!(f.read_to_end());
-    Ok(str::from_utf8_owned(d))
+    Ok(str::from_utf8(d.as_slice()).map(|s| s.to_owned()))
 }
 macro_rules! load_or_return {
     ($input: expr, $cant_read: expr, $not_utf8: expr) => {
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index 3ede325997d..06b57780abe 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -159,7 +159,8 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool,
             if should_fail && out.status.success() {
                 fail!("test executable succeeded when it should have failed");
             } else if !should_fail && !out.status.success() {
-                fail!("test executable failed:\n{}", str::from_utf8(out.error));
+                fail!("test executable failed:\n{}",
+                      str::from_utf8(out.error.as_slice()));
             }
         }
     }
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index 2d3e6bc86eb..34e2cbeb15e 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -1282,8 +1282,8 @@ pub fn from_reader(rdr: &mut io::Reader) -> DecodeResult<Json> {
         Ok(c) => c,
         Err(e) => return Err(IoError(e))
     };
-    let s = match str::from_utf8_owned(contents) {
-        Some(s) => s,
+    let s = match str::from_utf8(contents.as_slice()) {
+        Some(s) => s.to_owned(),
         None => return Err(ParseError(~"contents not utf-8", 0, 0))
     };
     let mut parser = Parser::new(s.chars());
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs
index 4da297a25fd..fa977113d6c 100644
--- a/src/libstd/io/buffered.rs
+++ b/src/libstd/io/buffered.rs
@@ -504,10 +504,10 @@ mod test {
     fn test_read_until() {
         let inner = MemReader::new(~[0, 1, 2, 1, 0]);
         let mut reader = BufferedReader::with_capacity(2, inner);
-        assert_eq!(reader.read_until(0), Ok(~[0]));
-        assert_eq!(reader.read_until(2), Ok(~[1, 2]));
-        assert_eq!(reader.read_until(1), Ok(~[1]));
-        assert_eq!(reader.read_until(8), Ok(~[0]));
+        assert_eq!(reader.read_until(0), Ok(vec!(0)));
+        assert_eq!(reader.read_until(2), Ok(vec!(1, 2)));
+        assert_eq!(reader.read_until(1), Ok(vec!(1)));
+        assert_eq!(reader.read_until(8), Ok(vec!(0)));
         assert!(reader.read_until(9).is_err());
     }
 
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs
index a9fe3be585c..10ea3628b86 100644
--- a/src/libstd/io/extensions.rs
+++ b/src/libstd/io/extensions.rs
@@ -323,7 +323,7 @@ mod test {
     fn read_bytes() {
         let mut reader = MemReader::new(~[10, 11, 12, 13]);
         let bytes = reader.read_exact(4).unwrap();
-        assert!(bytes == ~[10, 11, 12, 13]);
+        assert!(bytes == vec!(10, 11, 12, 13));
     }
 
     #[test]
@@ -332,7 +332,7 @@ mod test {
             count: 0,
         };
         let bytes = reader.read_exact(4).unwrap();
-        assert!(bytes == ~[10, 11, 12, 13]);
+        assert!(bytes == vec!(10, 11, 12, 13));
     }
 
     #[test]
@@ -344,9 +344,9 @@ mod test {
     #[test]
     fn push_exact() {
         let mut reader = MemReader::new(~[10, 11, 12, 13]);
-        let mut buf = ~[8, 9];
+        let mut buf = vec!(8, 9);
         reader.push_exact(&mut buf, 4).unwrap();
-        assert!(buf == ~[8, 9, 10, 11, 12, 13]);
+        assert!(buf == vec!(8, 9, 10, 11, 12, 13));
     }
 
     #[test]
@@ -354,17 +354,17 @@ mod test {
         let mut reader = PartialReader {
             count: 0,
         };
-        let mut buf = ~[8, 9];
+        let mut buf = vec!(8, 9);
         reader.push_exact(&mut buf, 4).unwrap();
-        assert!(buf == ~[8, 9, 10, 11, 12, 13]);
+        assert!(buf == vec!(8, 9, 10, 11, 12, 13));
     }
 
     #[test]
     fn push_exact_eof() {
         let mut reader = MemReader::new(~[10, 11]);
-        let mut buf = ~[8, 9];
+        let mut buf = vec!(8, 9);
         assert!(reader.push_exact(&mut buf, 4).is_err());
-        assert!(buf == ~[8, 9, 10, 11]);
+        assert!(buf == vec!(8, 9, 10, 11));
     }
 
     #[test]
@@ -372,9 +372,9 @@ mod test {
         let mut reader = ErroringLaterReader {
             count: 0,
         };
-        let mut buf = ~[8, 9];
+        let mut buf = vec!(8, 9);
         assert!(reader.push_exact(&mut buf, 4).is_err());
-        assert!(buf == ~[8, 9, 10]);
+        assert!(buf == vec!(8, 9, 10));
     }
 
     #[test]
@@ -383,7 +383,7 @@ mod test {
             count: 0,
         };
         let buf = reader.read_to_end().unwrap();
-        assert!(buf == ~[10, 11, 12, 13]);
+        assert!(buf == vec!(10, 11, 12, 13));
     }
 
     #[test]
@@ -393,7 +393,7 @@ mod test {
             count: 0,
         };
         let buf = reader.read_to_end().unwrap();
-        assert!(buf == ~[10, 11]);
+        assert!(buf == vec!(10, 11));
     }
 
     #[test]
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs
index 410b841545e..2fea002d419 100644
--- a/src/libstd/io/fs.rs
+++ b/src/libstd/io/fs.rs
@@ -1074,7 +1074,7 @@ mod test {
         check!(copy(&input, &output));
 
         assert_eq!(check!(File::open(&output).read_to_end()),
-                   (bytes!("foo")).to_owned());
+                   (Vec::from_slice(bytes!("foo"))));
     })
 
     iotest!(fn copy_file_src_dir() {
@@ -1114,7 +1114,7 @@ mod test {
         }
         assert_eq!(check!(stat(&out)).size, check!(stat(&input)).size);
         assert_eq!(check!(File::open(&out).read_to_end()),
-                   (bytes!("foobar")).to_owned());
+                   (Vec::from_slice(bytes!("foobar"))));
     })
 
     #[cfg(not(windows))] // apparently windows doesn't like symlinks
@@ -1146,7 +1146,7 @@ mod test {
         }
         assert_eq!(check!(stat(&out)).size, check!(stat(&input)).size);
         assert_eq!(check!(File::open(&out).read_to_end()),
-                   (bytes!("foobar")).to_owned());
+                   (Vec::from_slice(bytes!("foobar"))));
 
         // can't link to yourself
         match link(&input, &input) {
@@ -1206,7 +1206,7 @@ mod test {
         check!(file.fsync());
         assert_eq!(check!(stat(&path)).size, 10);
         assert_eq!(check!(File::open(&path).read_to_end()),
-                   (bytes!("foobar", 0, 0, 0, 0)).to_owned());
+                   (Vec::from_slice(bytes!("foobar", 0, 0, 0, 0))));
 
         // Truncate to a smaller length, don't seek, and then write something.
         // Ensure that the intermediate zeroes are all filled in (we're seeked
@@ -1217,7 +1217,7 @@ mod test {
         check!(file.fsync());
         assert_eq!(check!(stat(&path)).size, 9);
         assert_eq!(check!(File::open(&path).read_to_end()),
-                   (bytes!("fo", 0, 0, 0, 0, "wut")).to_owned());
+                   (Vec::from_slice(bytes!("fo", 0, 0, 0, 0, "wut"))));
         drop(file);
     })
 
diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs
index e9c6b5b01da..ee9432ca73b 100644
--- a/src/libstd/io/mem.rs
+++ b/src/libstd/io/mem.rs
@@ -129,7 +129,7 @@ impl Seek for MemWriter {
 ///
 /// let mut r = MemReader::new(~[0, 1, 2]);
 ///
-/// assert_eq!(r.read_to_end().unwrap(), ~[0, 1, 2]);
+/// assert_eq!(r.read_to_end().unwrap(), vec!(0, 1, 2));
 /// ```
 pub struct MemReader {
     buf: ~[u8],
@@ -272,7 +272,7 @@ impl<'a> Seek for BufWriter<'a> {
 /// let mut buf = [0, 1, 2, 3];
 /// let mut r = BufReader::new(buf);
 ///
-/// assert_eq!(r.read_to_end().unwrap(), ~[0, 1, 2, 3]);
+/// assert_eq!(r.read_to_end().unwrap(), vec!(0, 1, 2, 3));
 /// ```
 pub struct BufReader<'a> {
     buf: &'a [u8],
@@ -441,8 +441,8 @@ mod test {
         assert_eq!(buf.slice(0, 3), &[5, 6, 7]);
         assert!(reader.read(buf).is_err());
         let mut reader = MemReader::new(~[0, 1, 2, 3, 4, 5, 6, 7]);
-        assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]);
-        assert_eq!(reader.read_until(3).unwrap(), ~[4, 5, 6, 7]);
+        assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
+        assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7));
         assert!(reader.read(buf).is_err());
     }
 
@@ -465,8 +465,8 @@ mod test {
         assert_eq!(buf.slice(0, 3), &[5, 6, 7]);
         assert!(reader.read(buf).is_err());
         let mut reader = BufReader::new(in_buf);
-        assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]);
-        assert_eq!(reader.read_until(3).unwrap(), ~[4, 5, 6, 7]);
+        assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
+        assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7));
         assert!(reader.read(buf).is_err());
     }
 
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 403e0e48fd5..97519adbc3f 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -225,8 +225,8 @@ use str::{StrSlice, OwnedStr};
 use str;
 use uint;
 use unstable::finally::try_finally;
-use slice::{OwnedVector, MutableVector, ImmutableVector, OwnedCloneableVector};
-use slice;
+use slice::{Vector, OwnedVector, MutableVector, ImmutableVector, OwnedCloneableVector};
+use vec::Vec;
 
 // Reexports
 pub use self::stdio::stdin;
@@ -486,9 +486,9 @@ pub trait Reader {
     /// or EOF. If `Ok(())` is returned, then all of the requested bytes were
     /// pushed on to the vector, otherwise the amount `len` bytes couldn't be
     /// read (an error was encountered), and the error is returned.
-    fn push_exact(&mut self, buf: &mut ~[u8], len: uint) -> IoResult<()> {
+    fn push_exact(&mut self, buf: &mut Vec<u8>, len: uint) -> IoResult<()> {
         struct State<'a> {
-            buf: &'a mut ~[u8],
+            buf: &'a mut Vec<u8>,
             total_read: uint
         }
 
@@ -526,8 +526,8 @@ pub trait Reader {
     /// have already been consumed from the underlying reader, and they are lost
     /// (not returned as part of the error). If this is unacceptable, then it is
     /// recommended to use the `push_exact` or `read` methods.
-    fn read_exact(&mut self, len: uint) -> IoResult<~[u8]> {
-        let mut buf = slice::with_capacity(len);
+    fn read_exact(&mut self, len: uint) -> IoResult<Vec<u8>> {
+        let mut buf = Vec::with_capacity(len);
         match self.push_exact(&mut buf, len) {
             Ok(()) => Ok(buf),
             Err(e) => Err(e),
@@ -542,8 +542,8 @@ pub trait Reader {
     /// discarded when an error is returned.
     ///
     /// When EOF is encountered, all bytes read up to that point are returned.
-    fn read_to_end(&mut self) -> IoResult<~[u8]> {
-        let mut buf = slice::with_capacity(DEFAULT_BUF_SIZE);
+    fn read_to_end(&mut self) -> IoResult<Vec<u8>> {
+        let mut buf = Vec::with_capacity(DEFAULT_BUF_SIZE);
         loop {
             match self.push_exact(&mut buf, DEFAULT_BUF_SIZE) {
                 Ok(()) => {}
@@ -564,8 +564,8 @@ pub trait Reader {
     /// UTF-8 bytes.
     fn read_to_str(&mut self) -> IoResult<~str> {
         self.read_to_end().and_then(|s| {
-            match str::from_utf8_owned(s) {
-                Some(s) => Ok(s),
+            match str::from_utf8(s.as_slice()) {
+                Some(s) => Ok(s.to_owned()),
                 None => Err(standard_error(InvalidInput)),
             }
         })
@@ -1198,8 +1198,8 @@ pub trait Buffer: Reader {
     /// valid UTF-8 sequence of bytes.
     fn read_line(&mut self) -> IoResult<~str> {
         self.read_until('\n' as u8).and_then(|line|
-            match str::from_utf8_owned(line) {
-                Some(s) => Ok(s),
+            match str::from_utf8(line.as_slice()) {
+                Some(s) => Ok(s.to_owned()),
                 None => Err(standard_error(InvalidInput)),
             }
         )
@@ -1230,8 +1230,8 @@ pub trait Buffer: Reader {
     /// have been read, otherwise the pending byte buffer is returned. This
     /// is the reason that the byte buffer returned may not always contain the
     /// delimiter.
-    fn read_until(&mut self, byte: u8) -> IoResult<~[u8]> {
-        let mut res = ~[];
+    fn read_until(&mut self, byte: u8) -> IoResult<Vec<u8>> {
+        let mut res = Vec::new();
 
         let mut used;
         loop {
diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs
index b4dcd204479..02c061c54dd 100644
--- a/src/libstd/io/net/tcp.rs
+++ b/src/libstd/io/net/tcp.rs
@@ -718,14 +718,14 @@ mod test {
         spawn(proc() {
             let mut a = a;
             let mut c = a.accept().unwrap();
-            assert_eq!(c.read_to_end(), Ok(~[]));
+            assert_eq!(c.read_to_end(), Ok(vec!()));
             c.write([1]).unwrap();
         });
 
         let mut s = TcpStream::connect(addr).unwrap();
         assert!(s.obj.close_write().is_ok());
         assert!(s.write([1]).is_err());
-        assert_eq!(s.read_to_end(), Ok(~[1]));
+        assert_eq!(s.read_to_end(), Ok(vec!(1)));
     })
 }
 
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index 1f067021825..f0b96e2e76c 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -142,9 +142,9 @@ pub struct ProcessOutput {
     /// The status (exit code) of the process.
     pub status: ProcessExit,
     /// The data that the process wrote to stdout.
-    pub output: ~[u8],
+    pub output: Vec<u8>,
     /// The data that the process wrote to stderr.
-    pub error: ~[u8],
+    pub error: Vec<u8>,
 }
 
 /// Describes what to do with a standard io stream for a child process.
@@ -277,8 +277,8 @@ impl Process {
     /// };
     ///
     /// println!("status: {}", output.status);
-    /// println!("stdout: {}", str::from_utf8_lossy(output.output));
-    /// println!("stderr: {}", str::from_utf8_lossy(output.error));
+    /// println!("stdout: {}", str::from_utf8_lossy(output.output.as_slice()));
+    /// println!("stderr: {}", str::from_utf8_lossy(output.error.as_slice()));
     /// ```
     pub fn output(prog: &str, args: &[~str]) -> IoResult<ProcessOutput> {
         Process::new(prog, args).map(|mut p| p.wait_with_output())
@@ -387,14 +387,14 @@ impl Process {
     /// The stdin handle to the child is closed before waiting.
     pub fn wait_with_output(&mut self) -> ProcessOutput {
         drop(self.stdin.take());
-        fn read(stream: Option<io::PipeStream>) -> Receiver<IoResult<~[u8]>> {
+        fn read(stream: Option<io::PipeStream>) -> Receiver<IoResult<Vec<u8>>> {
             let (tx, rx) = channel();
             match stream {
                 Some(stream) => spawn(proc() {
                     let mut stream = stream;
                     tx.send(stream.read_to_end())
                 }),
-                None => tx.send(Ok(~[]))
+                None => tx.send(Ok(Vec::new()))
             }
             rx
         }
@@ -404,8 +404,8 @@ impl Process {
         let status = self.wait();
 
         ProcessOutput { status: status,
-                        output: stdout.recv().ok().unwrap_or(~[]),
-                        error:  stderr.recv().ok().unwrap_or(~[]) }
+                        output: stdout.recv().ok().unwrap_or(Vec::new()),
+                        error:  stderr.recv().ok().unwrap_or(Vec::new()) }
     }
 }
 
@@ -614,13 +614,13 @@ mod tests {
 
         let ProcessOutput {status, output, error}
              = Process::output("echo", [~"hello"]).unwrap();
-        let output_str = str::from_utf8_owned(output).unwrap();
+        let output_str = str::from_utf8(output.as_slice()).unwrap();
 
         assert!(status.success());
         assert_eq!(output_str.trim().to_owned(), ~"hello");
         // FIXME #7224
         if !running_on_valgrind() {
-            assert_eq!(error, ~[]);
+            assert_eq!(error, Vec::new());
         }
     })
 
@@ -630,7 +630,7 @@ mod tests {
              = Process::output("mkdir", [~"."]).unwrap();
 
         assert!(status.matches_exit_status(1));
-        assert_eq!(output, ~[]);
+        assert_eq!(output, Vec::new());
         assert!(!error.is_empty());
     })
 
@@ -652,13 +652,13 @@ mod tests {
 
         let mut prog = Process::new("echo", [~"hello"]).unwrap();
         let ProcessOutput {status, output, error} = prog.wait_with_output();
-        let output_str = str::from_utf8_owned(output).unwrap();
+        let output_str = str::from_utf8(output.as_slice()).unwrap();
 
         assert!(status.success());
         assert_eq!(output_str.trim().to_owned(), ~"hello");
         // FIXME #7224
         if !running_on_valgrind() {
-            assert_eq!(error, ~[]);
+            assert_eq!(error, Vec::new());
         }
     })
 
@@ -667,22 +667,22 @@ mod tests {
         let mut prog = Process::new("echo", [~"hello"]).unwrap();
         let ProcessOutput {status, output, error} = prog.wait_with_output();
 
-        let output_str = str::from_utf8_owned(output).unwrap();
+        let output_str = str::from_utf8(output.as_slice()).unwrap();
 
         assert!(status.success());
         assert_eq!(output_str.trim().to_owned(), ~"hello");
         // FIXME #7224
         if !running_on_valgrind() {
-            assert_eq!(error, ~[]);
+            assert_eq!(error, Vec::new());
         }
 
         let ProcessOutput {status, output, error} = prog.wait_with_output();
 
         assert!(status.success());
-        assert_eq!(output, ~[]);
+        assert_eq!(output, Vec::new());
         // FIXME #7224
         if !running_on_valgrind() {
-            assert_eq!(error, ~[]);
+            assert_eq!(error, Vec::new());
         }
     })
 
@@ -718,7 +718,7 @@ mod tests {
         use os;
         let mut prog = run_pwd(None);
 
-        let output = str::from_utf8_owned(prog.wait_with_output().output).unwrap();
+        let output = str::from_utf8(prog.wait_with_output().output.as_slice()).unwrap().to_owned();
         let parent_dir = os::getcwd();
         let child_dir = Path::new(output.trim());
 
@@ -736,7 +736,7 @@ mod tests {
         let parent_dir = os::getcwd().dir_path();
         let mut prog = run_pwd(Some(&parent_dir));
 
-        let output = str::from_utf8_owned(prog.wait_with_output().output).unwrap();
+        let output = str::from_utf8(prog.wait_with_output().output.as_slice()).unwrap().to_owned();
         let child_dir = Path::new(output.trim());
 
         let parent_stat = parent_dir.stat().unwrap();
@@ -780,7 +780,7 @@ mod tests {
         if running_on_valgrind() { return; }
 
         let mut prog = run_env(None);
-        let output = str::from_utf8_owned(prog.wait_with_output().output).unwrap();
+        let output = str::from_utf8(prog.wait_with_output().output.as_slice()).unwrap().to_owned();
 
         let r = os::env();
         for &(ref k, ref v) in r.iter() {
@@ -794,7 +794,7 @@ mod tests {
         if running_on_valgrind() { return; }
 
         let mut prog = run_env(None);
-        let output = str::from_utf8_owned(prog.wait_with_output().output).unwrap();
+        let output = str::from_utf8(prog.wait_with_output().output.as_slice()).unwrap().to_owned();
 
         let r = os::env();
         for &(ref k, ref v) in r.iter() {
@@ -811,7 +811,7 @@ mod tests {
 
         let mut prog = run_env(Some(new_env));
         let result = prog.wait_with_output();
-        let output = str::from_utf8_lossy(result.output).into_owned();
+        let output = str::from_utf8_lossy(result.output.as_slice()).into_owned();
 
         assert!(output.contains("RUN_TEST_NEW_ENV=123"),
                 "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs
index a294ba17289..b2661cb74e4 100644
--- a/src/libstd/io/util.rs
+++ b/src/libstd/io/util.rs
@@ -207,7 +207,7 @@ mod test {
         let mut r = MemReader::new(~[0, 1, 2]);
         {
             let mut r = LimitReader::new(r.by_ref(), 4);
-            assert_eq!(~[0, 1, 2], r.read_to_end().unwrap());
+            assert_eq!(vec!(0, 1, 2), r.read_to_end().unwrap());
         }
     }
 
@@ -216,9 +216,9 @@ mod test {
         let mut r = MemReader::new(~[0, 1, 2]);
         {
             let mut r = LimitReader::new(r.by_ref(), 2);
-            assert_eq!(~[0, 1], r.read_to_end().unwrap());
+            assert_eq!(vec!(0, 1), r.read_to_end().unwrap());
         }
-        assert_eq!(~[2], r.read_to_end().unwrap());
+        assert_eq!(vec!(2), r.read_to_end().unwrap());
     }
 
     #[test]
@@ -228,7 +228,7 @@ mod test {
         assert_eq!(3, r.limit());
         assert_eq!(0, r.read_byte().unwrap());
         assert_eq!(2, r.limit());
-        assert_eq!(~[1, 2], r.read_to_end().unwrap());
+        assert_eq!(vec!(1, 2), r.read_to_end().unwrap());
         assert_eq!(0, r.limit());
     }
 
@@ -288,14 +288,14 @@ mod test {
         let rs = ~[MemReader::new(~[0, 1]), MemReader::new(~[]),
                    MemReader::new(~[2, 3])];
         let mut r = ChainedReader::new(rs.move_iter());
-        assert_eq!(~[0, 1, 2, 3], r.read_to_end().unwrap());
+        assert_eq!(vec!(0, 1, 2, 3), r.read_to_end().unwrap());
     }
 
     #[test]
     fn test_tee_reader() {
         let mut r = TeeReader::new(MemReader::new(~[0, 1, 2]),
                                    MemWriter::new());
-        assert_eq!(~[0, 1, 2], r.read_to_end().unwrap());
+        assert_eq!(vec!(0, 1, 2), r.read_to_end().unwrap());
         let (_, w) = r.unwrap();
         assert_eq!(~[0, 1, 2], w.unwrap());
     }
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index 4d8d816d225..008532bcafe 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -113,13 +113,13 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
         }
         Ok(bytes) => bytes,
     };
-    match str::from_utf8_owned(bytes) {
+    match str::from_utf8(bytes.as_slice()) {
         Some(src) => {
             // Add this input file to the code map to make it available as
             // dependency information
             let filename = file.display().to_str();
             let interned = token::intern_and_get_ident(src);
-            cx.codemap().new_filemap(filename, src);
+            cx.codemap().new_filemap(filename, src.to_owned());
 
             base::MRExpr(cx.expr_str(sp, interned))
         }
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 3bf1474c461..bb812f7f6b4 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -350,7 +350,7 @@ pub fn gather_comments_and_literals(span_diagnostic:
                                     srdr: &mut io::Reader)
                                  -> (Vec<Comment>, Vec<Literal>) {
     let src = srdr.read_to_end().unwrap();
-    let src = str::from_utf8_owned(src).unwrap();
+    let src = str::from_utf8(src.as_slice()).unwrap().to_owned();
     let cm = CodeMap::new();
     let filemap = cm.new_filemap(path, src);
     let mut rdr = lexer::new_low_level_string_reader(span_diagnostic, filemap);
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index dbb85972774..35f9898ebbb 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -228,9 +228,10 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
             unreachable!()
         }
     };
-    match str::from_utf8_owned(bytes) {
+    match str::from_utf8(bytes.as_slice()) {
         Some(s) => {
-            return string_to_filemap(sess, s, path.as_str().unwrap().to_str())
+            return string_to_filemap(sess, s.to_owned(),
+                                     path.as_str().unwrap().to_str())
         }
         None => err(format!("{} is not UTF-8 encoded", path.display())),
     }
@@ -292,7 +293,7 @@ mod test {
         let mut writer = MemWriter::new();
         let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer);
         let _ = val.encode(&mut encoder);
-        str::from_utf8_owned(writer.unwrap()).unwrap()
+        str::from_utf8(writer.unwrap().as_slice()).unwrap().to_owned()
     }
 
     // produce a codemap::span
diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs
index 6d87d91ffc0..37ef3c133a5 100644
--- a/src/libterm/terminfo/parser/compiled.rs
+++ b/src/libterm/terminfo/parser/compiled.rs
@@ -208,8 +208,8 @@ pub fn parse(file: &mut io::Reader,
 
     // don't read NUL
     let bytes = try!(file.read_exact(names_bytes as uint - 1));
-    let names_str = match str::from_utf8_owned(bytes) {
-        Some(s) => s, None => return Err(~"input not utf-8"),
+    let names_str = match str::from_utf8(bytes.as_slice()) {
+        Some(s) => s.to_owned(), None => return Err(~"input not utf-8"),
     };
 
     let term_names: Vec<~str> = names_str.split('|').map(|s| s.to_owned()).collect();
diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs
index 6c1a52f4eee..8883abffb93 100644
--- a/src/libworkcache/lib.rs
+++ b/src/libworkcache/lib.rs
@@ -479,7 +479,7 @@ impl<'a, T:Send +
 fn test() {
     use std::os;
     use std::io::{fs, Process};
-    use std::str::from_utf8_owned;
+    use std::str::from_utf8;
 
     // Create a path to a new file 'filename' in the directory in which
     // this test is running.
@@ -505,7 +505,7 @@ fn test() {
         let pth = pth.clone();
 
         let contents = File::open(&pth).read_to_end().unwrap();
-        let file_content = from_utf8_owned(contents).unwrap();
+        let file_content = from_utf8(contents.as_slice()).unwrap().to_owned();
 
         // FIXME (#9639): This needs to handle non-utf8 paths
         prep.declare_input("file", pth.as_str().unwrap(), file_content);
diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs
index a96e9e9f81a..4ee4f94d435 100644
--- a/src/test/bench/shootout-reverse-complement.rs
+++ b/src/test/bench/shootout-reverse-complement.rs
@@ -44,7 +44,7 @@ fn main() {
     };
     let mut data = data.unwrap();
 
-    for seq in data.mut_split(|c| *c == '>' as u8) {
+    for seq in data.as_mut_slice().mut_split(|c| *c == '>' as u8) {
         // skip header and last \n
         let begin = match seq.iter().position(|c| *c == '\n' as u8) {
             None => continue,
@@ -80,5 +80,5 @@ fn main() {
         }
     }
 
-    stdout().write(data).unwrap();
+    stdout().write(data.as_slice()).unwrap();
 }
diff --git a/src/test/run-make/unicode-input/multiple_files.rs b/src/test/run-make/unicode-input/multiple_files.rs
index 45bb29f617f..66ddbac0513 100644
--- a/src/test/run-make/unicode-input/multiple_files.rs
+++ b/src/test/run-make/unicode-input/multiple_files.rs
@@ -58,7 +58,7 @@ fn main() {
         // rustc is passed to us with --out-dir and -L etc., so we
         // can't exec it directly
         let result = Process::output("sh", [~"-c", rustc + " " + main_file_str]).unwrap();
-        let err = str::from_utf8_lossy(result.error);
+        let err = str::from_utf8_lossy(result.error.as_slice());
 
         // positive test so that this test will be updated when the
         // compiler changes.
diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs
index 1ae6838be5b..faa22962290 100644
--- a/src/test/run-make/unicode-input/span_length.rs
+++ b/src/test/run-make/unicode-input/span_length.rs
@@ -55,7 +55,7 @@ fn main() {
         // can't exec it directly
         let result = Process::output("sh", [~"-c", rustc + " " + main_file_str]).unwrap();
 
-        let err = str::from_utf8_lossy(result.error);
+        let err = str::from_utf8_lossy(result.error.as_slice());
 
         // the span should end the line (e.g no extra ~'s)
         let expected_span = "^" + "~".repeat(n - 1) + "\n";
diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs
index edf0e195cb3..a34403daaab 100644
--- a/src/test/run-pass/backtrace.rs
+++ b/src/test/run-pass/backtrace.rs
@@ -53,7 +53,7 @@ fn runtest(me: &str) {
     }).unwrap();
     let out = p.wait_with_output();
     assert!(!out.status.success());
-    let s = str::from_utf8(out.error).unwrap();
+    let s = str::from_utf8(out.error.as_slice()).unwrap();
     assert!(s.contains("stack backtrace") && s.contains("foo::h"),
             "bad output: {}", s);
 
@@ -65,7 +65,7 @@ fn runtest(me: &str) {
     }).unwrap();
     let out = p.wait_with_output();
     assert!(!out.status.success());
-    let s = str::from_utf8(out.error).unwrap();
+    let s = str::from_utf8(out.error.as_slice()).unwrap();
     assert!(!s.contains("stack backtrace") && !s.contains("foo::h"),
             "bad output2: {}", s);
 
@@ -77,7 +77,7 @@ fn runtest(me: &str) {
     }).unwrap();
     let out = p.wait_with_output();
     assert!(!out.status.success());
-    let s = str::from_utf8(out.error).unwrap();
+    let s = str::from_utf8(out.error.as_slice()).unwrap();
     assert!(s.contains("stack backtrace") && s.contains("double::h"),
             "bad output3: {}", s);
 
@@ -90,7 +90,7 @@ fn runtest(me: &str) {
     }).unwrap();
     let out = p.wait_with_output();
     assert!(!out.status.success());
-    let s = str::from_utf8(out.error).unwrap();
+    let s = str::from_utf8(out.error.as_slice()).unwrap();
     let mut i = 0;
     for _ in range(0, 2) {
         i += s.slice_from(i + 10).find_str("stack backtrace").unwrap() + 10;
diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs
index 00861bd9b21..2e710cbf5c8 100644
--- a/src/test/run-pass/out-of-stack.rs
+++ b/src/test/run-pass/out-of-stack.rs
@@ -43,12 +43,12 @@ fn main() {
     } else {
         let silent = Process::output(args[0], [~"silent"]).unwrap();
         assert!(!silent.status.success());
-        let error = str::from_utf8_lossy(silent.error);
+        let error = str::from_utf8_lossy(silent.error.as_slice());
         assert!(error.as_slice().contains("has overflowed its stack"));
 
         let loud = Process::output(args[0], [~"loud"]).unwrap();
         assert!(!loud.status.success());
-        let error = str::from_utf8_lossy(silent.error);
+        let error = str::from_utf8_lossy(silent.error.as_slice());
         assert!(error.as_slice().contains("has overflowed its stack"));
     }
 }