]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #14310 : pcwalton/rust/detildestr-alllibs, r=brson
authorbors <bors@rust-lang.org>
Thu, 22 May 2014 22:16:31 +0000 (15:16 -0700)
committerbors <bors@rust-lang.org>
Thu, 22 May 2014 22:16:31 +0000 (15:16 -0700)
r? @brson

297 files changed:
src/compiletest/compiletest.rs
src/compiletest/errors.rs
src/compiletest/header.rs
src/compiletest/procsrv.rs
src/compiletest/runtest.rs
src/doc/complement-cheatsheet.md
src/liballoc/heap.rs
src/liballoc/util.rs
src/libcollections/bitv.rs
src/libcore/any.rs
src/libcore/bool.rs
src/libcore/cell.rs
src/libcore/char.rs
src/libcore/cmp.rs
src/libcore/fmt/mod.rs
src/libcore/fmt/num.rs
src/libcore/mem.rs
src/libcore/option.rs
src/libcore/ptr.rs
src/libcore/raw.rs
src/libcore/result.rs
src/libcore/should_not_exist.rs
src/libcore/str.rs
src/libcore/tuple.rs
src/libfmt_macros/lib.rs
src/libgetopts/lib.rs
src/libglob/lib.rs
src/libgreen/macros.rs
src/libhexfloat/lib.rs
src/liblog/lib.rs
src/libnative/io/addrinfo.rs
src/libnative/io/file_win32.rs
src/libnative/io/process.rs
src/libnum/bigint.rs
src/libnum/complex.rs
src/libnum/rational.rs
src/libregex/parse/mod.rs
src/libregex/test/bench.rs
src/libregex_macros/lib.rs
src/librustc/back/archive.rs
src/librustc/back/link.rs
src/librustc/back/lto.rs
src/librustc/back/rpath.rs
src/librustc/driver/config.rs
src/librustc/driver/driver.rs
src/librustc/driver/mod.rs
src/librustc/driver/session.rs
src/librustc/front/feature_gate.rs
src/librustc/front/std_inject.rs
src/librustc/front/test.rs
src/librustc/metadata/creader.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/loader.rs
src/librustc/metadata/tydecode.rs
src/librustc/middle/astencode.rs
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/gather_loans/mod.rs
src/librustc/middle/borrowck/gather_loans/move_error.rs
src/librustc/middle/borrowck/mod.rs
src/librustc/middle/cfg/construct.rs
src/librustc/middle/cfg/graphviz.rs
src/librustc/middle/check_const.rs
src/librustc/middle/check_loop.rs
src/librustc/middle/check_match.rs
src/librustc/middle/const_eval.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/dependency_format.rs
src/librustc/middle/effect.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/kind.rs
src/librustc/middle/lang_items.rs
src/librustc/middle/lint.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/privacy.rs
src/librustc/middle/reachable.rs
src/librustc/middle/resolve.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/subst.rs
src/librustc/middle/trans/_match.rs
src/librustc/middle/trans/adt.rs
src/librustc/middle/trans/asm.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/builder.rs
src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/cleanup.rs
src/librustc/middle/trans/closure.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/consts.rs
src/librustc/middle/trans/controlflow.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/foreign.rs
src/librustc/middle/trans/glue.rs
src/librustc/middle/trans/intrinsic.rs
src/librustc/middle/trans/monomorphize.rs
src/librustc/middle/trans/reflect.rs
src/librustc/middle/trans/type_of.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/check/_match.rs
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/vtable.rs
src/librustc/middle/typeck/check/writeback.rs
src/librustc/middle/typeck/coherence.rs
src/librustc/middle/typeck/collect.rs
src/librustc/middle/typeck/infer/coercion.rs
src/librustc/middle/typeck/infer/combine.rs
src/librustc/middle/typeck/infer/error_reporting.rs
src/librustc/middle/typeck/infer/glb.rs
src/librustc/middle/typeck/infer/lattice.rs
src/librustc/middle/typeck/infer/lub.rs
src/librustc/middle/typeck/infer/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/infer/unify.rs
src/librustc/middle/typeck/mod.rs
src/librustc/middle/typeck/variance.rs
src/librustc/middle/weak_lang_items.rs
src/librustc/util/ppaux.rs
src/librustdoc/clean.rs
src/librustdoc/html/format.rs
src/librustdoc/html/markdown.rs
src/librustdoc/html/render.rs
src/librustdoc/lib.rs
src/librustdoc/markdown.rs
src/librustdoc/passes.rs
src/librustdoc/test.rs
src/librustuv/lib.rs
src/libserialize/ebml.rs
src/libserialize/hex.rs
src/libserialize/json.rs
src/libstd/ascii.rs
src/libstd/c_str.rs
src/libstd/comm/mod.rs
src/libstd/fmt.rs
src/libstd/hash/mod.rs
src/libstd/hash/sip.rs
src/libstd/io/buffered.rs
src/libstd/io/fs.rs
src/libstd/io/mem.rs
src/libstd/io/mod.rs
src/libstd/io/net/ip.rs
src/libstd/io/net/tcp.rs
src/libstd/io/process.rs
src/libstd/io/stdio.rs
src/libstd/io/tempfile.rs
src/libstd/io/test.rs
src/libstd/lib.rs
src/libstd/local_data.rs
src/libstd/num/f32.rs
src/libstd/num/f64.rs
src/libstd/num/i16.rs
src/libstd/num/i32.rs
src/libstd/num/i64.rs
src/libstd/num/i8.rs
src/libstd/num/int.rs
src/libstd/num/int_macros.rs
src/libstd/num/mod.rs
src/libstd/num/strconv.rs
src/libstd/num/u16.rs
src/libstd/num/u32.rs
src/libstd/num/u64.rs
src/libstd/num/u8.rs
src/libstd/num/uint.rs
src/libstd/num/uint_macros.rs
src/libstd/os.rs
src/libstd/path/mod.rs
src/libstd/path/posix.rs
src/libstd/path/windows.rs
src/libstd/repr.rs
src/libstd/rt/args.rs
src/libstd/rt/env.rs
src/libstd/rt/macros.rs
src/libstd/rt/task.rs
src/libstd/rt/unwind.rs
src/libstd/rt/util.rs
src/libstd/slice.rs
src/libstd/str.rs
src/libstd/strbuf.rs
src/libstd/task.rs
src/libstd/to_str.rs
src/libstd/unstable/dynamic_lib.rs
src/libstd/vec.rs
src/libsyntax/attr.rs
src/libsyntax/crateid.rs
src/libsyntax/diagnostic.rs
src/libsyntax/ext/asm.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/concat.rs
src/libsyntax/ext/concat_idents.rs
src/libsyntax/ext/deriving/bounds.rs
src/libsyntax/ext/deriving/clone.rs
src/libsyntax/ext/deriving/decodable.rs
src/libsyntax/ext/deriving/encodable.rs
src/libsyntax/ext/deriving/generic/mod.rs
src/libsyntax/ext/deriving/mod.rs
src/libsyntax/ext/env.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/format.rs
src/libsyntax/ext/quote.rs
src/libsyntax/ext/source_util.rs
src/libsyntax/ext/tt/macro_parser.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/ext/tt/transcribe.rs
src/libsyntax/parse/attr.rs
src/libsyntax/parse/lexer.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pp.rs
src/libsyntax/print/pprust.rs
src/libterm/terminfo/mod.rs
src/libterm/terminfo/parser/compiled.rs
src/libterm/terminfo/searcher.rs
src/libtest/lib.rs
src/libtime/lib.rs
src/liburl/lib.rs
src/libuuid/lib.rs
src/rt/rust_builtin.c
src/test/bench/core-map.rs
src/test/bench/core-set.rs
src/test/bench/core-uint-to-str.rs
src/test/bench/msgsend-ring-mutex-arcs.rs
src/test/bench/msgsend-ring-rw-arcs.rs
src/test/bench/rt-messaging-ping-pong.rs
src/test/bench/rt-parfib.rs
src/test/bench/rt-spawn-rate.rs
src/test/bench/shootout-ackermann.rs
src/test/bench/shootout-binarytrees.rs
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-fannkuch-redux.rs
src/test/bench/shootout-fasta-redux.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-fibo.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide.rs
src/test/bench/shootout-mandelbrot.rs
src/test/bench/shootout-nbody.rs
src/test/bench/shootout-pidigits.rs
src/test/bench/shootout-regex-dna.rs
src/test/bench/shootout-spectralnorm.rs
src/test/bench/shootout-threadring.rs
src/test/bench/std-smallintmap.rs
src/test/bench/sudoku.rs
src/test/bench/task-perf-jargon-metal-smoke.rs
src/test/bench/task-perf-spawnalot.rs
src/test/compile-fail/closure-reform-bad.rs
src/test/compile-fail/lint-heap-memory.rs
src/test/compile-fail/regions-glb-free-free.rs
src/test/compile-fail/trait-coercion-generic-regions.rs
src/test/compile-fail/unsafe-modifying-str.rs [deleted file]
src/test/pretty/match-naked-expr-long.rs [deleted file]
src/test/run-fail/assert-macro-owned.rs
src/test/run-fail/explicit-fail-msg.rs
src/test/run-fail/issue-3029.rs
src/test/run-fail/unwind-misc-1.rs
src/test/run-make/unicode-input/multiple_files.rs
src/test/run-make/unicode-input/span_length.rs
src/test/run-pass/auto-ref-slice-plus-ref.rs
src/test/run-pass/backtrace.rs
src/test/run-pass/capturing-logging.rs
src/test/run-pass/cleanup-shortcircuit.rs
src/test/run-pass/concat.rs
src/test/run-pass/deriving-show-2.rs
src/test/run-pass/deriving-show.rs
src/test/run-pass/enum-discrim-width-stuff.rs
src/test/run-pass/exec-env.rs
src/test/run-pass/exponential-notation.rs
src/test/run-pass/fixed_length_vec_glue.rs
src/test/run-pass/format-ref-cell.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/issue-3559.rs
src/test/run-pass/issue-3563-3.rs
src/test/run-pass/issue-3574.rs
src/test/run-pass/let-assignability.rs
src/test/run-pass/let-destruct-ref.rs
src/test/run-pass/linear-for-loop.rs
src/test/run-pass/log-err-phi.rs
src/test/run-pass/option-ext.rs
src/test/run-pass/process-spawn-with-unicode-params.rs
src/test/run-pass/rec-align-u32.rs
src/test/run-pass/rec-align-u64.rs
src/test/run-pass/regions-borrow-estr-uniq.rs [deleted file]
src/test/run-pass/send_str_hashmap.rs
src/test/run-pass/signal-exit-status.rs
src/test/run-pass/str-idx.rs
src/test/run-pass/super-fast-paren-parsing.rs
src/test/run-pass/syntax-extension-source-utils.rs
src/test/run-pass/tag-align-shape.rs
src/test/run-pass/tag-disr-val-shape.rs
src/test/run-pass/task-comm-16.rs
src/test/run-pass/tcp-connect-timeouts.rs
src/test/run-pass/tcp-stress.rs
src/test/run-pass/test-ignore-cfg.rs
src/test/run-pass/vec-to_str.rs

index db9cf358a9b99db7e516c5dd29159ecf69ac832d..fa5d85111daf1ce3b028d463e33155f29b27ae8d 100644 (file)
@@ -96,7 +96,7 @@ pub fn parse_config(args: Vec<StrBuf> ) -> Config {
     let args_ = args.tail();
     if args.get(1).as_slice() == "-h" || args.get(1).as_slice() == "--help" {
         let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
-        println!("{}", getopts::usage(message, groups.as_slice()));
+        println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
         println!("");
         fail!()
     }
@@ -109,7 +109,7 @@ pub fn parse_config(args: Vec<StrBuf> ) -> Config {
 
     if matches.opt_present("h") || matches.opt_present("help") {
         let message = format!("Usage: {} [OPTIONS]  [TESTNAME...]", argv0);
-        println!("{}", getopts::usage(message, groups.as_slice()));
+        println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
         println!("");
         fail!()
     }
@@ -323,11 +323,15 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
     let mut valid = false;
 
     for ext in valid_extensions.iter() {
-        if name.ends_with(*ext) { valid = true; }
+        if name.ends_with(ext.as_slice()) {
+            valid = true;
+        }
     }
 
     for pre in invalid_prefixes.iter() {
-        if name.starts_with(*pre) { valid = false; }
+        if name.starts_with(pre.as_slice()) {
+            valid = false;
+        }
     }
 
     return valid;
index 408206b16e998c3b51bb1146b9b83f6babde078e..534e04ccb2daa2f22f38be990d93aa08b212610b 100644 (file)
@@ -24,7 +24,7 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
     let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
 
     rdr.lines().enumerate().filter_map(|(line_no, ln)| {
-        parse_expected(line_no + 1, ln.unwrap(), re)
+        parse_expected(line_no + 1, ln.unwrap().as_slice(), re)
     }).collect()
 }
 
index 5729a11d7ad7ef0862131a798607612d810f396a..55fca1784ded56cae84fb8cc5fed4dbacd814f44 100644 (file)
@@ -157,9 +157,14 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
         // module or function. This doesn't seem to be an optimization
         // with a warm page cache. Maybe with a cold one.
         let ln = ln.unwrap();
-        if ln.starts_with("fn") || ln.starts_with("mod") {
+        if ln.as_slice().starts_with("fn") ||
+                ln.as_slice().starts_with("mod") {
             return true;
-        } else { if !(it(ln.trim())) { return false; } }
+        } else {
+            if !(it(ln.as_slice().trim())) {
+                return false;
+            }
+        }
     }
     return true;
 }
index 6b273c2d4634593845753be052c9e03a06b09e07..2622cf0e5f1c5eb2503b733bad394db38ca3a862 100644 (file)
@@ -15,7 +15,8 @@
 
 fn target_env(lib_path: &str, prog: &str) -> Vec<(StrBuf, StrBuf)> {
     let prog = if cfg!(windows) {prog.slice_to(prog.len() - 4)} else {prog};
-    let aux_path = prog + ".libaux";
+    let mut aux_path = prog.to_strbuf();
+    aux_path.push_str(".libaux");
 
     // Need to be sure to put both the lib_path and the aux path in the dylib
     // search path for the child.
index 8c2b34ff35d3706009fee35ee23635ecdd3db77e..c591c477563ee6e5f59f64c60e26120b5e540a27 100644 (file)
@@ -351,7 +351,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                               cmds,
                               "quit".to_strbuf()].connect("\n");
             debug!("script_str = {}", script_str);
-            dump_output_file(config, testfile, script_str, "debugger.script");
+            dump_output_file(config,
+                             testfile,
+                             script_str.as_slice(),
+                             "debugger.script");
 
 
             procsrv::run("",
@@ -459,7 +462,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                 "quit\n".to_strbuf()
             ].connect("\n");
             debug!("script_str = {}", script_str);
-            dump_output_file(config, testfile, script_str, "debugger.script");
+            dump_output_file(config,
+                             testfile,
+                             script_str.as_slice(),
+                             "debugger.script");
 
             // run debugger script with gdb
             #[cfg(windows)]
@@ -538,7 +544,8 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
 
     // Set breakpoints on every line that contains the string "#break"
     for line in breakpoint_lines.iter() {
-        script_str.push_str(format!("breakpoint set --line {}\n", line));
+        script_str.push_str(format!("breakpoint set --line {}\n",
+                                    line).as_slice());
     }
 
     // Append the other commands
@@ -552,7 +559,10 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
 
     // Write the script into a file
     debug!("script_str = {}", script_str);
-    dump_output_file(config, testfile, script_str.into_owned(), "debugger.script");
+    dump_output_file(config,
+                     testfile,
+                     script_str.as_slice(),
+                     "debugger.script");
     let debugger_script = make_out_name(config, testfile, "debugger.script");
 
     // Let LLDB execute the script via lldb_batchmode.py
@@ -609,8 +619,8 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
                            -> DebuggerCommands {
     use std::io::{BufferedReader, File};
 
-    let command_directive = debugger_prefix + "-command";
-    let check_directive = debugger_prefix + "-check";
+    let command_directive = format!("{}-command", debugger_prefix);
+    let check_directive = format!("{}-check", debugger_prefix);
 
     let mut breakpoint_lines = vec!();
     let mut commands = vec!();
@@ -620,18 +630,18 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
     for line in reader.lines() {
         match line {
             Ok(line) => {
-                if line.contains("#break") {
+                if line.as_slice().contains("#break") {
                     breakpoint_lines.push(counter);
                 }
 
                 header::parse_name_value_directive(
-                        line,
+                        line.as_slice(),
                         command_directive.to_strbuf()).map(|cmd| {
                     commands.push(cmd)
                 });
 
                 header::parse_name_value_directive(
-                        line,
+                        line.as_slice(),
                         check_directive.to_strbuf()).map(|cmd| {
                     check_lines.push(cmd)
                 });
index 4670a2922cf8c6100bb51f6a4cf6548bc658484c..99f7c229d4e36f1e1a17967a9992162af2a2811b 100644 (file)
@@ -60,8 +60,8 @@ To return an Owned String (StrBuf) use the str helper function [`from_utf8_owned
 ~~~
 use std::str;
 
-let x: Result<StrBuf,~[u8]> =
-    str::from_utf8_owned(~[104u8,105u8]).map(|x| x.to_strbuf());
+let x: Option<StrBuf> =
+    str::from_utf8([ 104u8, 105u8 ]).map(|x| x.to_strbuf());
 let y: StrBuf = x.unwrap();
 ~~~
 
index 631b72cb8978ef791c42bba74a61c44f9cb2b4f9..8376fc578dba20634d89a9232f9ce147bd069ca1 100644 (file)
@@ -116,18 +116,18 @@ pub fn stats_print() {
     }
 }
 
+// The compiler never calls `exchange_free` on ~ZeroSizeType, so zero-size
+// allocations can point to this `static`. It would be incorrect to use a null
+// pointer, due to enums assuming types like unique pointers are never null.
+pub static mut EMPTY: uint = 12345;
+
 /// The allocator for unique pointers.
 #[cfg(not(test))]
 #[lang="exchange_malloc"]
 #[inline]
 unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
-    // The compiler never calls `exchange_free` on ~ZeroSizeType, so zero-size
-    // allocations can point to this `static`. It would be incorrect to use a null
-    // pointer, due to enums assuming types like unique pointers are never null.
-    static EMPTY: () = ();
-
     if size == 0 {
-        &EMPTY as *() as *mut u8
+        &EMPTY as *uint as *mut u8
     } else {
         allocate(size, align)
     }
index 7e35af79eab1cf10f8d10699edff49ca73b378ba..64d620358903e2864acd4ed5050722c9dacfac7e 100644 (file)
@@ -28,3 +28,20 @@ fn align_to(size: uint, align: uint) -> uint {
     assert!(align != 0);
     (size + align - 1) & !(align - 1)
 }
+
+// FIXME(#14344): When linking liballoc with libstd, this library will be linked
+//                as an rlib (it only exists as an rlib). It turns out that an
+//                optimized standard library doesn't actually use *any* symbols
+//                from this library. Everything is inlined and optimized away.
+//                This means that linkers will actually omit the object for this
+//                file, even though it may be needed in the future.
+//
+//                To get around this for now, we define a dummy symbol which
+//                will never get inlined so the stdlib can call it. The stdlib's
+//                reference to this symbol will cause this library's object file
+//                to get linked in to libstd successfully (the linker won't
+//                optimize it out).
+#[deprecated]
+#[doc(hidden)]
+pub fn make_stdlib_link_work() {}
+
index e2934efa43b65b5e42df828a7363e60c1e058c0c..82cca507c4da75f2ab409505fda673f3e7b1cf5f 100644 (file)
@@ -538,7 +538,7 @@ pub fn to_bools(&self) -> Vec<bool> {
      * The resulting string has the same length as `self`, and each
      * character is either '0' or '1'.
      */
-     pub fn to_str(&self) -> ~str {
+     pub fn to_str(&self) -> StrBuf {
         let mut rs = StrBuf::new();
         for i in self.iter() {
             if i {
@@ -547,7 +547,7 @@ pub fn to_str(&self) -> ~str {
                 rs.push_char('0');
             }
         };
-        rs.into_owned()
+        rs
      }
 
 
@@ -1330,7 +1330,7 @@ fn test_equal_sneaky_big() {
     #[test]
     fn test_from_bytes() {
         let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]);
-        let str = "10110110".to_owned() + "00000000" + "11111111";
+        let str = format!("{}{}{}", "10110110", "00000000", "11111111");
         assert_eq!(bitv.to_str(), str);
     }
 
index 61c1193e515973f939e9daf8ede42269079de50b..94ac344db3485e64993b489de63e25fcfdb97e62 100644 (file)
@@ -119,7 +119,7 @@ mod tests {
     use prelude::*;
     use super::*;
     use realstd::owned::{Box, AnyOwnExt};
-    use realstd::str::StrAllocating;
+    use realstd::str::{Str, StrAllocating};
 
     #[deriving(Eq, Show)]
     struct Test;
@@ -249,13 +249,17 @@ fn test_show() {
         use realstd::to_str::ToStr;
         let a = box 8u as Box<::realstd::any::Any>;
         let b = box Test as Box<::realstd::any::Any>;
-        assert_eq!(a.to_str(), "Box<Any>".to_owned());
-        assert_eq!(b.to_str(), "Box<Any>".to_owned());
+        let a_str = a.to_str();
+        let b_str = b.to_str();
+        assert_eq!(a_str.as_slice(), "Box<Any>");
+        assert_eq!(b_str.as_slice(), "Box<Any>");
 
         let a = &8u as &Any;
         let b = &Test as &Any;
-        assert_eq!(format!("{}", a), "&Any".to_owned());
-        assert_eq!(format!("{}", b), "&Any".to_owned());
+        let s = format!("{}", a);
+        assert_eq!(s.as_slice(), "&Any");
+        let s = format!("{}", b);
+        assert_eq!(s.as_slice(), "&Any");
     }
 }
 
index 2a44d1417198b2f28bd933fd81da1b88d4db80a8..ddfdbca196c66b3ffecf8d8cbc92191046dc9820 100644 (file)
@@ -242,8 +242,10 @@ fn test_not() {
 
     #[test]
     fn test_to_str() {
-        assert_eq!(false.to_str(), "false".to_owned());
-        assert_eq!(true.to_str(), "true".to_owned());
+        let s = false.to_str();
+        assert_eq!(s.as_slice(), "false");
+        let s = true.to_str();
+        assert_eq!(s.as_slice(), "true");
     }
 
     #[test]
index 093b3f57047ca0f1118a1798511ad1daec8a0d88..3ad2ebb9f0a284c7b9243151cbdcc0e84c52a694 100644 (file)
@@ -404,12 +404,13 @@ fn smoketest_cell() {
     #[test]
     fn cell_has_sensible_show() {
         use str::StrSlice;
+        use realstd::str::Str;
 
         let x = Cell::new("foo bar");
-        assert!(format!("{}", x).contains(x.get()));
+        assert!(format!("{}", x).as_slice().contains(x.get()));
 
         x.set("baz qux");
-        assert!(format!("{}", x).contains(x.get()));
+        assert!(format!("{}", x).as_slice().contains(x.get()));
     }
 
     #[test]
index 6e9d4c9bafbf616be4ae623ac8c9fad8ea641f87..f3942dfd753a45879384b7a1de0d1ded16962253 100644 (file)
@@ -637,7 +637,7 @@ mod test {
     use slice::ImmutableVector;
     use option::{Some, None};
     use realstd::strbuf::StrBuf;
-    use realstd::str::StrAllocating;
+    use realstd::str::{Str, StrAllocating};
 
     #[test]
     fn test_is_lowercase() {
@@ -742,46 +742,65 @@ fn test_is_digit() {
 
     #[test]
     fn test_escape_default() {
-        fn string(c: char) -> ~str {
+        fn string(c: char) -> StrBuf {
             let mut result = StrBuf::new();
             escape_default(c, |c| { result.push_char(c); });
-            return result.into_owned();
+            return result;
         }
-        assert_eq!(string('\n'), "\\n".to_owned());
-        assert_eq!(string('\r'), "\\r".to_owned());
-        assert_eq!(string('\''), "\\'".to_owned());
-        assert_eq!(string('"'), "\\\"".to_owned());
-        assert_eq!(string(' '), " ".to_owned());
-        assert_eq!(string('a'), "a".to_owned());
-        assert_eq!(string('~'), "~".to_owned());
-        assert_eq!(string('\x00'), "\\x00".to_owned());
-        assert_eq!(string('\x1f'), "\\x1f".to_owned());
-        assert_eq!(string('\x7f'), "\\x7f".to_owned());
-        assert_eq!(string('\xff'), "\\xff".to_owned());
-        assert_eq!(string('\u011b'), "\\u011b".to_owned());
-        assert_eq!(string('\U0001d4b6'), "\\U0001d4b6".to_owned());
+        let s = string('\n');
+        assert_eq!(s.as_slice(), "\\n");
+        let s = string('\r');
+        assert_eq!(s.as_slice(), "\\r");
+        let s = string('\'');
+        assert_eq!(s.as_slice(), "\\'");
+        let s = string('"');
+        assert_eq!(s.as_slice(), "\\\"");
+        let s = string(' ');
+        assert_eq!(s.as_slice(), " ");
+        let s = string('a');
+        assert_eq!(s.as_slice(), "a");
+        let s = string('~');
+        assert_eq!(s.as_slice(), "~");
+        let s = string('\x00');
+        assert_eq!(s.as_slice(), "\\x00");
+        let s = string('\x1f');
+        assert_eq!(s.as_slice(), "\\x1f");
+        let s = string('\x7f');
+        assert_eq!(s.as_slice(), "\\x7f");
+        let s = string('\xff');
+        assert_eq!(s.as_slice(), "\\xff");
+        let s = string('\u011b');
+        assert_eq!(s.as_slice(), "\\u011b");
+        let s = string('\U0001d4b6');
+        assert_eq!(s.as_slice(), "\\U0001d4b6");
     }
 
     #[test]
     fn test_escape_unicode() {
-        fn string(c: char) -> ~str {
+        fn string(c: char) -> StrBuf {
             let mut result = StrBuf::new();
             escape_unicode(c, |c| { result.push_char(c); });
-            return result.into_owned();
+            return result;
         }
-        assert_eq!(string('\x00'), "\\x00".to_owned());
-        assert_eq!(string('\n'), "\\x0a".to_owned());
-        assert_eq!(string(' '), "\\x20".to_owned());
-        assert_eq!(string('a'), "\\x61".to_owned());
-        assert_eq!(string('\u011b'), "\\u011b".to_owned());
-        assert_eq!(string('\U0001d4b6'), "\\U0001d4b6".to_owned());
+        let s = string('\x00');
+        assert_eq!(s.as_slice(), "\\x00");
+        let s = string('\n');
+        assert_eq!(s.as_slice(), "\\x0a");
+        let s = string(' ');
+        assert_eq!(s.as_slice(), "\\x20");
+        let s = string('a');
+        assert_eq!(s.as_slice(), "\\x61");
+        let s = string('\u011b');
+        assert_eq!(s.as_slice(), "\\u011b");
+        let s = string('\U0001d4b6');
+        assert_eq!(s.as_slice(), "\\U0001d4b6");
     }
 
     #[test]
     fn test_to_str() {
         use realstd::to_str::ToStr;
         let s = 't'.to_str();
-        assert_eq!(s, "t".to_owned());
+        assert_eq!(s.as_slice(), "t");
     }
 
     #[test]
index a50108607ce71cf46d1af2a618714e83317ebac9..bf1f3ee310ccd687e94bbfd978cab06c7763baaa 100644 (file)
@@ -171,7 +171,7 @@ fn ge(&self, other: &Self) -> bool { !self.lt(other) }
 /// The equivalence relation. Two values may be equivalent even if they are
 /// of different types. The most common use case for this relation is
 /// container types; e.g. it is often desirable to be able to use `&str`
-/// values to look up entries in a container with `~str` keys.
+/// values to look up entries in a container with `StrBuf` keys.
 pub trait Equiv<T> {
     /// Implement this function to decide equivalent values.
     fn equiv(&self, other: &T) -> bool;
index af492dc295aca2996b9e5297e4651334e862fc9d..cc965bc6eed39a027c8cc0f5fe7f08ec21c27529 100644 (file)
@@ -594,7 +594,7 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,
 }
 
 #[cfg(test)]
-pub fn format(args: &Arguments) -> ~str {
+pub fn format(args: &Arguments) -> ::realstd::strbuf::StrBuf {
     use str;
     use realstd::str::StrAllocating;
     use realstd::io::MemWriter;
@@ -613,7 +613,10 @@ fn write(&mut self, bytes: &[u8]) -> Result {
 
     let mut i = MemWriter::new();
     let _ = write(&mut i, args);
-    str::from_utf8(i.get_ref()).unwrap().to_owned()
+
+    let mut result = ::realstd::strbuf::StrBuf::new();
+    result.push_str(str::from_utf8(i.get_ref()).unwrap());
+    result
 }
 
 /// When the compiler determines that the type of an argument *must* be a string
@@ -761,7 +764,6 @@ fn fmt(&self, f: &mut Formatter) -> Result {
         }
     }
 })
-delegate!(~str to string)
 delegate!(&'a str to string)
 delegate!(bool to bool)
 delegate!(char to char)
index d9a327137812586759525a274962cb33347fde04..75f67c3df65d706d66393c029064ea2cddb0b494 100644 (file)
@@ -194,7 +194,7 @@ mod tests {
     use fmt::radix;
     use super::{Binary, Octal, Decimal, LowerHex, UpperHex};
     use super::{GenericRadix, Radix};
-    use realstd::str::StrAllocating;
+    use realstd::str::{Str, StrAllocating};
 
     #[test]
     fn test_radix_base() {
@@ -246,143 +246,143 @@ fn test_format_int() {
         // Formatting integers should select the right implementation based off
         // the type of the argument. Also, hex/octal/binary should be defined
         // for integers, but they shouldn't emit the negative sign.
-        assert_eq!(format!("{}", 1i), "1".to_owned());
-        assert_eq!(format!("{}", 1i8), "1".to_owned());
-        assert_eq!(format!("{}", 1i16), "1".to_owned());
-        assert_eq!(format!("{}", 1i32), "1".to_owned());
-        assert_eq!(format!("{}", 1i64), "1".to_owned());
-        assert_eq!(format!("{:d}", -1i), "-1".to_owned());
-        assert_eq!(format!("{:d}", -1i8), "-1".to_owned());
-        assert_eq!(format!("{:d}", -1i16), "-1".to_owned());
-        assert_eq!(format!("{:d}", -1i32), "-1".to_owned());
-        assert_eq!(format!("{:d}", -1i64), "-1".to_owned());
-        assert_eq!(format!("{:t}", 1i), "1".to_owned());
-        assert_eq!(format!("{:t}", 1i8), "1".to_owned());
-        assert_eq!(format!("{:t}", 1i16), "1".to_owned());
-        assert_eq!(format!("{:t}", 1i32), "1".to_owned());
-        assert_eq!(format!("{:t}", 1i64), "1".to_owned());
-        assert_eq!(format!("{:x}", 1i), "1".to_owned());
-        assert_eq!(format!("{:x}", 1i8), "1".to_owned());
-        assert_eq!(format!("{:x}", 1i16), "1".to_owned());
-        assert_eq!(format!("{:x}", 1i32), "1".to_owned());
-        assert_eq!(format!("{:x}", 1i64), "1".to_owned());
-        assert_eq!(format!("{:X}", 1i), "1".to_owned());
-        assert_eq!(format!("{:X}", 1i8), "1".to_owned());
-        assert_eq!(format!("{:X}", 1i16), "1".to_owned());
-        assert_eq!(format!("{:X}", 1i32), "1".to_owned());
-        assert_eq!(format!("{:X}", 1i64), "1".to_owned());
-        assert_eq!(format!("{:o}", 1i), "1".to_owned());
-        assert_eq!(format!("{:o}", 1i8), "1".to_owned());
-        assert_eq!(format!("{:o}", 1i16), "1".to_owned());
-        assert_eq!(format!("{:o}", 1i32), "1".to_owned());
-        assert_eq!(format!("{:o}", 1i64), "1".to_owned());
-
-        assert_eq!(format!("{}", 1u), "1".to_owned());
-        assert_eq!(format!("{}", 1u8), "1".to_owned());
-        assert_eq!(format!("{}", 1u16), "1".to_owned());
-        assert_eq!(format!("{}", 1u32), "1".to_owned());
-        assert_eq!(format!("{}", 1u64), "1".to_owned());
-        assert_eq!(format!("{:u}", 1u), "1".to_owned());
-        assert_eq!(format!("{:u}", 1u8), "1".to_owned());
-        assert_eq!(format!("{:u}", 1u16), "1".to_owned());
-        assert_eq!(format!("{:u}", 1u32), "1".to_owned());
-        assert_eq!(format!("{:u}", 1u64), "1".to_owned());
-        assert_eq!(format!("{:t}", 1u), "1".to_owned());
-        assert_eq!(format!("{:t}", 1u8), "1".to_owned());
-        assert_eq!(format!("{:t}", 1u16), "1".to_owned());
-        assert_eq!(format!("{:t}", 1u32), "1".to_owned());
-        assert_eq!(format!("{:t}", 1u64), "1".to_owned());
-        assert_eq!(format!("{:x}", 1u), "1".to_owned());
-        assert_eq!(format!("{:x}", 1u8), "1".to_owned());
-        assert_eq!(format!("{:x}", 1u16), "1".to_owned());
-        assert_eq!(format!("{:x}", 1u32), "1".to_owned());
-        assert_eq!(format!("{:x}", 1u64), "1".to_owned());
-        assert_eq!(format!("{:X}", 1u), "1".to_owned());
-        assert_eq!(format!("{:X}", 1u8), "1".to_owned());
-        assert_eq!(format!("{:X}", 1u16), "1".to_owned());
-        assert_eq!(format!("{:X}", 1u32), "1".to_owned());
-        assert_eq!(format!("{:X}", 1u64), "1".to_owned());
-        assert_eq!(format!("{:o}", 1u), "1".to_owned());
-        assert_eq!(format!("{:o}", 1u8), "1".to_owned());
-        assert_eq!(format!("{:o}", 1u16), "1".to_owned());
-        assert_eq!(format!("{:o}", 1u32), "1".to_owned());
-        assert_eq!(format!("{:o}", 1u64), "1".to_owned());
+        assert!(format!("{}", 1i).as_slice() == "1");
+        assert!(format!("{}", 1i8).as_slice() == "1");
+        assert!(format!("{}", 1i16).as_slice() == "1");
+        assert!(format!("{}", 1i32).as_slice() == "1");
+        assert!(format!("{}", 1i64).as_slice() == "1");
+        assert!(format!("{:d}", -1i).as_slice() == "-1");
+        assert!(format!("{:d}", -1i8).as_slice() == "-1");
+        assert!(format!("{:d}", -1i16).as_slice() == "-1");
+        assert!(format!("{:d}", -1i32).as_slice() == "-1");
+        assert!(format!("{:d}", -1i64).as_slice() == "-1");
+        assert!(format!("{:t}", 1i).as_slice() == "1");
+        assert!(format!("{:t}", 1i8).as_slice() == "1");
+        assert!(format!("{:t}", 1i16).as_slice() == "1");
+        assert!(format!("{:t}", 1i32).as_slice() == "1");
+        assert!(format!("{:t}", 1i64).as_slice() == "1");
+        assert!(format!("{:x}", 1i).as_slice() == "1");
+        assert!(format!("{:x}", 1i8).as_slice() == "1");
+        assert!(format!("{:x}", 1i16).as_slice() == "1");
+        assert!(format!("{:x}", 1i32).as_slice() == "1");
+        assert!(format!("{:x}", 1i64).as_slice() == "1");
+        assert!(format!("{:X}", 1i).as_slice() == "1");
+        assert!(format!("{:X}", 1i8).as_slice() == "1");
+        assert!(format!("{:X}", 1i16).as_slice() == "1");
+        assert!(format!("{:X}", 1i32).as_slice() == "1");
+        assert!(format!("{:X}", 1i64).as_slice() == "1");
+        assert!(format!("{:o}", 1i).as_slice() == "1");
+        assert!(format!("{:o}", 1i8).as_slice() == "1");
+        assert!(format!("{:o}", 1i16).as_slice() == "1");
+        assert!(format!("{:o}", 1i32).as_slice() == "1");
+        assert!(format!("{:o}", 1i64).as_slice() == "1");
+
+        assert!(format!("{}", 1u).as_slice() == "1");
+        assert!(format!("{}", 1u8).as_slice() == "1");
+        assert!(format!("{}", 1u16).as_slice() == "1");
+        assert!(format!("{}", 1u32).as_slice() == "1");
+        assert!(format!("{}", 1u64).as_slice() == "1");
+        assert!(format!("{:u}", 1u).as_slice() == "1");
+        assert!(format!("{:u}", 1u8).as_slice() == "1");
+        assert!(format!("{:u}", 1u16).as_slice() == "1");
+        assert!(format!("{:u}", 1u32).as_slice() == "1");
+        assert!(format!("{:u}", 1u64).as_slice() == "1");
+        assert!(format!("{:t}", 1u).as_slice() == "1");
+        assert!(format!("{:t}", 1u8).as_slice() == "1");
+        assert!(format!("{:t}", 1u16).as_slice() == "1");
+        assert!(format!("{:t}", 1u32).as_slice() == "1");
+        assert!(format!("{:t}", 1u64).as_slice() == "1");
+        assert!(format!("{:x}", 1u).as_slice() == "1");
+        assert!(format!("{:x}", 1u8).as_slice() == "1");
+        assert!(format!("{:x}", 1u16).as_slice() == "1");
+        assert!(format!("{:x}", 1u32).as_slice() == "1");
+        assert!(format!("{:x}", 1u64).as_slice() == "1");
+        assert!(format!("{:X}", 1u).as_slice() == "1");
+        assert!(format!("{:X}", 1u8).as_slice() == "1");
+        assert!(format!("{:X}", 1u16).as_slice() == "1");
+        assert!(format!("{:X}", 1u32).as_slice() == "1");
+        assert!(format!("{:X}", 1u64).as_slice() == "1");
+        assert!(format!("{:o}", 1u).as_slice() == "1");
+        assert!(format!("{:o}", 1u8).as_slice() == "1");
+        assert!(format!("{:o}", 1u16).as_slice() == "1");
+        assert!(format!("{:o}", 1u32).as_slice() == "1");
+        assert!(format!("{:o}", 1u64).as_slice() == "1");
 
         // Test a larger number
-        assert_eq!(format!("{:t}", 55), "110111".to_owned());
-        assert_eq!(format!("{:o}", 55), "67".to_owned());
-        assert_eq!(format!("{:d}", 55), "55".to_owned());
-        assert_eq!(format!("{:x}", 55), "37".to_owned());
-        assert_eq!(format!("{:X}", 55), "37".to_owned());
+        assert!(format!("{:t}", 55).as_slice() == "110111");
+        assert!(format!("{:o}", 55).as_slice() == "67");
+        assert!(format!("{:d}", 55).as_slice() == "55");
+        assert!(format!("{:x}", 55).as_slice() == "37");
+        assert!(format!("{:X}", 55).as_slice() == "37");
     }
 
     #[test]
     fn test_format_int_zero() {
-        assert_eq!(format!("{}", 0i), "0".to_owned());
-        assert_eq!(format!("{:d}", 0i), "0".to_owned());
-        assert_eq!(format!("{:t}", 0i), "0".to_owned());
-        assert_eq!(format!("{:o}", 0i), "0".to_owned());
-        assert_eq!(format!("{:x}", 0i), "0".to_owned());
-        assert_eq!(format!("{:X}", 0i), "0".to_owned());
-
-        assert_eq!(format!("{}", 0u), "0".to_owned());
-        assert_eq!(format!("{:u}", 0u), "0".to_owned());
-        assert_eq!(format!("{:t}", 0u), "0".to_owned());
-        assert_eq!(format!("{:o}", 0u), "0".to_owned());
-        assert_eq!(format!("{:x}", 0u), "0".to_owned());
-        assert_eq!(format!("{:X}", 0u), "0".to_owned());
+        assert!(format!("{}", 0i).as_slice() == "0");
+        assert!(format!("{:d}", 0i).as_slice() == "0");
+        assert!(format!("{:t}", 0i).as_slice() == "0");
+        assert!(format!("{:o}", 0i).as_slice() == "0");
+        assert!(format!("{:x}", 0i).as_slice() == "0");
+        assert!(format!("{:X}", 0i).as_slice() == "0");
+
+        assert!(format!("{}", 0u).as_slice() == "0");
+        assert!(format!("{:u}", 0u).as_slice() == "0");
+        assert!(format!("{:t}", 0u).as_slice() == "0");
+        assert!(format!("{:o}", 0u).as_slice() == "0");
+        assert!(format!("{:x}", 0u).as_slice() == "0");
+        assert!(format!("{:X}", 0u).as_slice() == "0");
     }
 
     #[test]
     fn test_format_int_flags() {
-        assert_eq!(format!("{:3d}", 1), "  1".to_owned());
-        assert_eq!(format!("{:>3d}", 1), "  1".to_owned());
-        assert_eq!(format!("{:>+3d}", 1), " +1".to_owned());
-        assert_eq!(format!("{:<3d}", 1), "1  ".to_owned());
-        assert_eq!(format!("{:#d}", 1), "1".to_owned());
-        assert_eq!(format!("{:#x}", 10), "0xa".to_owned());
-        assert_eq!(format!("{:#X}", 10), "0xA".to_owned());
-        assert_eq!(format!("{:#5x}", 10), "  0xa".to_owned());
-        assert_eq!(format!("{:#o}", 10), "0o12".to_owned());
-        assert_eq!(format!("{:08x}", 10), "0000000a".to_owned());
-        assert_eq!(format!("{:8x}", 10), "       a".to_owned());
-        assert_eq!(format!("{:<8x}", 10), "a       ".to_owned());
-        assert_eq!(format!("{:>8x}", 10), "       a".to_owned());
-        assert_eq!(format!("{:#08x}", 10), "0x00000a".to_owned());
-        assert_eq!(format!("{:08d}", -10), "-0000010".to_owned());
-        assert_eq!(format!("{:x}", -1u8), "ff".to_owned());
-        assert_eq!(format!("{:X}", -1u8), "FF".to_owned());
-        assert_eq!(format!("{:t}", -1u8), "11111111".to_owned());
-        assert_eq!(format!("{:o}", -1u8), "377".to_owned());
-        assert_eq!(format!("{:#x}", -1u8), "0xff".to_owned());
-        assert_eq!(format!("{:#X}", -1u8), "0xFF".to_owned());
-        assert_eq!(format!("{:#t}", -1u8), "0b11111111".to_owned());
-        assert_eq!(format!("{:#o}", -1u8), "0o377".to_owned());
+        assert!(format!("{:3d}", 1).as_slice() == "  1");
+        assert!(format!("{:>3d}", 1).as_slice() == "  1");
+        assert!(format!("{:>+3d}", 1).as_slice() == " +1");
+        assert!(format!("{:<3d}", 1).as_slice() == "1  ");
+        assert!(format!("{:#d}", 1).as_slice() == "1");
+        assert!(format!("{:#x}", 10).as_slice() == "0xa");
+        assert!(format!("{:#X}", 10).as_slice() == "0xA");
+        assert!(format!("{:#5x}", 10).as_slice() == "  0xa");
+        assert!(format!("{:#o}", 10).as_slice() == "0o12");
+        assert!(format!("{:08x}", 10).as_slice() == "0000000a");
+        assert!(format!("{:8x}", 10).as_slice() == "       a");
+        assert!(format!("{:<8x}", 10).as_slice() == "a       ");
+        assert!(format!("{:>8x}", 10).as_slice() == "       a");
+        assert!(format!("{:#08x}", 10).as_slice() == "0x00000a");
+        assert!(format!("{:08d}", -10).as_slice() == "-0000010");
+        assert!(format!("{:x}", -1u8).as_slice() == "ff");
+        assert!(format!("{:X}", -1u8).as_slice() == "FF");
+        assert!(format!("{:t}", -1u8).as_slice() == "11111111");
+        assert!(format!("{:o}", -1u8).as_slice() == "377");
+        assert!(format!("{:#x}", -1u8).as_slice() == "0xff");
+        assert!(format!("{:#X}", -1u8).as_slice() == "0xFF");
+        assert!(format!("{:#t}", -1u8).as_slice() == "0b11111111");
+        assert!(format!("{:#o}", -1u8).as_slice() == "0o377");
     }
 
     #[test]
     fn test_format_int_sign_padding() {
-        assert_eq!(format!("{:+5d}", 1), "   +1".to_owned());
-        assert_eq!(format!("{:+5d}", -1), "   -1".to_owned());
-        assert_eq!(format!("{:05d}", 1), "00001".to_owned());
-        assert_eq!(format!("{:05d}", -1), "-0001".to_owned());
-        assert_eq!(format!("{:+05d}", 1), "+0001".to_owned());
-        assert_eq!(format!("{:+05d}", -1), "-0001".to_owned());
+        assert!(format!("{:+5d}", 1).as_slice() == "   +1");
+        assert!(format!("{:+5d}", -1).as_slice() == "   -1");
+        assert!(format!("{:05d}", 1).as_slice() == "00001");
+        assert!(format!("{:05d}", -1).as_slice() == "-0001");
+        assert!(format!("{:+05d}", 1).as_slice() == "+0001");
+        assert!(format!("{:+05d}", -1).as_slice() == "-0001");
     }
 
     #[test]
     fn test_format_int_twos_complement() {
         use {i8, i16, i32, i64};
-        assert_eq!(format!("{}", i8::MIN), "-128".to_owned());
-        assert_eq!(format!("{}", i16::MIN), "-32768".to_owned());
-        assert_eq!(format!("{}", i32::MIN), "-2147483648".to_owned());
-        assert_eq!(format!("{}", i64::MIN), "-9223372036854775808".to_owned());
+        assert!(format!("{}", i8::MIN).as_slice() == "-128");
+        assert!(format!("{}", i16::MIN).as_slice() == "-32768");
+        assert!(format!("{}", i32::MIN).as_slice() == "-2147483648");
+        assert!(format!("{}", i64::MIN).as_slice() == "-9223372036854775808");
     }
 
     #[test]
     fn test_format_radix() {
-        assert_eq!(format!("{:04}", radix(3, 2)), "0011".to_owned());
-        assert_eq!(format!("{}", radix(55, 36)), "1j".to_owned());
+        assert!(format!("{:04}", radix(3, 2)).as_slice() == "0011");
+        assert!(format!("{}", radix(55, 36)).as_slice() == "1j");
     }
 
     #[test]
index aa7a8f0f8b63af28ae33f0ebaf12cca34eae4306..b72eebe85c587441ea81bf07b21a9e405b3037f1 100644 (file)
@@ -469,6 +469,7 @@ mod tests {
     use option::{Some,None};
     use realstd::str::StrAllocating;
     use realstd::owned::Box;
+    use realstd::vec::Vec;
     use raw;
 
     #[test]
@@ -568,7 +569,7 @@ impl Foo for int {}
         }
 
         unsafe {
-            assert_eq!(box [76u8], transmute("L".to_owned()));
+            assert!(Vec::from_slice([76u8]) == transmute("L".to_owned()));
         }
     }
 }
index 00f21ee4c9cedee495cd2d9dfd8e400cdc95d223..adea8ac630e27b3dcfbb4859f4e6314e6854b251 100644 (file)
@@ -188,14 +188,14 @@ pub fn is_none(&self) -> bool {
     ///
     /// # Example
     ///
-    /// Convert an `Option<~str>` into an `Option<int>`, preserving the original.
+    /// Convert an `Option<StrBuf>` into an `Option<int>`, preserving the original.
     /// The `map` method takes the `self` argument by value, consuming the original,
     /// so this technique uses `as_ref` to first take an `Option` to a reference
     /// to the value inside the original.
     ///
     /// ```
-    /// let num_as_str: Option<~str> = Some("10".to_owned());
-    /// // First, cast `Option<~str>` to `Option<&~str>` with `as_ref`,
+    /// let num_as_str: Option<StrBuf> = Some("10".to_strbuf());
+    /// // First, cast `Option<StrBuf>` to `Option<&StrBuf>` with `as_ref`,
     /// // then consume *that* with `map`, leaving `num_as_str` on the stack.
     /// let num_as_int: Option<uint> = num_as_str.as_ref().map(|n| n.len());
     /// println!("still can print num_as_str: {}", num_as_str);
@@ -278,10 +278,10 @@ pub fn unwrap_or_else(self, f: || -> T) -> T {
     ///
     /// # Example
     ///
-    /// Convert an `Option<~str>` into an `Option<uint>`, consuming the original:
+    /// Convert an `Option<StrBuf>` into an `Option<uint>`, consuming the original:
     ///
     /// ```
-    /// let num_as_str: Option<~str> = Some("10".to_owned());
+    /// let num_as_str: Option<StrBuf> = Some("10".to_strbuf());
     /// // `Option::map` takes self *by value*, consuming `num_as_str`
     /// let num_as_int: Option<uint> = num_as_str.map(|n| n.len());
     /// ```
@@ -596,9 +596,10 @@ pub fn collect<T, Iter: Iterator<Option<T>>, V: FromIterator<T>>(iter: Iter) ->
 #[cfg(test)]
 mod tests {
     use realstd::vec::Vec;
-    use realstd::str::StrAllocating;
+    use realstd::strbuf::StrBuf;
     use option::collect;
     use prelude::*;
+    use realstd::str::{Str, StrAllocating};
     use iter::range;
 
     use str::StrSlice;
@@ -619,11 +620,11 @@ fn test_get_ptr() {
 
     #[test]
     fn test_get_str() {
-        let x = "test".to_owned();
-        let addr_x = x.as_ptr();
+        let x = "test".to_strbuf();
+        let addr_x = x.as_slice().as_ptr();
         let opt = Some(x);
         let y = opt.unwrap();
-        let addr_y = y.as_ptr();
+        let addr_y = y.as_slice().as_ptr();
         assert_eq!(addr_x, addr_y);
     }
 
@@ -745,7 +746,8 @@ fn test_option_while_some() {
     #[test]
     fn test_unwrap() {
         assert_eq!(Some(1).unwrap(), 1);
-        assert_eq!(Some("hello".to_owned()).unwrap(), "hello".to_owned());
+        let s = Some("hello".to_strbuf()).unwrap();
+        assert_eq!(s.as_slice(), "hello");
     }
 
     #[test]
@@ -758,7 +760,7 @@ fn test_unwrap_fail1() {
     #[test]
     #[should_fail]
     fn test_unwrap_fail2() {
-        let x: Option<~str> = None;
+        let x: Option<StrBuf> = None;
         x.unwrap();
     }
 
index 870fa0ec53f8d6ef6a2e36180cd115fc2f8e9268..90b5b0d8753e432af7d80df6f21da82231681f97 100644 (file)
@@ -486,6 +486,7 @@ pub mod ptr_tests {
     use mem;
     use libc;
     use realstd::str;
+    use realstd::str::Str;
     use slice::{ImmutableVector, MutableVector};
 
     #[test]
@@ -660,7 +661,7 @@ fn test_ptr_array_each_with_len() {
                     let expected = expected_arr[ctr].with_ref(|buf| {
                             str::raw::from_c_str(buf)
                         });
-                    assert_eq!(actual, expected);
+                    assert_eq!(actual.as_slice(), expected.as_slice());
                     ctr += 1;
                     iteration_count += 1;
                 });
@@ -693,7 +694,7 @@ fn test_ptr_array_each() {
                     let expected = expected_arr[ctr].with_ref(|buf| {
                         str::raw::from_c_str(buf)
                     });
-                    assert_eq!(actual, expected);
+                    assert_eq!(actual.as_slice(), expected.as_slice());
                     ctr += 1;
                     iteration_count += 1;
                 });
index 25f40b358ab259fbb0df60d4fa9feac6a4b3b673..979eeb657b6a62609ac1d7e000a12e8b72129fe4 100644 (file)
@@ -81,7 +81,6 @@ impl<'a, T> Repr<Slice<T>> for &'a [T] {}
 impl<'a> Repr<Slice<u8>> for &'a str {}
 impl<T> Repr<*Box<T>> for @T {}
 impl<T> Repr<*Vec<T>> for ~[T] {}
-impl Repr<*String> for ~str {}
 
 #[cfg(test)]
 mod tests {
index 46f4427e8387e67074bfa9a0c49d9fa8a1cce5af..98d1782f20f53e035f1ce14f2e9054f48734ea8e 100644 (file)
 //! ~~~
 //! use std::io::{File, Open, Write, IoError};
 //!
-//! struct Info { name: ~str, age: int, rating: int }
+//! struct Info {
+//!     name: StrBuf,
+//!     age: int,
+//!     rating: int
+//! }
 //!
 //! fn write_info(info: &Info) -> Result<(), IoError> {
 //!     let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
 //!     // Early return on error
-//!     match file.write_line(format!("name: {}", info.name)) {
+//!     match file.write_line(format!("name: {}", info.name).as_slice()) {
 //!         Ok(_) => (),
 //!         Err(e) => return Err(e)
 //!     }
-//!     match file.write_line(format!("age: {}", info.age)) {
+//!     match file.write_line(format!("age: {}", info.age).as_slice()) {
 //!         Ok(_) => (),
 //!         Err(e) => return Err(e)
 //!     }
-//!     return file.write_line(format!("rating: {}", info.rating));
+//!     return file.write_line(format!("rating: {}", info.rating).as_slice());
 //! }
 //! ~~~
 //!
 //! ~~~
 //! use std::io::{File, Open, Write, IoError};
 //!
-//! struct Info { name: ~str, age: int, rating: int }
+//! struct Info {
+//!     name: StrBuf,
+//!     age: int,
+//!     rating: int
+//! }
 //!
 //! fn write_info(info: &Info) -> Result<(), IoError> {
 //!     let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
 //!     // Early return on error
-//!     try!(file.write_line(format!("name: {}", info.name)));
-//!     try!(file.write_line(format!("age: {}", info.age)));
-//!     try!(file.write_line(format!("rating: {}", info.rating)));
+//!     try!(file.write_line(format!("name: {}", info.name).as_slice()));
+//!     try!(file.write_line(format!("age: {}", info.age).as_slice()));
+//!     try!(file.write_line(format!("rating: {}", info.rating).as_slice()));
 //!     return Ok(());
 //! }
 //! ~~~
@@ -421,10 +429,10 @@ pub fn as_mut<'r>(&'r mut self) -> Result<&'r mut T, &'r mut E> {
     /// let mut sum = 0;
     ///
     /// while !reader.eof() {
-    ///     let line: IoResult<~str> = reader.read_line();
+    ///     let line: IoResult<StrBuf> = reader.read_line();
     ///     // Convert the string line to a number using `map` and `from_str`
     ///     let val: IoResult<int> = line.map(|line| {
-    ///         from_str::<int>(line).unwrap_or(0)
+    ///         from_str::<int>(line.as_slice()).unwrap_or(0)
     ///     });
     ///     // Add the value if there were no errors, otherwise add 0
     ///     sum += val.ok().unwrap_or(0);
@@ -629,69 +637,68 @@ pub fn fold_<T,E,Iter:Iterator<Result<T,E>>>(iterator: Iter) -> Result<(),E> {
 #[cfg(test)]
 mod tests {
     use realstd::vec::Vec;
-    use realstd::str::StrAllocating;
+    use realstd::strbuf::StrBuf;
 
     use result::{collect, fold, fold_};
     use prelude::*;
+    use realstd::str::{Str, StrAllocating};
     use iter::range;
 
-    pub fn op1() -> Result<int, ~str> { Ok(666) }
-    pub fn op2() -> Result<int, ~str> { Err("sadface".to_owned()) }
+    pub fn op1() -> Result<int, &'static str> { Ok(666) }
+    pub fn op2() -> Result<int, &'static str> { Err("sadface") }
 
     #[test]
     pub fn test_and() {
         assert_eq!(op1().and(Ok(667)).unwrap(), 667);
-        assert_eq!(op1().and(Err::<(), ~str>("bad".to_owned())).unwrap_err(), "bad".to_owned());
+        assert_eq!(op1().and(Err::<(), &'static str>("bad")).unwrap_err(),
+                   "bad");
 
-        assert_eq!(op2().and(Ok(667)).unwrap_err(), "sadface".to_owned());
-        assert_eq!(op2().and(Err::<(), ~str>("bad".to_owned())).unwrap_err(), "sadface".to_owned());
+        assert_eq!(op2().and(Ok(667)).unwrap_err(), "sadface");
+        assert_eq!(op2().and(Err::<(),&'static str>("bad")).unwrap_err(),
+                   "sadface");
     }
 
     #[test]
     pub fn test_and_then() {
-        assert_eq!(op1().and_then(|i| Ok::<int, ~str>(i + 1)).unwrap(), 667);
-        assert_eq!(op1().and_then(|_| Err::<int, ~str>("bad".to_owned())).unwrap_err(),
-                   "bad".to_owned());
-
-        assert_eq!(op2().and_then(|i| Ok::<int, ~str>(i + 1)).unwrap_err(),
-                   "sadface".to_owned());
-        assert_eq!(op2().and_then(|_| Err::<int, ~str>("bad".to_owned())).unwrap_err(),
-                   "sadface".to_owned());
+        assert_eq!(op1().and_then(|i| Ok::<int, &'static str>(i + 1)).unwrap(), 667);
+        assert_eq!(op1().and_then(|_| Err::<int, &'static str>("bad")).unwrap_err(),
+                   "bad");
+
+        assert_eq!(op2().and_then(|i| Ok::<int, &'static str>(i + 1)).unwrap_err(),
+                   "sadface");
+        assert_eq!(op2().and_then(|_| Err::<int, &'static str>("bad")).unwrap_err(),
+                   "sadface");
     }
 
     #[test]
     pub fn test_or() {
         assert_eq!(op1().or(Ok(667)).unwrap(), 666);
-        assert_eq!(op1().or(Err("bad".to_owned())).unwrap(), 666);
+        assert_eq!(op1().or(Err("bad")).unwrap(), 666);
 
         assert_eq!(op2().or(Ok(667)).unwrap(), 667);
-        assert_eq!(op2().or(Err("bad".to_owned())).unwrap_err(), "bad".to_owned());
+        assert_eq!(op2().or(Err("bad")).unwrap_err(), "bad");
     }
 
     #[test]
     pub fn test_or_else() {
-        assert_eq!(op1().or_else(|_| Ok::<int, ~str>(667)).unwrap(), 666);
-        assert_eq!(op1().or_else(|e| Err::<int, ~str>(e + "!")).unwrap(), 666);
+        assert_eq!(op1().or_else(|_| Ok::<int, &'static str>(667)).unwrap(), 666);
+        assert_eq!(op1().or_else(|e| Err::<int, &'static str>(e)).unwrap(), 666);
 
-        assert_eq!(op2().or_else(|_| Ok::<int, ~str>(667)).unwrap(), 667);
-        assert_eq!(op2().or_else(|e| Err::<int, ~str>(e + "!")).unwrap_err(),
-                   "sadface!".to_owned());
+        assert_eq!(op2().or_else(|_| Ok::<int, &'static str>(667)).unwrap(), 667);
+        assert_eq!(op2().or_else(|e| Err::<int, &'static str>(e)).unwrap_err(),
+                   "sadface");
     }
 
     #[test]
     pub fn test_impl_map() {
-        assert_eq!(Ok::<~str, ~str>("a".to_owned()).map(|x| x + "b"),
-                   Ok("ab".to_owned()));
-        assert_eq!(Err::<~str, ~str>("a".to_owned()).map(|x| x + "b"),
-                   Err("a".to_owned()));
+        assert!(Ok::<int, int>(1).map(|x| x + 1) == Ok(2));
+        assert!(Err::<int, int>(1).map(|x| x + 1) == Err(1));
     }
 
     #[test]
     pub fn test_impl_map_err() {
-        assert_eq!(Ok::<~str, ~str>("a".to_owned()).map_err(|x| x + "b"),
-                   Ok("a".to_owned()));
-        assert_eq!(Err::<~str, ~str>("a".to_owned()).map_err(|x| x + "b"),
-                   Err("ab".to_owned()));
+        assert!(Ok::<int, int>(1).map_err(|x| x + 1) == Ok(1));
+        assert!(Err::<int, int>(1).map_err(|x| x + 1) == Err(2));
     }
 
     #[test]
@@ -736,17 +743,19 @@ fn test_fold() {
 
     #[test]
     pub fn test_fmt_default() {
-        let ok: Result<int, ~str> = Ok(100);
-        let err: Result<int, ~str> = Err("Err".to_owned());
+        let ok: Result<int, &'static str> = Ok(100);
+        let err: Result<int, &'static str> = Err("Err");
 
-        assert_eq!(format!("{}", ok), "Ok(100)".to_owned());
-        assert_eq!(format!("{}", err), "Err(Err)".to_owned());
+        let s = format!("{}", ok);
+        assert_eq!(s.as_slice(), "Ok(100)");
+        let s = format!("{}", err);
+        assert_eq!(s.as_slice(), "Err(Err)");
     }
 
     #[test]
     pub fn test_unwrap_or() {
-        let ok: Result<int, ~str> = Ok(100);
-        let ok_err: Result<int, ~str> = Err("Err".to_owned());
+        let ok: Result<int, &'static str> = Ok(100);
+        let ok_err: Result<int, &'static str> = Err("Err");
 
         assert_eq!(ok.unwrap_or(50), 100);
         assert_eq!(ok_err.unwrap_or(50), 50);
@@ -754,16 +763,16 @@ pub fn test_unwrap_or() {
 
     #[test]
     pub fn test_unwrap_or_else() {
-        fn handler(msg: ~str) -> int {
-            if msg == "I got this.".to_owned() {
+        fn handler(msg: &'static str) -> int {
+            if msg == "I got this." {
                 50
             } else {
                 fail!("BadBad")
             }
         }
 
-        let ok: Result<int, ~str> = Ok(100);
-        let ok_err: Result<int, ~str> = Err("I got this.".to_owned());
+        let ok: Result<int, &'static str> = Ok(100);
+        let ok_err: Result<int, &'static str> = Err("I got this.");
 
         assert_eq!(ok.unwrap_or_else(handler), 100);
         assert_eq!(ok_err.unwrap_or_else(handler), 50);
@@ -772,15 +781,15 @@ fn handler(msg: ~str) -> int {
     #[test]
     #[should_fail]
     pub fn test_unwrap_or_else_failure() {
-        fn handler(msg: ~str) -> int {
-            if msg == "I got this.".to_owned() {
+        fn handler(msg: &'static str) -> int {
+            if msg == "I got this." {
                 50
             } else {
                 fail!("BadBad")
             }
         }
 
-        let bad_err: Result<int, ~str> = Err("Unrecoverable mess.".to_owned());
+        let bad_err: Result<int, &'static str> = Err("Unrecoverable mess.");
         let _ : int = bad_err.unwrap_or_else(handler);
     }
 }
index 2046017869dea9ef44fb2321a5e91ff109a2bce2..9a0e3ad7ca4ac912fd01d238e171f8baec3d8d79 100644 (file)
@@ -10,9 +10,9 @@
 
 // As noted by this file name, this file should not exist. This file should not
 // exist because it performs allocations which libcore is not allowed to do. The
-// reason for this file's existence is that the `~[T]` and `~str` types are
-// language-defined types. Traits are defined in libcore, such as `Clone`, which
-// these types need to implement, but the implementation can only be found in
+// reason for this file's existence is that the `~[T]` type is a language-
+// defined type. Traits are defined in libcore, such as `Clone`, which these
+// types need to implement, but the implementation can only be found in
 // libcore.
 //
 // Plan of attack for solving this problem:
 //
 // Currently, no progress has been made on this list.
 
-use char::Char;
 use clone::Clone;
 use container::Container;
-use default::Default;
 use finally::try_finally;
 use intrinsics;
-use iter::{range, Iterator, FromIterator};
+use iter::{range, Iterator};
 use mem;
 use num::{CheckedMul, CheckedAdd};
 use option::{Some, None};
@@ -38,9 +36,6 @@
 use ptr;
 use raw::Vec;
 use slice::ImmutableVector;
-use str::StrSlice;
-
-#[cfg(not(test))] use ops::Add;
 
 #[allow(ctypes)]
 extern {
@@ -60,105 +55,6 @@ unsafe fn alloc(cap: uint) -> *mut Vec<()> {
     ret
 }
 
-// Strings
-
-impl Default for ~str {
-    fn default() -> ~str {
-        unsafe {
-            // Get some memory
-            let ptr = alloc(0);
-
-            // Initialize the memory
-            (*ptr).fill = 0;
-            (*ptr).alloc = 0;
-
-            mem::transmute(ptr)
-        }
-    }
-}
-
-impl Clone for ~str {
-    fn clone(&self) -> ~str {
-        // Don't use the clone() implementation above because it'll start
-        // requiring the eh_personality lang item (no fun)
-        unsafe {
-            let bytes = self.as_bytes().as_ptr();
-            let len = self.len();
-
-            let ptr = alloc(len) as *mut Vec<u8>;
-            ptr::copy_nonoverlapping_memory(&mut (*ptr).data, bytes, len);
-            (*ptr).fill = len;
-            (*ptr).alloc = len;
-
-            mem::transmute(ptr)
-        }
-    }
-}
-
-impl FromIterator<char> for ~str {
-    #[inline]
-    fn from_iter<T: Iterator<char>>(mut iterator: T) -> ~str {
-        let (lower, _) = iterator.size_hint();
-        let mut cap = if lower == 0 {16} else {lower};
-        let mut len = 0;
-        let mut tmp = [0u8, ..4];
-
-        unsafe {
-            let mut ptr = alloc(cap) as *mut Vec<u8>;
-            let mut ret = mem::transmute(ptr);
-            for ch in iterator {
-                let amt = ch.encode_utf8(tmp);
-
-                if len + amt > cap {
-                    cap = cap.checked_mul(&2).unwrap();
-                    if cap < len + amt {
-                        cap = len + amt;
-                    }
-                    let ptr2 = alloc(cap) as *mut Vec<u8>;
-                    ptr::copy_nonoverlapping_memory(&mut (*ptr2).data,
-                                                    &(*ptr).data,
-                                                    len);
-                    // FIXME: #13994: port to the sized deallocation API when available
-                    rust_deallocate(ptr as *u8, 0, 8);
-                    mem::forget(ret);
-                    ret = mem::transmute(ptr2);
-                    ptr = ptr2;
-                }
-
-                let base = &mut (*ptr).data as *mut u8;
-                for byte in tmp.slice_to(amt).iter() {
-                    *base.offset(len as int) = *byte;
-                    len += 1;
-                }
-                (*ptr).fill = len;
-            }
-            ret
-        }
-    }
-}
-
-#[cfg(not(test))]
-impl<'a> Add<&'a str,~str> for &'a str {
-    #[inline]
-    fn add(&self, rhs: & &'a str) -> ~str {
-        let amt = self.len().checked_add(&rhs.len()).unwrap();
-        unsafe {
-            let ptr = alloc(amt) as *mut Vec<u8>;
-            let base = &mut (*ptr).data as *mut _;
-            ptr::copy_nonoverlapping_memory(base,
-                                            self.as_bytes().as_ptr(),
-                                            self.len());
-            let base = base.offset(self.len() as int);
-            ptr::copy_nonoverlapping_memory(base,
-                                            rhs.as_bytes().as_ptr(),
-                                            rhs.len());
-            (*ptr).fill = amt;
-            (*ptr).alloc = amt;
-            mem::transmute(ptr)
-        }
-    }
-}
-
 // Arrays
 
 impl<A: Clone> Clone for ~[A] {
index 19be2fd3169c83c9df3b00aa1dce97b3ff0900e3..0b264b1724df022fe67ed45d71220ef59b0313c2 100644 (file)
@@ -25,7 +25,7 @@
 use num::Saturating;
 use option::{None, Option, Some};
 use raw::Repr;
-use slice::{ImmutableVector, Vector};
+use slice::ImmutableVector;
 use slice;
 use uint;
 
@@ -596,20 +596,6 @@ pub fn eq_slice(a: &str, b: &str) -> bool {
     eq_slice_(a, b)
 }
 
-/// Bytewise string equality
-#[cfg(not(test))]
-#[lang="uniq_str_eq"]
-#[inline]
-pub fn eq(a: &~str, b: &~str) -> bool {
-    eq_slice(*a, *b)
-}
-
-#[cfg(test)]
-#[inline]
-pub fn eq(a: &~str, b: &~str) -> bool {
-    eq_slice(*a, *b)
-}
-
 /*
 Section: Misc
 */
@@ -976,11 +962,6 @@ fn cmp(&self, other: & &'a str) -> Ordering {
         }
     }
 
-    impl TotalOrd for ~str {
-        #[inline]
-        fn cmp(&self, other: &~str) -> Ordering { self.as_slice().cmp(&other.as_slice()) }
-    }
-
     impl<'a> Eq for &'a str {
         #[inline]
         fn eq(&self, other: & &'a str) -> bool {
@@ -990,36 +971,17 @@ fn eq(&self, other: & &'a str) -> bool {
         fn ne(&self, other: & &'a str) -> bool { !(*self).eq(other) }
     }
 
-    impl Eq for ~str {
-        #[inline]
-        fn eq(&self, other: &~str) -> bool {
-            eq_slice((*self), (*other))
-        }
-    }
-
     impl<'a> TotalEq for &'a str {}
 
-    impl TotalEq for ~str {}
-
     impl<'a> Ord for &'a str {
         #[inline]
         fn lt(&self, other: & &'a str) -> bool { self.cmp(other) == Less }
     }
 
-    impl Ord for ~str {
-        #[inline]
-        fn lt(&self, other: &~str) -> bool { self.cmp(other) == Less }
-    }
-
     impl<'a, S: Str> Equiv<S> for &'a str {
         #[inline]
         fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
     }
-
-    impl<'a, S: Str> Equiv<S> for ~str {
-        #[inline]
-        fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
-    }
 }
 
 #[cfg(test)]
@@ -1036,11 +998,6 @@ impl<'a> Str for &'a str {
     fn as_slice<'a>(&'a self) -> &'a str { *self }
 }
 
-impl<'a> Str for ~str {
-    #[inline]
-    fn as_slice<'a>(&'a self) -> &'a str { let s: &'a str = *self; s }
-}
-
 impl<'a> Container for &'a str {
     #[inline]
     fn len(&self) -> uint {
@@ -1048,11 +1005,6 @@ fn len(&self) -> uint {
     }
 }
 
-impl Container for ~str {
-    #[inline]
-    fn len(&self) -> uint { self.as_slice().len() }
-}
-
 /// Methods for string slices
 pub trait StrSlice<'a> {
     /// Returns true if one string contains another
index b73d85489a390bc030e64880455fdd9e25ad56ea..0e21c95807d09af66f542f8e2fb99c9cd3a4d254 100644 (file)
@@ -246,11 +246,11 @@ mod tests {
     use super::*;
     use clone::Clone;
     use cmp::*;
-    use realstd::str::StrAllocating;
+    use realstd::str::{Str, StrAllocating};
 
     #[test]
     fn test_clone() {
-        let a = (1, "2".to_owned());
+        let a = (1, "2");
         let b = a.clone();
         assert_eq!(a, b);
     }
@@ -323,8 +323,11 @@ fn test_tuple_cmp() {
 
     #[test]
     fn test_show() {
-        assert_eq!(format!("{}", (1,)), "(1,)".to_owned());
-        assert_eq!(format!("{}", (1, true)), "(1, true)".to_owned());
-        assert_eq!(format!("{}", (1, "hi".to_owned(), true)), "(1, hi, true)".to_owned());
+        let s = format!("{}", (1,));
+        assert_eq!(s.as_slice(), "(1,)");
+        let s = format!("{}", (1, true));
+        assert_eq!(s.as_slice(), "(1, true)");
+        let s = format!("{}", (1, "hi", true));
+        assert_eq!(s.as_slice(), "(1, hi, true)");
     }
 }
index e12026340d8285b06e4fde2bfa32c2f313755f76..0e146505d5411893479a195d2dc8a2706835c260 100644 (file)
@@ -274,12 +274,13 @@ fn must_consume(&mut self, c: char) {
                 self.cur.next();
             }
             Some((_, other)) => {
-                self.err(
-                    format!("expected `{}` but found `{}`", c, other));
+                self.err(format!("expected `{}` but found `{}`",
+                                 c,
+                                 other).as_slice());
             }
             None => {
-                self.err(
-                    format!("expected `{}` but string was terminated", c));
+                self.err(format!("expected `{}` but string was terminated",
+                                 c).as_slice());
             }
         }
     }
@@ -307,7 +308,8 @@ fn escape(&mut self) -> char {
             Some((_, c @ '#')) | Some((_, c @ '{')) |
             Some((_, c @ '\\')) | Some((_, c @ '}')) => { c }
             Some((_, c)) => {
-                self.err(format!("invalid escape character `{}`", c));
+                self.err(format!("invalid escape character `{}`",
+                                 c).as_slice());
                 c
             }
             None => {
@@ -459,7 +461,7 @@ fn method(&mut self) -> Option<Box<Method<'a>>> {
                 return None;
             }
             method => {
-                self.err(format!("unknown method: `{}`", method));
+                self.err(format!("unknown method: `{}`", method).as_slice());
                 return None;
             }
         }
@@ -526,7 +528,7 @@ fn plural(&mut self) -> Box<Method<'a>> {
                         let word = self.word();
                         if word != "offset" {
                             self.err(format!("expected `offset`, found `{}`",
-                                             word));
+                                             word).as_slice());
                         } else {
                             self.must_consume(':');
                             match self.integer() {
@@ -566,7 +568,7 @@ fn plural(&mut self) -> Box<Method<'a>> {
                     "many"  => Keyword(Many),
                     word    => {
                         self.err(format!("unexpected plural selector `{}`",
-                                         word));
+                                         word).as_slice());
                         if word == "" {
                             break
                         } else {
index ba30e1a2e986bb12e8874627bb44a728acf316f0..60528776294e98a7761c253edc46b79c0a0b4548 100644 (file)
@@ -661,7 +661,7 @@ pub fn getopts(args: &[StrBuf], optgrps: &[OptGroup]) -> Result {
 /// Derive a usage message from a set of long options.
 pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
 
-    let desc_sep = "\n" + " ".repeat(24);
+    let desc_sep = format!("\n{}", " ".repeat(24));
 
     let mut rows = opts.iter().map(|optref| {
         let OptGroup{short_name: short_name,
@@ -713,7 +713,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
                 row.push_char(' ');
             }
         } else {
-            row.push_str(desc_sep)
+            row.push_str(desc_sep.as_slice())
         }
 
         // Normalize desc to contain words separated by one space character
@@ -734,7 +734,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> StrBuf {
 
         // FIXME: #5516 should be graphemes not codepoints
         // wrapped description
-        row.push_str(desc_rows.connect(desc_sep));
+        row.push_str(desc_rows.connect(desc_sep.as_slice()).as_slice());
 
         row
     });
@@ -784,7 +784,11 @@ fn format_option(opt: &OptGroup) -> StrBuf {
 /// Derive a short one-line usage summary from a set of long options.
 pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> StrBuf {
     let mut line = format_strbuf!("Usage: {} ", program_name);
-    line.push_str(opts.iter().map(format_option).collect::<Vec<StrBuf>>().connect(" "));
+    line.push_str(opts.iter()
+                      .map(format_option)
+                      .collect::<Vec<StrBuf>>()
+                      .connect(" ")
+                      .as_slice());
     line
 }
 
index 7b9260c7eb9dcffe215870b54c4afa632c87ebbf..e4b1278f3d9dbb68731a9dc99ed78f3cf039424c 100644 (file)
@@ -690,13 +690,13 @@ fn test_range_pattern() {
 
         let pat = Pattern::new("a[0-9]b");
         for i in range(0, 10) {
-            assert!(pat.matches(format!("a{}b", i)));
+            assert!(pat.matches(format!("a{}b", i).as_slice()));
         }
         assert!(!pat.matches("a_b"));
 
         let pat = Pattern::new("a[!0-9]b");
         for i in range(0, 10) {
-            assert!(!pat.matches(format!("a{}b", i)));
+            assert!(!pat.matches(format!("a{}b", i).as_slice()));
         }
         assert!(pat.matches("a_b"));
 
@@ -704,11 +704,11 @@ fn test_range_pattern() {
         for &p in pats.iter() {
             let pat = Pattern::new(p);
             for c in "abcdefghijklmnopqrstuvwxyz".chars() {
-                assert!(pat.matches(c.to_str()));
+                assert!(pat.matches(c.to_str().as_slice()));
             }
             for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars() {
                 let options = MatchOptions {case_sensitive: false, .. MatchOptions::new()};
-                assert!(pat.matches_with(c.to_str(), options));
+                assert!(pat.matches_with(c.to_str().as_slice(), options));
             }
             assert!(pat.matches("1"));
             assert!(pat.matches("2"));
index 1921eef9f60d46d4d6fa28dc2f22485265ac0e7a..eddf17b34b9ff070075b53a44f73bd54fc20c150 100644 (file)
@@ -46,7 +46,7 @@ macro_rules! rtassert (
 
 macro_rules! rtabort (
     ($($arg:tt)*) => ( {
-        ::macros::abort(format!($($arg)*));
+        ::macros::abort(format!($($arg)*).as_slice());
     } )
 )
 
index dda14fb10af027d25086a84a70569316e8f443f7..9f731637a3b513c65170a2c2a0fc5c86ce063917 100644 (file)
@@ -147,7 +147,10 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
             Some((err_pos, err_str)) => {
                 let pos = expr.span.lo + syntax::codemap::Pos::from_uint(err_pos + 1);
                 let span = syntax::codemap::mk_sp(pos,pos);
-                cx.span_err(span, format!("invalid hex float literal in hexfloat!: {}", err_str));
+                cx.span_err(span,
+                            format!("invalid hex float literal in hexfloat!: \
+                                     {}",
+                                    err_str).as_slice());
                 return base::DummyResult::expr(sp);
             }
             _ => ()
index 5981f87b4f2b6fbe988a7ea5fbc762d75ac5fae8..a9c0501ee3e095caf1a99f9033c763c772e3c6ee 100644 (file)
@@ -302,8 +302,10 @@ pub fn mod_enabled(level: u32, module: &str) -> bool {
     enabled(level, module, unsafe { (*DIRECTIVES).iter() })
 }
 
-fn enabled(level: u32, module: &str,
-           iter: slice::Items<directive::LogDirective>) -> bool {
+fn enabled(level: u32,
+           module: &str,
+           iter: slice::Items<directive::LogDirective>)
+           -> bool {
     // Search for the longest match, the vector is assumed to be pre-sorted.
     for directive in iter.rev() {
         match directive.name {
@@ -322,7 +324,7 @@ fn enabled(level: u32, module: &str,
 /// `Once` primitive (and this function is called from that primitive).
 fn init() {
     let mut directives = match os::getenv("RUST_LOG") {
-        Some(spec) => directive::parse_logging_spec(spec),
+        Some(spec) => directive::parse_logging_spec(spec.as_slice()),
         None => Vec::new(),
     };
 
index 8ebae70f73c04c0e08120e2e620dc8fca7c5f300..64b082d9f3f58e940e7b50ee00efb247e0a47e5a 100644 (file)
@@ -104,9 +104,10 @@ fn get_error(_: c_int) -> IoError {
 #[cfg(not(windows))]
 fn get_error(s: c_int) -> IoError {
     use std::io;
-    use std::str::raw::from_c_str;
 
-    let err_str = unsafe { from_c_str(gai_strerror(s)) };
+    let err_str = unsafe {
+        CString::new(gai_strerror(s), false).as_str().unwrap().to_strbuf()
+    };
     IoError {
         kind: io::OtherIoError,
         desc: "unable to resolve host",
index 9693f772170093a2b72ee9cae54b5d67dd4ba3e3..f320aca2bfcbf54d1f26a5c81f694cb513b592b8 100644 (file)
@@ -450,7 +450,9 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
                                   libc::VOLUME_NAME_DOS)
     });
     let ret = match ret {
-        Some(ref s) if s.starts_with(r"\\?\") => Ok(Path::new(s.slice_from(4))),
+        Some(ref s) if s.as_slice().starts_with(r"\\?\") => {
+            Ok(Path::new(s.as_slice().slice_from(4)))
+        }
         Some(s) => Ok(Path::new(s)),
         None => Err(super::last_error()),
     };
index 04911bc5f1bd670648c9c4a3e47cdd6af2e078a4..80b00dfb3fe57dbdae73621d602058401a6827da 100644 (file)
@@ -323,7 +323,7 @@ fn spawn_process_os(cfg: ProcessConfig, in_fd: c_int, out_fd: c_int, err_fd: c_i
 
         with_envp(cfg.env, |envp| {
             with_dirp(cfg.cwd, |dirp| {
-                os::win32::as_mut_utf16_p(cmd_str, |cmdp| {
+                os::win32::as_mut_utf16_p(cmd_str.as_slice(), |cmdp| {
                     let created = CreateProcessW(ptr::null(),
                                                  cmdp,
                                                  ptr::mut_null(),
@@ -396,7 +396,7 @@ fn zeroed_process_information() -> libc::types::os::arch::extra::PROCESS_INFORMA
 }
 
 #[cfg(windows)]
-fn make_command_line(prog: &CString, args: &[CString]) -> ~str {
+fn make_command_line(prog: &CString, args: &[CString]) -> StrBuf {
     let mut cmd = StrBuf::new();
     append_arg(&mut cmd, prog.as_str()
                              .expect("expected program name to be utf-8 encoded"));
@@ -405,7 +405,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> ~str {
         append_arg(&mut cmd, arg.as_str()
                                 .expect("expected argument to be utf-8 encoded"));
     }
-    return cmd.into_owned();
+    return cmd;
 
     fn append_arg(cmd: &mut StrBuf, arg: &str) {
         let quote = arg.chars().any(|c| c == ' ' || c == '\t');
@@ -1093,7 +1093,7 @@ fn test_make_command_line() {
         use std::c_str::CString;
         use super::make_command_line;
 
-        fn test_wrapper(prog: &str, args: &[&str]) -> ~str {
+        fn test_wrapper(prog: &str, args: &[&str]) -> StrBuf {
             make_command_line(&prog.to_c_str(),
                               args.iter()
                                   .map(|a| a.to_c_str())
index ecc48d5569c0e20a3a91f6be9a7c811893d9f67b..9267aea01b4e251b1cdee9ccc20e9adb3a604a17 100644 (file)
@@ -604,7 +604,7 @@ fn to_biguint(&self) -> Option<BigUint> {
 impl_to_biguint!(u64,  FromPrimitive::from_u64)
 
 impl ToStrRadix for BigUint {
-    fn to_str_radix(&self, radix: uint) -> ~str {
+    fn to_str_radix(&self, radix: uint) -> StrBuf {
         assert!(1 < radix && radix <= 16);
         let (base, max_len) = get_radix_base(radix);
         if base == BigDigit::base {
@@ -627,15 +627,17 @@ fn convert_base(n: &BigUint, base: DoubleBigDigit) -> Vec<BigDigit> {
             return result;
         }
 
-        fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str {
-            if v.is_empty() { return "0".to_owned() }
+        fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> StrBuf {
+            if v.is_empty() {
+                return "0".to_strbuf()
+            }
             let mut s = StrBuf::with_capacity(v.len() * l);
             for n in v.iter().rev() {
                 let ss = (*n as uint).to_str_radix(radix);
-                s.push_str("0".repeat(l - ss.len()));
-                s.push_str(ss);
+                s.push_str("0".repeat(l - ss.len()).as_slice());
+                s.push_str(ss.as_slice());
             }
-            s.as_slice().trim_left_chars('0').to_owned()
+            s.as_slice().trim_left_chars('0').to_strbuf()
         }
     }
 }
@@ -1209,11 +1211,11 @@ fn to_bigint(&self) -> Option<BigInt> {
 
 impl ToStrRadix for BigInt {
     #[inline]
-    fn to_str_radix(&self, radix: uint) -> ~str {
+    fn to_str_radix(&self, radix: uint) -> StrBuf {
         match self.sign {
             Plus  => self.data.to_str_radix(radix),
-            Zero  => "0".to_owned(),
-            Minus => "-".to_owned() + self.data.to_str_radix(radix)
+            Zero  => "0".to_strbuf(),
+            Minus => format_strbuf!("-{}", self.data.to_str_radix(radix)),
         }
     }
 }
@@ -1476,29 +1478,112 @@ fn check(s: &str, shift: uint, ans: &str) {
         check("0", 3, "0");
         check("1", 3, "8");
 
-        check("1" + "0000" + "0000" + "0000" + "0001" + "0000" + "0000" + "0000" + "0001", 3,
-              "8" + "0000" + "0000" + "0000" + "0008" + "0000" + "0000" + "0000" + "0008");
-        check("1" + "0000" + "0001" + "0000" + "0001", 2,
-              "4" + "0000" + "0004" + "0000" + "0004");
-        check("1" + "0001" + "0001", 1,
-              "2" + "0002" + "0002");
-
-        check(""  + "4000" + "0000" + "0000" + "0000", 3,
-              "2" + "0000" + "0000" + "0000" + "0000");
-        check(""  + "4000" + "0000", 2,
-              "1" + "0000" + "0000");
-        check(""  + "4000", 2,
-              "1" + "0000");
-
-        check(""  + "4000" + "0000" + "0000" + "0000", 67,
-              "2" + "0000" + "0000" + "0000" + "0000" + "0000" + "0000" + "0000" + "0000");
-        check(""  + "4000" + "0000", 35,
-              "2" + "0000" + "0000" + "0000" + "0000");
-        check(""  + "4000", 19,
-              "2" + "0000" + "0000");
-
-        check(""  + "fedc" + "ba98" + "7654" + "3210" + "fedc" + "ba98" + "7654" + "3210", 4,
-              "f" + "edcb" + "a987" + "6543" + "210f" + "edcb" + "a987" + "6543" + "2100");
+        check("1\
+               0000\
+               0000\
+               0000\
+               0001\
+               0000\
+               0000\
+               0000\
+               0001",
+              3,
+              "8\
+               0000\
+               0000\
+               0000\
+               0008\
+               0000\
+               0000\
+               0000\
+               0008");
+        check("1\
+               0000\
+               0001\
+               0000\
+               0001",
+              2,
+              "4\
+               0000\
+               0004\
+               0000\
+               0004");
+        check("1\
+               0001\
+               0001",
+              1,
+              "2\
+               0002\
+               0002");
+
+        check("\
+              4000\
+              0000\
+              0000\
+              0000",
+              3,
+              "2\
+              0000\
+              0000\
+              0000\
+              0000");
+        check("4000\
+              0000",
+              2,
+              "1\
+              0000\
+              0000");
+        check("4000",
+              2,
+              "1\
+              0000");
+
+        check("4000\
+              0000\
+              0000\
+              0000",
+              67,
+              "2\
+              0000\
+              0000\
+              0000\
+              0000\
+              0000\
+              0000\
+              0000\
+              0000");
+        check("4000\
+              0000",
+              35,
+              "2\
+              0000\
+              0000\
+              0000\
+              0000");
+        check("4000",
+              19,
+              "2\
+              0000\
+              0000");
+
+        check("fedc\
+              ba98\
+              7654\
+              3210\
+              fedc\
+              ba98\
+              7654\
+              3210",
+              4,
+              "f\
+              edcb\
+              a987\
+              6543\
+              210f\
+              edcb\
+              a987\
+              6543\
+              2100");
         check("88887777666655554444333322221111", 16,
               "888877776666555544443333222211110000");
     }
@@ -1515,28 +1600,107 @@ fn check(s: &str, shift: uint, ans: &str) {
         check("0", 3, "0");
         check("f", 3, "1");
 
-        check("1" + "0000" + "0000" + "0000" + "0001" + "0000" + "0000" + "0000" + "0001", 3,
-              ""  + "2000" + "0000" + "0000" + "0000" + "2000" + "0000" + "0000" + "0000");
-        check("1" + "0000" + "0001" + "0000" + "0001", 2,
-              ""  + "4000" + "0000" + "4000" + "0000");
-        check("1" + "0001" + "0001", 1,
-              ""  + "8000" + "8000");
-
-        check("2" + "0000" + "0000" + "0000" + "0001" + "0000" + "0000" + "0000" + "0001", 67,
-              ""  + "4000" + "0000" + "0000" + "0000");
-        check("2" + "0000" + "0001" + "0000" + "0001", 35,
-              ""  + "4000" + "0000");
-        check("2" + "0001" + "0001", 19,
-              ""  + "4000");
-
-        check("1" + "0000" + "0000" + "0000" + "0000", 1,
-              ""  + "8000" + "0000" + "0000" + "0000");
-        check("1" + "0000" + "0000", 1,
-              ""  + "8000" + "0000");
-        check("1" + "0000", 1,
-              ""  + "8000");
-        check("f" + "edcb" + "a987" + "6543" + "210f" + "edcb" + "a987" + "6543" + "2100", 4,
-              ""  + "fedc" + "ba98" + "7654" + "3210" + "fedc" + "ba98" + "7654" + "3210");
+        check("1\
+              0000\
+              0000\
+              0000\
+              0001\
+              0000\
+              0000\
+              0000\
+              0001",
+              3,
+              "2000\
+              0000\
+              0000\
+              0000\
+              2000\
+              0000\
+              0000\
+              0000");
+        check("1\
+              0000\
+              0001\
+              0000\
+              0001",
+              2,
+              "4000\
+              0000\
+              4000\
+              0000");
+        check("1\
+              0001\
+              0001",
+              1,
+              "8000\
+              8000");
+
+        check("2\
+              0000\
+              0000\
+              0000\
+              0001\
+              0000\
+              0000\
+              0000\
+              0001",
+              67,
+              "4000\
+              0000\
+              0000\
+              0000");
+        check("2\
+              0000\
+              0001\
+              0000\
+              0001",
+              35,
+              "4000\
+              0000");
+        check("2\
+              0001\
+              0001",
+              19,
+              "4000");
+
+        check("1\
+              0000\
+              0000\
+              0000\
+              0000",
+              1,
+              "8000\
+              0000\
+              0000\
+              0000");
+        check("1\
+              0000\
+              0000",
+              1,
+              "8000\
+              0000");
+        check("1\
+              0000",
+              1,
+              "8000");
+        check("f\
+              edcb\
+              a987\
+              6543\
+              210f\
+              edcb\
+              a987\
+              6543\
+              2100",
+              4,
+              "fedc\
+              ba98\
+              7654\
+              3210\
+              fedc\
+              ba98\
+              7654\
+              3210");
 
         check("888877776666555544443333222211110000", 16,
               "88887777666655554444333322221111");
@@ -2543,7 +2707,7 @@ fn test_abs_sub() {
     fn test_to_str_radix() {
         fn check(n: int, ans: &str) {
             let n: BigInt = FromPrimitive::from_int(n).unwrap();
-            assert!(ans == n.to_str_radix(10));
+            assert!(ans == n.to_str_radix(10).as_slice());
         }
         check(10, "10");
         check(1, "1");
@@ -2572,7 +2736,8 @@ fn check(s: &str, ans: Option<int>) {
 
         // issue 10522, this hit an edge case that caused it to
         // attempt to allocate a vector of size (-1u) == huge.
-        let x: BigInt = from_str("1" + "0".repeat(36)).unwrap();
+        let x: BigInt =
+            from_str(format!("1{}", "0".repeat(36)).as_slice()).unwrap();
         let _y = x.to_str();
     }
 
index dfbacf6e4922fd9dc36a770c16a49c4b89174cad..37d9453fabfc6e3b3a8dff99a393a6428a895759 100644 (file)
@@ -175,11 +175,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 impl<T: ToStrRadix + Num + Ord> ToStrRadix for Complex<T> {
-    fn to_str_radix(&self, radix: uint) -> ~str {
+    fn to_str_radix(&self, radix: uint) -> StrBuf {
         if self.im < Zero::zero() {
-            format!("{}-{}i", self.re.to_str_radix(radix), (-self.im).to_str_radix(radix))
+            format_strbuf!("{}-{}i",
+                           self.re.to_str_radix(radix),
+                           (-self.im).to_str_radix(radix))
         } else {
-            format!("{}+{}i", self.re.to_str_radix(radix), self.im.to_str_radix(radix))
+            format_strbuf!("{}+{}i",
+                           self.re.to_str_radix(radix),
+                           self.im.to_str_radix(radix))
         }
     }
 }
index cd5c82acf6e9a17fb11f9395371123231a0b05a9..6191b93ff8f301b5a059e939f285457ecac8583c 100644 (file)
@@ -281,8 +281,10 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 impl<T: ToStrRadix> ToStrRadix for Ratio<T> {
     /// Renders as `numer/denom` where the numbers are in base `radix`.
-    fn to_str_radix(&self, radix: uint) -> ~str {
-        format!("{}/{}", self.numer.to_str_radix(radix), self.denom.to_str_radix(radix))
+    fn to_str_radix(&self, radix: uint) -> StrBuf {
+        format_strbuf!("{}/{}",
+                       self.numer.to_str_radix(radix),
+                       self.denom.to_str_radix(radix))
     }
 }
 
@@ -582,7 +584,7 @@ fn test(s: &str) {
     #[test]
     fn test_to_from_str_radix() {
         fn test(r: Rational, s: StrBuf, n: uint) {
-            assert_eq!(FromStrRadix::from_str_radix(s.to_owned(), n),
+            assert_eq!(FromStrRadix::from_str_radix(s.as_slice(), n),
                        Some(r));
             assert_eq!(r.to_str_radix(n).to_strbuf(), s);
         }
index a695da9fa163e6cc592c585672eaf0f605beffde..beefda07f0a0db8939899f4d912a79d7893781e9 100644 (file)
@@ -278,7 +278,10 @@ fn parse(&mut self) -> Result<Ast, Error> {
     fn noteof(&mut self, expected: &str) -> Result<(), Error> {
         match self.next_char() {
             true => Ok(()),
-            false => self.err(format!("Expected {} but got EOF.", expected)),
+            false => {
+                self.err(format!("Expected {} but got EOF.",
+                                 expected).as_slice())
+            }
         }
     }
 
@@ -286,8 +289,11 @@ fn expect(&mut self, expected: char) -> Result<(), Error> {
         match self.next_char() {
             true if self.cur() == expected => Ok(()),
             true => self.err(format!("Expected '{}' but got '{}'.",
-                                     expected, self.cur())),
-            false => self.err(format!("Expected '{}' but got EOF.", expected)),
+                                     expected, self.cur()).as_slice()),
+            false => {
+                self.err(format!("Expected '{}' but got EOF.",
+                                 expected).as_slice())
+            }
         }
     }
 
@@ -429,8 +435,10 @@ fn parse_class(&mut self) -> Result<(), Error> {
                         try!(self.noteof("not a ']'"))
                         let c2 = self.cur();
                         if c2 < c {
-                            return self.err(format!(
-                                "Invalid character class range '{}-{}'", c, c2))
+                            return self.err(format!("Invalid character class \
+                                                     range '{}-{}'",
+                                                    c,
+                                                    c2).as_slice())
                         }
                         ranges.push((c, self.cur()))
                     } else {
@@ -491,9 +499,12 @@ fn parse_counted(&mut self) -> Result<(), Error> {
         let closer =
             match self.pos('}') {
                 Some(i) => i,
-                None => return self.err(format!(
-                    "No closing brace for counted repetition starting at \
-                     position {}.", start)),
+                None => {
+                    return self.err(format!("No closing brace for counted \
+                                             repetition starting at position \
+                                             {}.",
+                                            start).as_slice())
+                }
             };
         self.chari = closer;
         let greed = try!(self.get_next_greedy());
@@ -502,11 +513,11 @@ fn parse_counted(&mut self) -> Result<(), Error> {
 
         // Parse the min and max values from the regex.
         let (mut min, mut max): (uint, Option<uint>);
-        if !inner.contains(",") {
-            min = try!(self.parse_uint(inner));
+        if !inner.as_slice().contains(",") {
+            min = try!(self.parse_uint(inner.as_slice()));
             max = Some(min);
         } else {
-            let pieces: Vec<&str> = inner.splitn(',', 1).collect();
+            let pieces: Vec<&str> = inner.as_slice().splitn(',', 1).collect();
             let (smin, smax) = (*pieces.get(0), *pieces.get(1));
             if smin.len() == 0 {
                 return self.err("Max repetitions cannot be specified \
@@ -525,19 +536,19 @@ fn parse_counted(&mut self) -> Result<(), Error> {
         if min > MAX_REPEAT {
             return self.err(format!(
                 "{} exceeds maximum allowed repetitions ({})",
-                min, MAX_REPEAT));
+                min, MAX_REPEAT).as_slice());
         }
         if max.is_some() {
             let m = max.unwrap();
             if m > MAX_REPEAT {
                 return self.err(format!(
                     "{} exceeds maximum allowed repetitions ({})",
-                    m, MAX_REPEAT));
+                    m, MAX_REPEAT).as_slice());
             }
             if m < min {
                 return self.err(format!(
                     "Max repetitions ({}) cannot be smaller than min \
-                     repetitions ({}).", m, min));
+                     repetitions ({}).", m, min).as_slice());
             }
         }
 
@@ -600,7 +611,10 @@ fn parse_escape(&mut self) -> Result<Ast, Error> {
                 if c.is_uppercase() { flags |= FLAG_NEGATED }
                 Ok(Class(ranges, flags))
             }
-            _ => self.err(format!("Invalid escape sequence '\\\\{}'", c)),
+            _ => {
+                self.err(format!("Invalid escape sequence '\\\\{}'",
+                                 c).as_slice())
+            }
         }
     }
 
@@ -619,7 +633,7 @@ fn parse_unicode_name(&mut self) -> Result<Ast, Error> {
                     Some(i) => i,
                     None => return self.err(format!(
                         "Missing '\\}' for unclosed '\\{' at position {}",
-                        self.chari)),
+                        self.chari).as_slice()),
                 };
             if closer - self.chari + 1 == 0 {
                 return self.err("No Unicode class name found.")
@@ -634,8 +648,10 @@ fn parse_unicode_name(&mut self) -> Result<Ast, Error> {
             self.chari += 1;
         }
         match find_class(UNICODE_CLASSES, name.as_slice()) {
-            None => return self.err(format!(
-                "Could not find Unicode class '{}'", name)),
+            None => {
+                return self.err(format!("Could not find Unicode class '{}'",
+                                        name).as_slice())
+            }
             Some(ranges) => {
                 Ok(Class(ranges, negated | (self.flags & FLAG_NOCASE)))
             }
@@ -659,8 +675,10 @@ fn parse_octal(&mut self) -> Result<Ast, Error> {
         let s = self.slice(start, end);
         match num::from_str_radix::<u32>(s.as_slice(), 8) {
             Some(n) => Ok(Literal(try!(self.char_from_u32(n)), FLAG_EMPTY)),
-            None => self.err(format!(
-                "Could not parse '{}' as octal number.", s)),
+            None => {
+                self.err(format!("Could not parse '{}' as octal number.",
+                                 s).as_slice())
+            }
         }
     }
 
@@ -674,8 +692,11 @@ fn parse_hex(&mut self) -> Result<Ast, Error> {
         let start = self.chari + 2;
         let closer =
             match self.pos('}') {
-                None => return self.err(format!(
-                    "Missing '\\}' for unclosed '\\{' at position {}", start)),
+                None => {
+                    return self.err(format!("Missing '\\}' for unclosed \
+                                             '\\{' at position {}",
+                                            start).as_slice())
+                }
                 Some(i) => i,
             };
         self.chari = closer;
@@ -689,7 +710,8 @@ fn parse_hex(&mut self) -> Result<Ast, Error> {
     fn parse_hex_two(&mut self) -> Result<Ast, Error> {
         let (start, end) = (self.chari, self.chari + 2);
         let bad = self.slice(start - 2, self.chars.len());
-        try!(self.noteof(format!("Invalid hex escape sequence '{}'", bad)))
+        try!(self.noteof(format!("Invalid hex escape sequence '{}'",
+                                 bad).as_slice()))
         self.parse_hex_digits(self.slice(start, end).as_slice())
     }
 
@@ -697,8 +719,10 @@ fn parse_hex_two(&mut self) -> Result<Ast, Error> {
     fn parse_hex_digits(&self, s: &str) -> Result<Ast, Error> {
         match num::from_str_radix::<u32>(s, 16) {
             Some(n) => Ok(Literal(try!(self.char_from_u32(n)), FLAG_EMPTY)),
-            None => self.err(format!(
-                "Could not parse '{}' as hex number.", s)),
+            None => {
+                self.err(format!("Could not parse '{}' as hex number.",
+                                 s).as_slice())
+            }
         }
     }
 
@@ -722,7 +746,8 @@ fn parse_named_capture(&mut self) -> Result<(), Error> {
                 "Capture names can only have underscores, letters and digits.")
         }
         if self.names.contains(&name) {
-            return self.err(format!("Duplicate capture group name '{}'.", name))
+            return self.err(format!("Duplicate capture group name '{}'.",
+                                    name).as_slice())
         }
         self.names.push(name.clone());
         self.chari = closer;
@@ -754,7 +779,7 @@ fn parse_group_opts(&mut self) -> Result<(), Error> {
                     if sign < 0 {
                         return self.err(format!(
                             "Cannot negate flags twice in '{}'.",
-                            self.slice(start, self.chari + 1)))
+                            self.slice(start, self.chari + 1)).as_slice())
                     }
                     sign = -1;
                     saw_flag = false;
@@ -765,7 +790,7 @@ fn parse_group_opts(&mut self) -> Result<(), Error> {
                         if !saw_flag {
                             return self.err(format!(
                                 "A valid flag does not follow negation in '{}'",
-                                self.slice(start, self.chari + 1)))
+                                self.slice(start, self.chari + 1)).as_slice())
                         }
                         flags = flags ^ flags;
                     }
@@ -777,7 +802,7 @@ fn parse_group_opts(&mut self) -> Result<(), Error> {
                     return Ok(())
                 }
                 _ => return self.err(format!(
-                    "Unrecognized flag '{}'.", self.cur())),
+                    "Unrecognized flag '{}'.", self.cur()).as_slice()),
             }
         }
     }
@@ -871,16 +896,21 @@ fn build_from(&mut self, from: uint, mk: |Ast, Ast| -> Ast)
     fn parse_uint(&self, s: &str) -> Result<uint, Error> {
         match from_str::<uint>(s) {
             Some(i) => Ok(i),
-            None => self.err(format!(
-                "Expected an unsigned integer but got '{}'.", s)),
+            None => {
+                self.err(format!("Expected an unsigned integer but got '{}'.",
+                                 s).as_slice())
+            }
         }
     }
 
     fn char_from_u32(&self, n: u32) -> Result<char, Error> {
         match char::from_u32(n) {
             Some(c) => Ok(c),
-            None => self.err(format!(
-                "Could not decode '{}' to unicode character.", n)),
+            None => {
+                self.err(format!("Could not decode '{}' to unicode \
+                                  character.",
+                                 n).as_slice())
+            }
         }
     }
 
index 4c4ba8dd6bf93e133db10fa4b8208cd85cf5cbed..6fcbcbd265aa19aea069c3684c9b9a2600eb820d 100644 (file)
@@ -20,38 +20,40 @@ fn bench_assert_match(b: &mut Bencher, re: Regex, text: &str) {
 #[bench]
 fn no_exponential(b: &mut Bencher) {
     let n = 100;
-    let re = Regex::new("a?".repeat(n) + "a".repeat(n)).unwrap();
+    let re = Regex::new(format!("{}{}",
+                                "a?".repeat(n),
+                                "a".repeat(n)).as_slice()).unwrap();
     let text = "a".repeat(n);
-    bench_assert_match(b, re, text);
+    bench_assert_match(b, re, text.as_slice());
 }
 
 #[bench]
 fn literal(b: &mut Bencher) {
     let re = regex!("y");
-    let text = "x".repeat(50) + "y";
-    bench_assert_match(b, re, text);
+    let text = format!("{}y", "x".repeat(50));
+    bench_assert_match(b, re, text.as_slice());
 }
 
 #[bench]
 fn not_literal(b: &mut Bencher) {
     let re = regex!(".y");
-    let text = "x".repeat(50) + "y";
-    bench_assert_match(b, re, text);
+    let text = format!("{}y", "x".repeat(50));
+    bench_assert_match(b, re, text.as_slice());
 }
 
 #[bench]
 fn match_class(b: &mut Bencher) {
     let re = regex!("[abcdw]");
-    let text = "xxxx".repeat(20) + "w";
-    bench_assert_match(b, re, text);
+    let text = format!("{}w", "xxxx".repeat(20));
+    bench_assert_match(b, re, text.as_slice());
 }
 
 #[bench]
 fn match_class_in_range(b: &mut Bencher) {
     // 'b' is between 'a' and 'c', so the class range checking doesn't help.
     let re = regex!("[ac]");
-    let text = "bbbb".repeat(20) + "c";
-    bench_assert_match(b, re, text);
+    let text = format!("{}c", "bbbb".repeat(20));
+    bench_assert_match(b, re, text.as_slice());
 }
 
 #[bench]
@@ -75,7 +77,7 @@ fn anchored_literal_short_non_match(b: &mut Bencher) {
 fn anchored_literal_long_non_match(b: &mut Bencher) {
     let re = regex!("^zbc(d|e)");
     let text = "abcdefghijklmnopqrstuvwxyz".repeat(15);
-    b.iter(|| re.is_match(text));
+    b.iter(|| re.is_match(text.as_slice()));
 }
 
 #[bench]
@@ -89,7 +91,7 @@ fn anchored_literal_short_match(b: &mut Bencher) {
 fn anchored_literal_long_match(b: &mut Bencher) {
     let re = regex!("^.bc(d|e)");
     let text = "abcdefghijklmnopqrstuvwxyz".repeat(15);
-    b.iter(|| re.is_match(text));
+    b.iter(|| re.is_match(text.as_slice()));
 }
 
 #[bench]
index b85a1592eff02ae439fb1895b3909f068e5767c8..68320e8edd301e6ddb757c03f82df4118688330f 100644 (file)
@@ -82,10 +82,10 @@ fn native(cx: &mut ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree])
         // error is logged in 'parse' with cx.span_err
         None => return DummyResult::any(sp),
     };
-    let re = match Regex::new(regex.to_owned()) {
+    let re = match Regex::new(regex.as_slice()) {
         Ok(re) => re,
         Err(err) => {
-            cx.span_err(sp, err.to_str());
+            cx.span_err(sp, err.to_str().as_slice());
             return DummyResult::any(sp)
         }
     };
@@ -612,7 +612,7 @@ fn parse(cx: &mut ExtCtxt, tts: &[ast::TokenTree]) -> Option<StrBuf> {
                 _ => {
                     cx.span_err(entry.span, format!(
                         "expected string literal but got `{}`",
-                        pprust::lit_to_str(lit)));
+                        pprust::lit_to_str(lit)).as_slice());
                     return None
                 }
             }
@@ -620,7 +620,7 @@ fn parse(cx: &mut ExtCtxt, tts: &[ast::TokenTree]) -> Option<StrBuf> {
         _ => {
             cx.span_err(entry.span, format!(
                 "expected string literal but got `{}`",
-                pprust::expr_to_str(entry)));
+                pprust::expr_to_str(entry)).as_slice());
             return None
         }
     };
index 571959d812a45c5210d2b39c2d153c757cf1db39..ba3796211f259cdd29bf0f7f093bab23ebe1312b 100644 (file)
@@ -56,17 +56,24 @@ fn run_ar(sess: &Session, args: &str, cwd: Option<&Path>,
         Ok(prog) => {
             let o = prog.wait_with_output().unwrap();
             if !o.status.success() {
-                sess.err(format!("{} failed with: {}", cmd, o.status));
+                sess.err(format!("{} failed with: {}",
+                                 cmd,
+                                 o.status).as_slice());
                 sess.note(format!("stdout ---\n{}",
-                                  str::from_utf8(o.output.as_slice()).unwrap()));
+                                  str::from_utf8(o.output
+                                                  .as_slice()).unwrap())
+                          .as_slice());
                 sess.note(format!("stderr ---\n{}",
-                                  str::from_utf8(o.error.as_slice()).unwrap()));
+                                  str::from_utf8(o.error
+                                                  .as_slice()).unwrap())
+                          .as_slice());
                 sess.abort_if_errors();
             }
             o
         },
         Err(e) => {
-            sess.err(format!("could not exec `{}`: {}", ar.as_slice(), e));
+            sess.err(format!("could not exec `{}`: {}", ar.as_slice(),
+                             e).as_slice());
             sess.abort_if_errors();
             fail!("rustc::back::archive::run_ar() should not reach this point");
         }
@@ -158,7 +165,7 @@ fn add_archive(&mut self, archive: &Path, name: &str,
             if skip.iter().any(|s| *s == filename) { continue }
             if filename.contains(".SYMDEF") { continue }
 
-            let filename = format!("r-{}-{}", name, filename);
+            let filename = format_strbuf!("r-{}-{}", name, filename);
             let new_filename = file.with_filename(filename);
             try!(fs::rename(file, &new_filename));
             inputs.push(new_filename);
@@ -178,8 +185,8 @@ fn find_library(&self, name: &str) -> Path {
         };
         // On Windows, static libraries sometimes show up as libfoo.a and other
         // times show up as foo.lib
-        let oslibname = format!("{}{}.{}", osprefix, name, osext);
-        let unixlibname = format!("lib{}.a", name);
+        let oslibname = format_strbuf!("{}{}.{}", osprefix, name, osext);
+        let unixlibname = format_strbuf!("lib{}.a", name);
 
         let mut rustpath = filesearch::rust_path();
         rustpath.push(self.sess.target_filesearch().get_lib_path());
@@ -194,7 +201,8 @@ fn find_library(&self, name: &str) -> Path {
             }
         }
         self.sess.fatal(format!("could not find native static library `{}`, \
-                                 perhaps an -L flag is missing?", name));
+                                 perhaps an -L flag is missing?",
+                                name).as_slice());
     }
 }
 
index 429a8f5be5eb5f54604b862465c7e1fe82e952d1..57f3824ecc560819bde056d1db54baf735092899 100644 (file)
@@ -62,7 +62,9 @@ pub fn llvm_err(sess: &Session, msg: StrBuf) -> ! {
         } else {
             let err = CString::new(cstr, true);
             let err = str::from_utf8_lossy(err.as_bytes());
-            sess.fatal((msg.as_slice() + ": " + err.as_slice()));
+            sess.fatal(format!("{}: {}",
+                               msg.as_slice(),
+                               err.as_slice()).as_slice());
         }
     }
 }
@@ -167,7 +169,9 @@ pub fn run_passes(sess: &Session,
                 "dynamic-no-pic" => lib::llvm::RelocDynamicNoPic,
                 _ => {
                     sess.err(format!("{} is not a valid relocation mode",
-                             sess.opts.cg.relocation_model));
+                                     sess.opts
+                                         .cg
+                                         .relocation_model).as_slice());
                     sess.abort_if_errors();
                     return;
                 }
@@ -219,7 +223,8 @@ pub fn run_passes(sess: &Session,
             for pass in sess.opts.cg.passes.iter() {
                 pass.as_slice().with_c_str(|s| {
                     if !llvm::LLVMRustAddPass(mpm, s) {
-                        sess.warn(format!("unknown pass {}, ignoring", *pass));
+                        sess.warn(format!("unknown pass {}, ignoring",
+                                          *pass).as_slice());
                     }
                 })
             }
@@ -360,16 +365,21 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
         match cmd.output() {
             Ok(prog) => {
                 if !prog.status.success() {
-                    sess.err(format!("linking with `{}` failed: {}", pname, prog.status));
-                    sess.note(format!("{}", &cmd));
+                    sess.err(format!("linking with `{}` failed: {}",
+                                     pname,
+                                     prog.status).as_slice());
+                    sess.note(format!("{}", &cmd).as_slice());
                     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.note(str::from_utf8(note.as_slice()).unwrap()
+                                                             .as_slice());
                     sess.abort_if_errors();
                 }
             },
             Err(e) => {
-                sess.err(format!("could not exec the linker `{}`: {}", pname, e));
+                sess.err(format!("could not exec the linker `{}`: {}",
+                                 pname,
+                                 e).as_slice());
                 sess.abort_if_errors();
             }
         }
@@ -531,8 +541,8 @@ pub fn find_crate_id(attrs: &[ast::Attribute], out_filestem: &str) -> CrateId {
     match attr::find_crateid(attrs) {
         None => from_str(out_filestem).unwrap_or_else(|| {
             let mut s = out_filestem.chars().filter(|c| c.is_XID_continue());
-            from_str(s.collect::<StrBuf>()
-                      .to_owned()).or(from_str("rust-out")).unwrap()
+            from_str(s.collect::<StrBuf>().as_slice())
+                .or(from_str("rust-out")).unwrap()
         }),
         Some(s) => s,
     }
@@ -639,7 +649,7 @@ pub fn sanitize(s: &str) -> StrBuf {
     if result.len() > 0u &&
         result.as_slice()[0] != '_' as u8 &&
         ! char::is_XID_start(result.as_slice()[0] as char) {
-        return ("_" + result.as_slice()).to_strbuf();
+        return format!("_{}", result.as_slice()).to_strbuf();
     }
 
     return result;
@@ -666,7 +676,7 @@ pub fn mangle<PI: Iterator<PathElem>>(mut path: PI,
 
     fn push(n: &mut StrBuf, s: &str) {
         let sani = sanitize(s);
-        n.push_str(format!("{}{}", sani.len(), sani));
+        n.push_str(format!("{}{}", sani.len(), sani).as_slice());
     }
 
     // First, connect each component with <len, name> pairs.
@@ -691,7 +701,7 @@ pub fn exported_name(path: PathElems, hash: &str, vers: &str) -> StrBuf {
     // The version will get mangled to have a leading '_', but it makes more
     // sense to lead with a 'v' b/c this is a version...
     let vers = if vers.len() > 0 && !char::is_XID_start(vers.char_at(0)) {
-        "v" + vers
+        format!("v{}", vers)
     } else {
         vers.to_owned()
     };
@@ -774,7 +784,9 @@ fn remove(sess: &Session, path: &Path) {
     match fs::unlink(path) {
         Ok(..) => {}
         Err(e) => {
-            sess.err(format!("failed to remove {}: {}", path.display(), e));
+            sess.err(format!("failed to remove {}: {}",
+                             path.display(),
+                             e).as_slice());
         }
     }
 }
@@ -815,7 +827,7 @@ pub fn filename_for_input(sess: &Session, crate_type: config::CrateType,
     let libname = output_lib_filename(id);
     match crate_type {
         config::CrateTypeRlib => {
-            out_filename.with_filename(format!("lib{}.rlib", libname))
+            out_filename.with_filename(format_strbuf!("lib{}.rlib", libname))
         }
         config::CrateTypeDylib => {
             let (prefix, suffix) = match sess.targ_cfg.os {
@@ -825,10 +837,13 @@ pub fn filename_for_input(sess: &Session, crate_type: config::CrateType,
                 abi::OsAndroid => (loader::ANDROID_DLL_PREFIX, loader::ANDROID_DLL_SUFFIX),
                 abi::OsFreebsd => (loader::FREEBSD_DLL_PREFIX, loader::FREEBSD_DLL_SUFFIX),
             };
-            out_filename.with_filename(format!("{}{}{}", prefix, libname, suffix))
+            out_filename.with_filename(format_strbuf!("{}{}{}",
+                                                      prefix,
+                                                      libname,
+                                                      suffix))
         }
         config::CrateTypeStaticlib => {
-            out_filename.with_filename(format!("lib{}.a", libname))
+            out_filename.with_filename(format_strbuf!("lib{}.a", libname))
         }
         config::CrateTypeExecutable => out_filename.clone(),
     }
@@ -855,12 +870,14 @@ fn link_binary_output(sess: &Session,
     let obj_is_writeable = is_writeable(&obj_filename);
     let out_is_writeable = is_writeable(&out_filename);
     if !out_is_writeable {
-        sess.fatal(format!("output file {} is not writeable -- check its permissions.",
-                           out_filename.display()));
+        sess.fatal(format!("output file {} is not writeable -- check its \
+                            permissions.",
+                           out_filename.display()).as_slice());
     }
     else if !obj_is_writeable {
-        sess.fatal(format!("object file {} is not writeable -- check its permissions.",
-                           obj_filename.display()));
+        sess.fatal(format!("object file {} is not writeable -- check its \
+                            permissions.",
+                           obj_filename.display()).as_slice());
     }
 
     match crate_type {
@@ -936,7 +953,8 @@ fn link_rlib<'a>(sess: &'a Session,
                 Ok(..) => {}
                 Err(e) => {
                     sess.err(format!("failed to write {}: {}",
-                                     metadata.display(), e));
+                                     metadata.display(),
+                                     e).as_slice());
                     sess.abort_if_errors();
                 }
             }
@@ -956,7 +974,9 @@ fn link_rlib<'a>(sess: &'a Session,
             }) {
                 Ok(()) => {}
                 Err(e) => {
-                    sess.err(format!("failed to write compressed bytecode: {}", e));
+                    sess.err(format!("failed to write compressed bytecode: \
+                                      {}",
+                                     e).as_slice());
                     sess.abort_if_errors()
                 }
             }
@@ -1003,7 +1023,8 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
         let name = sess.cstore.get_crate_data(cnum).name.clone();
         let p = match *path {
             Some(ref p) => p.clone(), None => {
-                sess.err(format!("could not find rlib for: `{}`", name));
+                sess.err(format!("could not find rlib for: `{}`",
+                                 name).as_slice());
                 continue
             }
         };
@@ -1015,7 +1036,9 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
                 cstore::NativeUnknown => "library",
                 cstore::NativeFramework => "framework",
             };
-            sess.warn(format!("unlinked native {}: {}", name, *lib));
+            sess.warn(format!("unlinked native {}: {}",
+                              name,
+                              *lib).as_slice());
         }
     }
 }
@@ -1049,16 +1072,21 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
     match prog {
         Ok(prog) => {
             if !prog.status.success() {
-                sess.err(format!("linking with `{}` failed: {}", pname, prog.status));
-                sess.note(format!("{}", &cmd));
+                sess.err(format!("linking with `{}` failed: {}",
+                                 pname,
+                                 prog.status).as_slice());
+                sess.note(format!("{}", &cmd).as_slice());
                 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.note(str::from_utf8(output.as_slice()).unwrap()
+                                                           .as_slice());
                 sess.abort_if_errors();
             }
         },
         Err(e) => {
-            sess.err(format!("could not exec the linker `{}`: {}", pname, e));
+            sess.err(format!("could not exec the linker `{}`: {}",
+                             pname,
+                             e).as_slice());
             sess.abort_if_errors();
         }
     }
@@ -1070,7 +1098,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
         match Command::new("dsymutil").arg(out_filename).status() {
             Ok(..) => {}
             Err(e) => {
-                sess.err(format!("failed to run dsymutil: {}", e));
+                sess.err(format!("failed to run dsymutil: {}", e).as_slice());
                 sess.abort_if_errors();
             }
         }
@@ -1409,7 +1437,8 @@ fn add_static_crate(cmd: &mut Command, sess: &Session, tmpdir: &Path,
         // against the archive.
         if sess.lto() {
             let name = sess.cstore.get_crate_data(cnum).name.clone();
-            time(sess.time_passes(), format!("altering {}.rlib", name),
+            time(sess.time_passes(),
+                 format!("altering {}.rlib", name).as_slice(),
                  (), |()| {
                 let dst = tmpdir.join(cratepath.filename().unwrap());
                 match fs::copy(&cratepath, &dst) {
@@ -1418,12 +1447,12 @@ fn add_static_crate(cmd: &mut Command, sess: &Session, tmpdir: &Path,
                         sess.err(format!("failed to copy {} to {}: {}",
                                          cratepath.display(),
                                          dst.display(),
-                                         e));
+                                         e).as_slice());
                         sess.abort_if_errors();
                     }
                 }
                 let mut archive = Archive::open(sess, dst.clone());
-                archive.remove_file(format!("{}.o", name));
+                archive.remove_file(format!("{}.o", name).as_slice());
                 let files = archive.files();
                 if files.iter().any(|s| s.as_slice().ends_with(".o")) {
                     cmd.arg(dst);
index 74ac972e5c4b2c05ebac6b6fa1b43c9acc3ad843..9f12b9d58951c9a23b522e36fccedf7b32af01e0 100644 (file)
@@ -47,29 +47,46 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
         let path = match path {
             Some(p) => p,
             None => {
-                sess.fatal(format!("could not find rlib for: `{}`", name));
+                sess.fatal(format!("could not find rlib for: `{}`",
+                                   name).as_slice());
             }
         };
 
         let archive = ArchiveRO::open(&path).expect("wanted an rlib");
         debug!("reading {}", name);
-        let bc = time(sess.time_passes(), format!("read {}.bc.deflate", name), (), |_|
-                      archive.read(format!("{}.bc.deflate", name)));
+        let bc = time(sess.time_passes(),
+                      format!("read {}.bc.deflate", name).as_slice(),
+                      (),
+                      |_| {
+                          archive.read(format!("{}.bc.deflate",
+                                               name).as_slice())
+                      });
         let bc = bc.expect("missing compressed bytecode in archive!");
-        let bc = time(sess.time_passes(), format!("inflate {}.bc", name), (), |_|
-                      match flate::inflate_bytes(bc) {
-                          Some(bc) => bc,
-                          None => sess.fatal(format!("failed to decompress bc of `{}`", name))
+        let bc = time(sess.time_passes(),
+                      format!("inflate {}.bc", name).as_slice(),
+                      (),
+                      |_| {
+                          match flate::inflate_bytes(bc) {
+                              Some(bc) => bc,
+                              None => {
+                                  sess.fatal(format!("failed to decompress \
+                                                      bc of `{}`",
+                                                     name).as_slice())
+                              }
+                          }
                       });
         let ptr = bc.as_slice().as_ptr();
         debug!("linking {}", name);
-        time(sess.time_passes(), format!("ll link {}", name), (), |()| unsafe {
+        time(sess.time_passes(),
+             format!("ll link {}", name).as_slice(),
+             (),
+             |()| unsafe {
             if !llvm::LLVMRustLinkInExternalBitcode(llmod,
                                                     ptr as *libc::c_char,
                                                     bc.len() as libc::size_t) {
                 link::llvm_err(sess,
-                               (format_strbuf!("failed to load bc of `{}`",
-                                               name)));
+                               format_strbuf!("failed to load bc of `{}`",
+                                               name.as_slice()));
             }
         });
     }
index 8557cfc0bc2bbaa2db2520d0339476e91993f3ee..8258fb5762be395becdf07b2749ee5b66a798e87 100644 (file)
@@ -59,7 +59,7 @@ pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<StrBuf> {
 pub fn rpaths_to_flags(rpaths: &[StrBuf]) -> Vec<StrBuf> {
     let mut ret = Vec::new();
     for rpath in rpaths.iter() {
-        ret.push(("-Wl,-rpath," + (*rpath).as_slice()).to_strbuf());
+        ret.push(format!("-Wl,-rpath,{}", (*rpath).as_slice()));
     }
     return ret;
 }
@@ -132,8 +132,9 @@ pub fn get_rpath_relative_to_output(os: abi::Os,
     let relative = lib.path_relative_from(&output);
     let relative = relative.expect("could not create rpath relative to output");
     // FIXME (#9639): This needs to handle non-utf8 paths
-    (prefix + "/" + relative.as_str()
-                            .expect("non-utf8 component in path")).to_strbuf()
+    format!("{}/{}",
+            prefix,
+            relative.as_str().expect("non-utf8 component in path"))
 }
 
 pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> StrBuf {
index 4cf33a777ad78c556cd1355704612a9af5317fb8..d80cf72bb466d8c4f89cc76747c2aa69df2a97d5 100644 (file)
@@ -328,18 +328,23 @@ pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
             if option_to_lookup.as_slice() != candidate { continue }
             if !setter(&mut cg, value) {
                 match value {
-                    Some(..) => early_error(format!("codegen option `{}` takes \
-                                                     no value", key)),
-                    None => early_error(format!("codegen option `{0}` requires \
-                                                 a value (-C {0}=<value>)",
-                                                key))
+                    Some(..) => {
+                        early_error(format!("codegen option `{}` takes no \
+                                             value", key).as_slice())
+                    }
+                    None => {
+                        early_error(format!("codegen option `{0}` requires \
+                                             a value (-C {0}=<value>)",
+                                            key).as_slice())
+                    }
                 }
             }
             found = true;
             break;
         }
         if !found {
-            early_error(format!("unknown codegen option: `{}`", key));
+            early_error(format!("unknown codegen option: `{}`",
+                                key).as_slice());
         }
     }
     return cg;
@@ -464,8 +469,8 @@ pub fn build_target_config(sopts: &Options) -> Config {
     let arch = match get_arch(sopts.target_triple.as_slice()) {
       Some(arch) => arch,
       None => {
-          early_error("unknown architecture: " +
-                      sopts.target_triple.as_slice())
+          early_error(format!("unknown architecture: {}",
+                              sopts.target_triple.as_slice()).as_slice())
       }
     };
     let (int_type, uint_type) = match arch {
@@ -570,7 +575,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                 "staticlib" => CrateTypeStaticlib,
                 "dylib"     => CrateTypeDylib,
                 "bin"       => CrateTypeExecutable,
-                _ => early_error(format!("unknown crate type: `{}`", part))
+                _ => {
+                    early_error(format!("unknown crate type: `{}`",
+                                        part).as_slice())
+                }
             };
             crate_types.push(new_part)
         }
@@ -589,14 +597,17 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
 
         let level_short = level_name.slice_chars(0, 1);
         let level_short = level_short.to_ascii().to_upper().into_str();
-        let flags = matches.opt_strs(level_short).move_iter().collect::<Vec<_>>().append(
-                                   matches.opt_strs(level_name).as_slice());
+        let flags = matches.opt_strs(level_short.as_slice())
+                           .move_iter()
+                           .collect::<Vec<_>>()
+                           .append(matches.opt_strs(level_name).as_slice());
         for lint_name in flags.iter() {
-            let lint_name = lint_name.replace("-", "_");
+            let lint_name = lint_name.replace("-", "_").into_strbuf();
             match lint_dict.find_equiv(&lint_name) {
               None => {
                 early_error(format!("unknown {} flag: {}",
-                                    level_name, lint_name));
+                                    level_name,
+                                    lint_name).as_slice());
               }
               Some(lint) => {
                 lint_opts.push((lint.lint, *level));
@@ -618,7 +629,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             }
         }
         if this_bit == 0 {
-            early_error(format!("unknown debug flag: {}", *debug_flag))
+            early_error(format!("unknown debug flag: {}",
+                                *debug_flag).as_slice())
         }
         debugging_opts |= this_bit;
     }
@@ -638,7 +650,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                     "bc"   => link::OutputTypeBitcode,
                     "obj"  => link::OutputTypeObject,
                     "link" => link::OutputTypeExe,
-                    _ => early_error(format!("unknown emission type: `{}`", part))
+                    _ => {
+                        early_error(format!("unknown emission type: `{}`",
+                                            part).as_slice())
+                    }
                 };
                 output_types.push(output_type)
             }
@@ -671,8 +686,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                 Some("2") => Default,
                 Some("3") => Aggressive,
                 Some(arg) => {
-                    early_error(format!("optimization level needs to be between 0-3 \
-                                        (instead was `{}`)", arg));
+                    early_error(format!("optimization level needs to be \
+                                         between 0-3 (instead was `{}`)",
+                                        arg).as_slice());
                 }
             }
         } else {
@@ -692,8 +708,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             None      |
             Some("2") => FullDebugInfo,
             Some(arg) => {
-                early_error(format!("optimization level needs to be between 0-3 \
-                                    (instead was `{}`)", arg));
+                early_error(format!("optimization level needs to be between \
+                                     0-3 (instead was `{}`)",
+                                    arg).as_slice());
             }
         }
     } else {
@@ -725,9 +742,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
 
         None => Auto,
 
-        Some(arg) => early_error(format!(
-            "argument for --color must be auto, always or never (instead was `{}`)",
-            arg))
+        Some(arg) => {
+            early_error(format!("argument for --color must be auto, always \
+                                 or never (instead was `{}`)",
+                                arg).as_slice())
+        }
     };
 
     Options {
index f51735afaceac8b6a79e72b899ec56b8385e5613..4e682e8e34bb2d2848e27244741c5ce46dfa8c38 100644 (file)
@@ -511,7 +511,7 @@ fn write_out_deps(sess: &Session,
         Ok(()) => {}
         Err(e) => {
             sess.fatal(format!("error writing dependencies to `{}`: {}",
-                               deps_filename.display(), e));
+                               deps_filename.display(), e).as_slice());
         }
     }
 }
@@ -705,7 +705,8 @@ fn expand_err_details(r: io::IoResult<()>) -> io::IoResult<()> {
             let m = "graphviz::render failed";
             io::IoError {
                 detail: Some(match orig_detail {
-                    None => m.into_owned(), Some(d) => format!("{}: {}", m, d)
+                    None => m.into_strbuf(),
+                    Some(d) => format_strbuf!("{}: {}", m, d)
                 }),
                 ..ioerr
             }
index 06d62c82ce1f2a0e0c38940adddd0edb84fc085a..2fb730e4daeecd79e8457f95b6173e1fcaa04d3b 100644 (file)
@@ -120,7 +120,8 @@ fn usage() {
     -C help             Print codegen options
     -W help             Print 'lint' options and default settings
     -Z help             Print internal options for debugging rustc\n",
-              getopts::usage(message, config::optgroups().as_slice()));
+              getopts::usage(message.as_slice(),
+                             config::optgroups().as_slice()));
 }
 
 fn describe_warnings() {
@@ -142,8 +143,8 @@ fn describe_warnings() {
     for &(_, name) in lint_dict.iter() {
         max_key = cmp::max(name.len(), max_key);
     }
-    fn padded(max: uint, s: &str) -> ~str {
-        " ".repeat(max - s.len()) + s
+    fn padded(max: uint, s: &str) -> StrBuf {
+        format!("{}{}", " ".repeat(max - s.len()), s)
     }
     println!("\nAvailable lint checks:\n");
     println!("    {}  {:7.7s}  {}",
@@ -153,7 +154,7 @@ fn padded(max: uint, s: &str) -> ~str {
     for (spec, name) in lint_dict.move_iter() {
         let name = name.replace("_", "-");
         println!("    {}  {:7.7s}  {}",
-                 padded(max_key, name),
+                 padded(max_key, name.as_slice()),
                  lint::level_to_str(spec.default),
                  spec.desc);
     }
@@ -305,16 +306,18 @@ pub fn parse_pretty(sess: &Session, name: &str) -> PpMode {
         (arg, "flowgraph") => {
              match arg.and_then(from_str) {
                  Some(id) => PpmFlowGraph(id),
-                 None => sess.fatal(format_strbuf!("`pretty flowgraph=<nodeid>` needs \
-                                                     an integer <nodeid>; got {}",
-                                                   arg.unwrap_or("nothing")).as_slice())
+                 None => {
+                     sess.fatal(format!("`pretty flowgraph=<nodeid>` needs \
+                                         an integer <nodeid>; got {}",
+                                        arg.unwrap_or("nothing")).as_slice())
+                 }
              }
         }
         _ => {
             sess.fatal(format!(
                 "argument to `pretty` must be one of `normal`, \
                  `expanded`, `flowgraph=<nodeid>`, `typed`, `identified`, \
-                 or `expanded,identified`; got {}", name));
+                 or `expanded,identified`; got {}", name).as_slice());
         }
     }
 }
@@ -397,18 +400,23 @@ fn monitor(f: proc():Send) {
 
                 let xs = [
                     "the compiler hit an unexpected failure path. this is a bug.".to_owned(),
-                    "we would appreciate a bug report: " + BUG_REPORT_URL,
+                    format!("we would appreciate a bug report: {}",
+                            BUG_REPORT_URL),
                     "run with `RUST_BACKTRACE=1` for a backtrace".to_owned(),
                 ];
                 for note in xs.iter() {
-                    emitter.emit(None, *note, diagnostic::Note)
+                    emitter.emit(None, note.as_slice(), diagnostic::Note)
                 }
 
                 match r.read_to_str() {
                     Ok(s) => println!("{}", s),
-                    Err(e) => emitter.emit(None,
-                                           format!("failed to read internal stderr: {}", e),
-                                           diagnostic::Error),
+                    Err(e) => {
+                        emitter.emit(None,
+                                     format!("failed to read internal \
+                                              stderr: {}",
+                                             e).as_slice(),
+                                     diagnostic::Error)
+                    }
                 }
             }
 
index e450fd200a6ae19598720d1d67bd759605efa9e7..19cc3a75e052b3ca69106e140e4719313ec1f3ef 100644 (file)
@@ -141,7 +141,8 @@ pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
     // This exists to help with refactoring to eliminate impossible
     // cases later on
     pub fn impossible_case(&self, sp: Span, msg: &str) -> ! {
-        self.span_bug(sp, format!("impossible case reached: {}", msg));
+        self.span_bug(sp,
+                      format!("impossible case reached: {}", msg).as_slice());
     }
     pub fn verbose(&self) -> bool { self.debugging_opt(config::VERBOSE) }
     pub fn time_passes(&self) -> bool { self.debugging_opt(config::TIME_PASSES) }
index b6022f5675926edbad249800eeeb141e840588e7..21a7fc8d15044f5bc72a36b5c1d0f9ef7574188c 100644 (file)
@@ -109,7 +109,7 @@ fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
             self.sess.span_err(span, explain);
             self.sess.span_note(span, format!("add \\#![feature({})] to the \
                                                   crate attributes to enable",
-                                                 feature));
+                                                 feature).as_slice());
         }
     }
 
@@ -259,7 +259,9 @@ fn visit_mac(&mut self, macro: &ast::Mac, _: ()) {
         else {
             for &quote in quotes.iter() {
                 if id == token::str_to_ident(quote) {
-                  self.gate_feature("quote", path.span, quote + msg);
+                  self.gate_feature("quote",
+                                    path.span,
+                                    format!("{}{}", quote, msg).as_slice());
                 }
             }
         }
index 92bd81a40f2460017a1807becff4424a6a469235..efaeeaa557510074e3f07315815f43f43852651f 100644 (file)
@@ -65,7 +65,7 @@ pub fn with_version(krate: &str) -> Option<(InternedString, ast::StrStyle)> {
         _ => {
             Some((token::intern_and_get_ident(format!("{}\\#{}",
                                                       krate,
-                                                      VERSION)),
+                                                      VERSION).as_slice()),
                   ast::CookedStr))
         }
     }
index 0ebd392e582fd9d7da939dba410247552480578a..e7a5aeb9ef5aa00a25ed63fe6c59bd2efae7c6a3 100644 (file)
@@ -327,7 +327,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
         pub fn main() {
             #![main]
             use std::slice::Vector;
-            test::test_main_static_x(::std::os::args().as_slice(), TESTS);
+            test::test_main_static(::std::os::args().as_slice(), TESTS);
         }
     )).unwrap();
 
index 5ed8da8a82b04970602ac1c238fc4fa5183b8079..06a043b172fa78f518432611fe1b61f6d3686548 100644 (file)
@@ -91,7 +91,8 @@ fn warn_if_multiple_versions(diag: &SpanHandler, cstore: &CStore) {
     for ((name, _), dupes) in map.move_iter() {
         if dupes.len() == 1 { continue }
         diag.handler().warn(
-            format!("using multiple versions of crate `{}`", name));
+            format!("using multiple versions of crate `{}`",
+                    name).as_slice());
         for dupe in dupes.move_iter() {
             let data = cstore.get_crate_data(dupe);
             diag.span_note(data.span, "used here");
@@ -161,7 +162,7 @@ fn extract_crate_info(e: &Env, i: &ast::ViewItem) -> Option<CrateInfo> {
                         Some(id) => id
                     }
                 }
-                None => from_str(ident.get().to_str()).unwrap()
+                None => from_str(ident.get().to_str().as_slice()).unwrap()
             };
             Some(CrateInfo {
                 ident: ident.get().to_strbuf(),
@@ -224,7 +225,8 @@ fn visit_item(e: &Env, i: &ast::Item) {
                                     cstore::NativeUnknown
                                 } else {
                                     e.sess.span_err(m.span,
-                                        format!("unknown kind: `{}`", k));
+                                        format!("unknown kind: `{}`",
+                                                k).as_slice());
                                     cstore::NativeUnknown
                                 }
                             }
@@ -243,7 +245,9 @@ fn visit_item(e: &Env, i: &ast::Item) {
                             }
                         };
                         if n.get().is_empty() {
-                            e.sess.span_err(m.span, "#[link(name = \"\")] given with empty name");
+                            e.sess.span_err(m.span,
+                                            "#[link(name = \"\")] given with \
+                                             empty name");
                         } else {
                             e.sess
                              .cstore
@@ -425,7 +429,7 @@ fn load_crate(&mut self, krate: &ast::ViewItem) -> MacroCrate {
                     let message = format!("crate `{}` contains a macro_registrar fn but \
                                   only a version for triple `{}` could be found (need {})",
                                   info.ident, target_triple, driver::host_triple());
-                    self.env.sess.span_err(krate.span, message);
+                    self.env.sess.span_err(krate.span, message.as_slice());
                     // need to abort now because the syntax expansion
                     // code will shortly attempt to load and execute
                     // code from the found library.
index 2e478419e77a92508994de825fd580f8de5faede..a0742669cc07e9a38be051ada15aa4d1865df2b0 100644 (file)
@@ -248,7 +248,7 @@ fn encode_symbol(ecx: &EncodeContext,
         }
         None => {
             ecx.diag.handler().bug(
-                format!("encode_symbol: id not found {}", id));
+                format!("encode_symbol: id not found {}", id).as_slice());
         }
     }
     ebml_w.end_tag();
@@ -375,7 +375,7 @@ fn encode_reexported_static_method(ebml_w: &mut Encoder,
     ebml_w.start_tag(tag_items_data_item_reexport_name);
     ebml_w.wr_str(format!("{}::{}",
                           exp.name,
-                          token::get_ident(method_ident)));
+                          token::get_ident(method_ident)).as_slice());
     ebml_w.end_tag();
     ebml_w.end_tag();
 }
@@ -602,7 +602,7 @@ fn encode_visibility(ebml_w: &mut Encoder, visibility: Visibility) {
         Public => 'y',
         Inherited => 'i',
     };
-    ebml_w.wr_str(str::from_char(ch));
+    ebml_w.wr_str(str::from_char(ch).as_slice());
     ebml_w.end_tag();
 }
 
@@ -848,7 +848,7 @@ fn encode_sized(ebml_w: &mut Encoder, sized: Sized) {
         DynSize => 'd',
         StaticSize => 's',
     };
-    ebml_w.wr_str(str::from_char(ch));
+    ebml_w.wr_str(str::from_char(ch).as_slice());
     ebml_w.end_tag();
 }
 
@@ -1439,7 +1439,10 @@ fn synthesize_crateid_attr(ecx: &EncodeContext) -> Attribute {
         attr::mk_attr_inner(
             attr::mk_name_value_item_str(
                 InternedString::new("crate_id"),
-                token::intern_and_get_ident(ecx.link_meta.crateid.to_str())))
+                token::intern_and_get_ident(ecx.link_meta
+                                               .crateid
+                                               .to_str()
+                                               .as_slice())))
     }
 
     let mut attrs = Vec::new();
@@ -1882,5 +1885,5 @@ pub fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> StrBuf {
         tcx: tcx,
         abbrevs: &RefCell::new(HashMap::new())
     }, t);
-    str::from_utf8_owned(wr.get_ref().to_owned()).unwrap().to_strbuf()
+    str::from_utf8_owned(Vec::from_slice(wr.get_ref())).unwrap().to_strbuf()
 }
index 456259d1a5d0440131ee70a0b9de4a0acc8ba845..9a63aad893f5f22a82282f8a83fa3d8d015010fe 100644 (file)
@@ -137,15 +137,17 @@ pub fn report_load_errs(&mut self) {
             &Some(ref r) => format!("{} which `{}` depends on",
                                     message, r.ident)
         };
-        self.sess.span_err(self.span, message);
+        self.sess.span_err(self.span, message.as_slice());
 
         let mismatches = self.rejected_via_triple.iter();
         if self.rejected_via_triple.len() > 0 {
-            self.sess.span_note(self.span, format!("expected triple of {}", self.triple));
+            self.sess.span_note(self.span,
+                                format!("expected triple of {}",
+                                        self.triple).as_slice());
             for (i, &CrateMismatch{ ref path, ref got }) in mismatches.enumerate() {
                 self.sess.fileline_note(self.span,
                     format!("crate `{}` path \\#{}, triple {}: {}",
-                            self.ident, i+1, got, path.display()));
+                            self.ident, i+1, got, path.display()).as_slice());
             }
         }
         if self.rejected_via_hash.len() > 0 {
@@ -155,7 +157,7 @@ pub fn report_load_errs(&mut self) {
             for (i, &CrateMismatch{ ref path, .. }) in mismatches.enumerate() {
                 self.sess.fileline_note(self.span,
                     format!("crate `{}` path \\#{}: {}",
-                            self.ident, i+1, path.display()));
+                            self.ident, i+1, path.display()).as_slice());
             }
             match self.root {
                 &None => {}
@@ -163,7 +165,7 @@ pub fn report_load_errs(&mut self) {
                     for (i, path) in r.paths().iter().enumerate() {
                         self.sess.fileline_note(self.span,
                             format!("crate `{}` path \\#{}: {}",
-                                    r.ident, i+1, path.display()));
+                                    r.ident, i+1, path.display()).as_slice());
                     }
                 }
             }
@@ -198,9 +200,10 @@ fn find_library_crate(&mut self) -> Option<Library> {
                 None => return FileDoesntMatch,
                 Some(file) => file,
             };
-            if file.starts_with(rlib_prefix) && file.ends_with(".rlib") {
+            if file.starts_with(rlib_prefix.as_slice()) &&
+                    file.ends_with(".rlib") {
                 info!("rlib candidate: {}", path.display());
-                match self.try_match(file, rlib_prefix, ".rlib") {
+                match self.try_match(file, rlib_prefix.as_slice(), ".rlib") {
                     Some(hash) => {
                         info!("rlib accepted, hash: {}", hash);
                         let slot = candidates.find_or_insert_with(hash, |_| {
@@ -215,9 +218,12 @@ fn find_library_crate(&mut self) -> Option<Library> {
                         FileDoesntMatch
                     }
                 }
-            } else if file.starts_with(dylib_prefix) && file.ends_with(dysuffix){
+            } else if file.starts_with(dylib_prefix.as_slice()) &&
+                    file.ends_with(dysuffix){
                 info!("dylib candidate: {}", path.display());
-                match self.try_match(file, dylib_prefix, dysuffix) {
+                match self.try_match(file,
+                                     dylib_prefix.as_slice(),
+                                     dysuffix) {
                     Some(hash) => {
                         info!("dylib accepted, hash: {}", hash);
                         let slot = candidates.find_or_insert_with(hash, |_| {
@@ -271,18 +277,20 @@ fn find_library_crate(&mut self) -> Option<Library> {
             _ => {
                 self.sess.span_err(self.span,
                     format!("multiple matching crates for `{}`",
-                            self.crate_id.name));
+                            self.crate_id.name).as_slice());
                 self.sess.note("candidates:");
                 for lib in libraries.iter() {
                     match lib.dylib {
                         Some(ref p) => {
-                            self.sess.note(format!("path: {}", p.display()));
+                            self.sess.note(format!("path: {}",
+                                                   p.display()).as_slice());
                         }
                         None => {}
                     }
                     match lib.rlib {
                         Some(ref p) => {
-                            self.sess.note(format!("path: {}", p.display()));
+                            self.sess.note(format!("path: {}",
+                                                   p.display()).as_slice());
                         }
                         None => {}
                     }
@@ -375,10 +383,13 @@ fn extract_one(&mut self, m: HashSet<Path>, flavor: &str,
             if ret.is_some() {
                 self.sess.span_err(self.span,
                                    format!("multiple {} candidates for `{}` \
-                                            found", flavor, self.crate_id.name));
+                                            found",
+                                           flavor,
+                                           self.crate_id.name).as_slice());
                 self.sess.span_note(self.span,
                                     format!(r"candidate \#1: {}",
-                                            ret.get_ref().display()));
+                                            ret.get_ref()
+                                               .display()).as_slice());
                 error = 1;
                 ret = None;
             }
@@ -386,7 +397,7 @@ fn extract_one(&mut self, m: HashSet<Path>, flavor: &str,
                 error += 1;
                 self.sess.span_note(self.span,
                                     format!(r"candidate \#{}: {}", error,
-                                            lib.display()));
+                                            lib.display()).as_slice());
                 continue
             }
             *slot = Some(metadata);
@@ -450,7 +461,7 @@ fn dylibname(&self) -> (&'static str, &'static str) {
 }
 
 pub fn note_crateid_attr(diag: &SpanHandler, crateid: &CrateId) {
-    diag.handler().note(format!("crate_id: {}", crateid.to_str()));
+    diag.handler().note(format!("crate_id: {}", crateid.to_str()).as_slice());
 }
 
 impl ArchiveMetadata {
@@ -541,7 +552,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, Str
             let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
             let name = str::raw::from_buf_len(name_buf as *u8, name_len as uint);
             debug!("get_metadata_section: name {}", name);
-            if read_meta_section_name(os) == name {
+            if read_meta_section_name(os).as_slice() == name.as_slice() {
                 let cbuf = llvm::LLVMGetSectionContents(si.llsi);
                 let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
                 let mut found =
index 0ccb44d2f8caed3c72e76d6f7677af915e7fc1a5..2cc6a9028dca17d1798b23425465c8f9474f271d 100644 (file)
@@ -155,7 +155,10 @@ fn parse_trait_store(st: &mut PState, conv: conv_did) -> ty::TraitStore {
     match next(st) {
         '~' => ty::UniqTraitStore,
         '&' => ty::RegionTraitStore(parse_region(st, conv), parse_mutability(st)),
-        c => st.tcx.sess.bug(format!("parse_trait_store(): bad input '{}'", c))
+        c => {
+            st.tcx.sess.bug(format!("parse_trait_store(): bad input '{}'",
+                                    c).as_slice())
+        }
     }
 }
 
@@ -449,7 +452,7 @@ fn parse_abi_set(st: &mut PState) -> abi::Abi {
     assert_eq!(next(st), '[');
     scan(st, |c| c == ']', |bytes| {
         let abi_str = str::from_utf8(bytes).unwrap().to_owned();
-        abi::lookup(abi_str).expect(abi_str)
+        abi::lookup(abi_str.as_slice()).expect(abi_str)
     })
 }
 
index f46fe9a8b249196f1aa4d8b1af8770059c54ae29..8956beb33f453d8f4cf51a25eb215848bc385d79 100644 (file)
@@ -1312,7 +1312,8 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
         match c::astencode_tag::from_uint(tag) {
             None => {
                 xcx.dcx.tcx.sess.bug(
-                    format!("unknown tag found in side tables: {:x}", tag));
+                    format!("unknown tag found in side tables: {:x}",
+                            tag).as_slice());
             }
             Some(value) => {
                 let val_doc = entry_doc.get(c::tag_table_val as uint);
@@ -1376,7 +1377,8 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
                     }
                     _ => {
                         xcx.dcx.tcx.sess.bug(
-                            format!("unknown tag found in side tables: {:x}", tag));
+                            format!("unknown tag found in side tables: {:x}",
+                                    tag).as_slice());
                     }
                 }
             }
index a24e7d6638066153322d6cc661ce54aa91b82c8f..65ecec2d2ed9f8ab467a8afdb22d40ac28d1eee9 100644 (file)
@@ -243,7 +243,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
             if restr.loan_path != loan2.loan_path { continue; }
 
             let old_pronoun = if new_loan.loan_path == old_loan.loan_path {
-                "it".to_owned()
+                "it".to_strbuf()
             } else {
                 format!("`{}`",
                         self.bccx.loan_path_to_str(&*old_loan.loan_path))
@@ -255,7 +255,8 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                         new_loan.span,
                         format!("cannot borrow `{}` as mutable \
                                 more than once at a time",
-                                self.bccx.loan_path_to_str(&*new_loan.loan_path)));
+                                self.bccx.loan_path_to_str(
+                                    &*new_loan.loan_path)).as_slice());
                 }
 
                 (ty::UniqueImmBorrow, _) => {
@@ -264,7 +265,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                         format!("closure requires unique access to `{}` \
                                 but {} is already borrowed",
                                 self.bccx.loan_path_to_str(&*new_loan.loan_path),
-                                old_pronoun));
+                                old_pronoun).as_slice());
                 }
 
                 (_, ty::UniqueImmBorrow) => {
@@ -273,7 +274,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                         format!("cannot borrow `{}` as {} because \
                                 previous closure requires unique access",
                                 self.bccx.loan_path_to_str(&*new_loan.loan_path),
-                                new_loan.kind.to_user_str()));
+                                new_loan.kind.to_user_str()).as_slice());
                 }
 
                 (_, _) => {
@@ -284,7 +285,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                                 self.bccx.loan_path_to_str(&*new_loan.loan_path),
                                 new_loan.kind.to_user_str(),
                                 old_pronoun,
-                                old_loan.kind.to_user_str()));
+                                old_loan.kind.to_user_str()).as_slice());
                 }
             }
 
@@ -293,7 +294,8 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                     self.bccx.span_note(
                         span,
                         format!("borrow occurs due to use of `{}` in closure",
-                                self.bccx.loan_path_to_str(&*new_loan.loan_path)));
+                                self.bccx.loan_path_to_str(
+                                    &*new_loan.loan_path)).as_slice());
                 }
                 _ => { }
             }
@@ -303,7 +305,8 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                     format!("the mutable borrow prevents subsequent \
                             moves, borrows, or modification of `{0}` \
                             until the borrow ends",
-                            self.bccx.loan_path_to_str(&*old_loan.loan_path))
+                            self.bccx.loan_path_to_str(
+                                &*old_loan.loan_path))
                 }
 
                 ty::ImmBorrow => {
@@ -340,7 +343,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
 
             self.bccx.span_note(
                 old_loan.span,
-                format!("{}; {}", borrow_summary, rule_summary));
+                format!("{}; {}", borrow_summary, rule_summary).as_slice());
 
             let old_loan_span = self.tcx().map.span(old_loan.kill_scope);
             self.bccx.span_end_note(old_loan_span,
@@ -428,14 +431,14 @@ pub fn check_assignment(&self, expr: &ast::Expr) {
                     format!("cannot assign to {} {} `{}`",
                             cmt.mutbl.to_user_str(),
                             self.bccx.cmt_to_str(&*cmt),
-                            self.bccx.loan_path_to_str(&*lp)));
+                            self.bccx.loan_path_to_str(&*lp)).as_slice());
             }
             None => {
                 self.bccx.span_err(
                     expr.span,
                     format!("cannot assign to {} {}",
                             cmt.mutbl.to_user_str(),
-                            self.bccx.cmt_to_str(&*cmt)));
+                            self.bccx.cmt_to_str(&*cmt)).as_slice());
             }
         }
         return;
@@ -672,11 +675,11 @@ pub fn report_illegal_mutation(&self,
         self.bccx.span_err(
             expr.span,
             format!("cannot assign to `{}` because it is borrowed",
-                 self.bccx.loan_path_to_str(loan_path)));
+                    self.bccx.loan_path_to_str(loan_path)).as_slice());
         self.bccx.span_note(
             loan.span,
             format!("borrow of `{}` occurs here",
-                 self.bccx.loan_path_to_str(loan_path)));
+                    self.bccx.loan_path_to_str(loan_path)).as_slice());
     }
 
     fn check_move_out_from_expr(&self, expr: &ast::Expr) {
@@ -702,11 +705,13 @@ fn check_move_out_from_id(&self, id: ast::NodeId, span: Span) {
                         span,
                         format!("cannot move out of `{}` \
                                 because it is borrowed",
-                             self.bccx.loan_path_to_str(move_path)));
+                                self.bccx.loan_path_to_str(
+                                    move_path)).as_slice());
                     self.bccx.span_note(
                         loan_span,
                         format!("borrow of `{}` occurs here",
-                                self.bccx.loan_path_to_str(&*loan_path)));
+                                self.bccx.loan_path_to_str(
+                                    &*loan_path)).as_slice());
                 }
             }
             true
@@ -745,11 +750,13 @@ fn check_by_move_capture(this: &CheckLoanCtxt,
                         freevar.span,
                         format!("cannot move `{}` into closure \
                                 because it is borrowed",
-                                this.bccx.loan_path_to_str(move_path)));
+                                this.bccx.loan_path_to_str(
+                                    move_path)).as_slice());
                     this.bccx.span_note(
                         loan_span,
                         format!("borrow of `{}` occurs here",
-                                this.bccx.loan_path_to_str(&*loan_path)));
+                                this.bccx.loan_path_to_str(
+                                    &*loan_path)).as_slice());
                 }
             }
         }
index b351c99084de3d9474b8f39dfa8af24dca36f8fd..d34ce7f6a5f24579a57972f95c3b43cdfcd031fe 100644 (file)
@@ -174,8 +174,9 @@ fn check_aliasability(bccx: &BorrowckCtxt,
                     // static item resides in immutable memory and mutating it would
                     // cause segfaults.
                     bccx.tcx.sess.span_err(borrow_span,
-                                           format!("borrow of immutable static items with \
-                                                    unsafe interior is not allowed"));
+                                           "borrow of immutable static items \
+                                            with unsafe interior is not \
+                                            allowed");
                     Err(())
                 }
                 mc::InteriorSafe => {
@@ -290,7 +291,8 @@ fn guarantee_valid(&mut self,
                     ty::ReInfer(..) => {
                         self.tcx().sess.span_bug(
                             cmt.span,
-                            format!("invalid borrow lifetime: {:?}", loan_region));
+                            format!("invalid borrow lifetime: {:?}",
+                                    loan_region).as_slice());
                     }
                 };
                 debug!("loan_scope = {:?}", loan_scope);
index 4662074aa47fb6302eb8c36e648f4e16d0e30d05..925244849bc8ab408f340242155d4c9f3812a742 100644 (file)
@@ -131,7 +131,7 @@ fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) {
             bccx.span_err(
                 move_from.span,
                 format!("cannot move out of {}",
-                        bccx.cmt_to_str(&*move_from)));
+                        bccx.cmt_to_str(&*move_from)).as_slice());
         }
 
         mc::cat_downcast(ref b) |
@@ -143,7 +143,7 @@ fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) {
                         move_from.span,
                         format!("cannot move out of type `{}`, \
                                  which defines the `Drop` trait",
-                                b.ty.user_string(bccx.tcx)));
+                                b.ty.user_string(bccx.tcx)).as_slice());
                 },
                 _ => fail!("this path should not cause illegal move")
             }
@@ -163,10 +163,10 @@ fn note_move_destination(bccx: &BorrowckCtxt,
             format!("attempting to move value to here (to prevent the move, \
                      use `ref {0}` or `ref mut {0}` to capture value by \
                      reference)",
-                    pat_name));
+                    pat_name).as_slice());
     } else {
         bccx.span_note(move_to_span,
                        format!("and here (use `ref {0}` or `ref mut {0}`)",
-                               pat_name));
+                               pat_name).as_slice());
     }
 }
index eaa39ee231df3fa347d8076193aec53f6d8fdaea..2060932875de6d4bd8e6e014a633c77384c1ca23 100644 (file)
@@ -460,17 +460,17 @@ pub fn report_use_of_moved_value(&self,
                 self.tcx.sess.span_err(
                     use_span,
                     format!("{} of possibly uninitialized variable: `{}`",
-                         verb,
-                         self.loan_path_to_str(lp)));
+                            verb,
+                            self.loan_path_to_str(lp)).as_slice());
             }
             _ => {
                 let partially = if lp == moved_lp {""} else {"partially "};
                 self.tcx.sess.span_err(
                     use_span,
                     format!("{} of {}moved value: `{}`",
-                         verb,
-                         partially,
-                         self.loan_path_to_str(lp)));
+                            verb,
+                            partially,
+                            self.loan_path_to_str(lp)).as_slice());
             }
         }
 
@@ -482,25 +482,31 @@ pub fn report_use_of_moved_value(&self,
                     Some(ast_map::NodeExpr(expr)) => {
                         (ty::expr_ty_adjusted(self.tcx, expr), expr.span)
                     }
-                    r => self.tcx.sess.bug(format!("MoveExpr({:?}) maps to {:?}, not Expr",
-                                                   move.id, r))
+                    r => {
+                        self.tcx.sess.bug(format!("MoveExpr({:?}) maps to \
+                                                   {:?}, not Expr",
+                                                  move.id,
+                                                  r).as_slice())
+                    }
                 };
                 let suggestion = move_suggestion(self.tcx, expr_ty,
                         "moved by default (use `copy` to override)");
                 self.tcx.sess.span_note(
                     expr_span,
                     format!("`{}` moved here because it has type `{}`, which is {}",
-                         self.loan_path_to_str(moved_lp),
-                         expr_ty.user_string(self.tcx), suggestion));
+                            self.loan_path_to_str(moved_lp),
+                            expr_ty.user_string(self.tcx),
+                            suggestion).as_slice());
             }
 
             move_data::MovePat => {
                 let pat_ty = ty::node_id_to_type(self.tcx, move.id);
                 self.tcx.sess.span_note(self.tcx.map.span(move.id),
                     format!("`{}` moved here because it has type `{}`, \
-                          which is moved by default (use `ref` to override)",
-                         self.loan_path_to_str(moved_lp),
-                         pat_ty.user_string(self.tcx)));
+                             which is moved by default (use `ref` to \
+                             override)",
+                            self.loan_path_to_str(moved_lp),
+                            pat_ty.user_string(self.tcx)).as_slice());
             }
 
             move_data::Captured => {
@@ -508,8 +514,12 @@ pub fn report_use_of_moved_value(&self,
                     Some(ast_map::NodeExpr(expr)) => {
                         (ty::expr_ty_adjusted(self.tcx, expr), expr.span)
                     }
-                    r => self.tcx.sess.bug(format!("Captured({:?}) maps to {:?}, not Expr",
-                                                   move.id, r))
+                    r => {
+                        self.tcx.sess.bug(format!("Captured({:?}) maps to \
+                                                   {:?}, not Expr",
+                                                  move.id,
+                                                  r).as_slice())
+                    }
                 };
                 let suggestion = move_suggestion(self.tcx, expr_ty,
                         "moved by default (make a copy and \
@@ -517,9 +527,10 @@ pub fn report_use_of_moved_value(&self,
                 self.tcx.sess.span_note(
                     expr_span,
                     format!("`{}` moved into closure environment here because it \
-                          has type `{}`, which is {}",
-                         self.loan_path_to_str(moved_lp),
-                         expr_ty.user_string(self.tcx), suggestion));
+                            has type `{}`, which is {}",
+                            self.loan_path_to_str(moved_lp),
+                            expr_ty.user_string(self.tcx),
+                            suggestion).as_slice());
             }
         }
 
@@ -547,10 +558,8 @@ pub fn report_reassigned_immutable_variable(&self,
         self.tcx.sess.span_err(
             span,
             format!("re-assignment of immutable variable `{}`",
-                 self.loan_path_to_str(lp)));
-        self.tcx.sess.span_note(
-            assign.span,
-            format!("prior assignment occurs here"));
+                    self.loan_path_to_str(lp)).as_slice());
+        self.tcx.sess.span_note(assign.span, "prior assignment occurs here");
     }
 
     pub fn span_err(&self, s: Span, m: &str) {
@@ -657,23 +666,23 @@ pub fn report_aliasability_violation(&self,
                 self.tcx.sess.span_err(
                     span,
                     format!("{} in an aliasable location",
-                             prefix));
+                             prefix).as_slice());
             }
             mc::AliasableStatic(..) |
             mc::AliasableStaticMut(..) => {
                 self.tcx.sess.span_err(
                     span,
-                    format!("{} in a static location", prefix));
+                    format!("{} in a static location", prefix).as_slice());
             }
             mc::AliasableManaged => {
                 self.tcx.sess.span_err(
                     span,
-                    format!("{} in a `@` pointer", prefix));
+                    format!("{} in a `@` pointer", prefix).as_slice());
             }
             mc::AliasableBorrowed => {
                 self.tcx.sess.span_err(
                     span,
-                    format!("{} in a `&` reference", prefix));
+                    format!("{} in a `&` reference", prefix).as_slice());
             }
         }
     }
@@ -710,12 +719,13 @@ pub fn note_and_explain_bckerr(&self, err: BckError) {
                 };
                 note_and_explain_region(
                     self.tcx,
-                    format!("{} would have to be valid for ", descr),
+                    format!("{} would have to be valid for ",
+                            descr).as_slice(),
                     loan_scope,
                     "...");
                 note_and_explain_region(
                     self.tcx,
-                    format!("...but {} is only valid for ", descr),
+                    format!("...but {} is only valid for ", descr).as_slice(),
                     ptr_scope,
                     "");
             }
@@ -739,7 +749,7 @@ pub fn append_loan_path_to_str(&self,
                     }
                     mc::PositionalField(idx) => {
                         out.push_char('#'); // invent a notation here
-                        out.push_str(idx.to_str());
+                        out.push_str(idx.to_str().as_slice());
                     }
                 }
             }
index c9c397d3d6121141a0cc6a7dc901dfe884ff3653..acf2442f6c16bd33168f53775dad97edad0e3bed 100644 (file)
@@ -508,7 +508,9 @@ fn add_exiting_edge(&mut self,
     fn add_returning_edge(&mut self,
                           _from_expr: @ast::Expr,
                           from_index: CFGIndex) {
-        let mut data = CFGEdgeData {exiting_scopes: vec!() };
+        let mut data = CFGEdgeData {
+            exiting_scopes: vec!(),
+        };
         for &LoopScope { loop_id: id, .. } in self.loop_scopes.iter().rev() {
             data.exiting_scopes.push(id);
         }
@@ -533,13 +535,15 @@ fn find_scope(&self,
                         }
                         self.tcx.sess.span_bug(
                             expr.span,
-                            format!("no loop scope for id {:?}", loop_id));
+                            format!("no loop scope for id {:?}",
+                                    loop_id).as_slice());
                     }
 
                     r => {
                         self.tcx.sess.span_bug(
                             expr.span,
-                            format!("bad entry `{:?}` in def_map for label", r));
+                            format!("bad entry `{:?}` in def_map for label",
+                                    r).as_slice());
                     }
                 }
             }
index b8baeefd3d02efdfa8b8e0b75883b6bd5d969866..3d69e84b63c92e66609a55db2b17266c09dcc206 100644 (file)
@@ -37,7 +37,8 @@ fn replace_newline_with_backslash_l(s: StrBuf) -> StrBuf {
         // \l, not the line that follows; so, add \l at end of string
         // if not already present, ensuring last line gets left-aligned
         // as well.
-        let mut last_two : Vec<_> = s.chars().rev().take(2).collect();
+        let mut last_two: Vec<_> =
+            s.as_slice().chars().rev().take(2).collect();
         last_two.reverse();
         if last_two.as_slice() != ['\\', 'l'] {
             s = s.append("\\l");
@@ -82,7 +83,9 @@ fn edge_label(&self, e: &Edge<'a>) -> dot::LabelText<'a> {
             let s = self.ast_map.node_to_str(node_id);
             // left-aligns the lines
             let s = replace_newline_with_backslash_l(s);
-            label = label.append(format!("exiting scope_{} {}", i, s.as_slice()));
+            label = label.append(format!("exiting scope_{} {}",
+                                         i,
+                                         s.as_slice()).as_slice());
         }
         dot::EscStr(label.into_maybe_owned())
     }
index 7da56655378edf7e8d65b5a856143e4b50b33d0d..64b7977c2351ed71430661b6bba57804e70df3da 100644 (file)
@@ -107,7 +107,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
                  .span_err(e.span,
                            format!("can not cast to `{}` in a constant \
                                     expression",
-                                   ppaux::ty_to_str(v.tcx, ety).as_slice()))
+                                   ppaux::ty_to_str(v.tcx, ety)).as_slice())
             }
           }
           ExprPath(ref pth) => {
index 4f08d818f4a13c33ad406f3012b67d905bbe163a..6e738b143083301dc63f4dad06ab660cb886b2cf 100644 (file)
@@ -57,10 +57,14 @@ fn require_loop(&self, name: &str, cx: Context, span: Span) {
         match cx {
             Loop => {}
             Closure => {
-                self.sess.span_err(span, format!("`{}` inside of a closure", name));
+                self.sess.span_err(span,
+                                   format!("`{}` inside of a closure",
+                                           name).as_slice());
             }
             Normal => {
-                self.sess.span_err(span, format!("`{}` outside of loop", name));
+                self.sess.span_err(span,
+                                   format!("`{}` outside of loop",
+                                           name).as_slice());
             }
         }
     }
index 7b91928ba41454a4ca8376dcb8b4d94f0649fdb8..fb797a027956f7ae4323f488cfa8e3293257d6e5 100644 (file)
@@ -74,7 +74,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &Expr) {
                // We know the type is inhabited, so this must be wrong
                cx.tcx.sess.span_err(ex.span, format!("non-exhaustive patterns: \
                             type {} is non-empty",
-                            ty_to_str(cx.tcx, pat_ty)));
+                            ty_to_str(cx.tcx, pat_ty)).as_slice());
            }
            // If the type *is* empty, it's vacuously exhaustive
            return;
@@ -164,8 +164,8 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: Vec<@Pat> ) {
             match ty::get(ty).sty {
                 ty::ty_bool => {
                     match *ctor {
-                        val(const_bool(true)) => Some("true".to_owned()),
-                        val(const_bool(false)) => Some("false".to_owned()),
+                        val(const_bool(true)) => Some("true".to_strbuf()),
+                        val(const_bool(false)) => Some("false".to_strbuf()),
                         _ => None
                     }
                 }
@@ -177,7 +177,11 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: Vec<@Pat> ) {
                     let variants = ty::enum_variants(cx.tcx, id);
 
                     match variants.iter().find(|v| v.id == vid) {
-                        Some(v) => Some(token::get_ident(v.name).get().to_str()),
+                        Some(v) => {
+                            Some(token::get_ident(v.name).get()
+                                                         .to_str()
+                                                         .into_strbuf())
+                        }
                         None => {
                             fail!("check_exhaustive: bad variant in ctor")
                         }
@@ -185,7 +189,9 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: Vec<@Pat> ) {
                 }
                 ty::ty_vec(..) | ty::ty_rptr(..) => {
                     match *ctor {
-                        vec(n) => Some(format!("vectors of length {}", n)),
+                        vec(n) => {
+                            Some(format_strbuf!("vectors of length {}", n))
+                        }
                         _ => None
                     }
                 }
@@ -193,11 +199,11 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: Vec<@Pat> ) {
             }
         }
     };
-    let msg = "non-exhaustive patterns".to_owned() + match ext {
-        Some(ref s) => format!(": {} not covered",  *s),
-        None => "".to_owned()
-    };
-    cx.tcx.sess.span_err(sp, msg);
+    let msg = format_strbuf!("non-exhaustive patterns{}", match ext {
+        Some(ref s) => format_strbuf!(": {} not covered", *s),
+        None => "".to_strbuf()
+    });
+    cx.tcx.sess.span_err(sp, msg.as_slice());
 }
 
 type matrix = Vec<Vec<@Pat> > ;
@@ -739,7 +745,8 @@ fn specialize(cx: &MatchCheckCtxt,
                                     pat_span,
                                     format!("struct pattern resolved to {}, \
                                           not a struct",
-                                         ty_to_str(cx.tcx, left_ty)));
+                                         ty_to_str(cx.tcx,
+                                                   left_ty)).as_slice());
                             }
                         }
                         let args = class_fields.iter().map(|class_field| {
@@ -980,9 +987,10 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
                     _ => {
                         cx.tcx.sess.span_bug(
                             p.span,
-                            format!("binding pattern {} is \
-                                  not an identifier: {:?}",
-                                 p.id, p.node));
+                            format!("binding pattern {} is not an \
+                                     identifier: {:?}",
+                                    p.id,
+                                    p.node).as_slice());
                     }
                 }
             }
index aa0b573eba8c819d7ad173a5d3bfa0c48f7cb08d..2a1334db2d085f29693b529e799b7054fd6d1115 100644 (file)
@@ -436,10 +436,11 @@ fn fromb(b: bool) -> Result<const_val, StrBuf> { Ok(const_int(b as i64)) }
         // (#5900). Fall back to doing a limited lookup to get past it.
         let ety = ty::expr_ty_opt(tcx.ty_ctxt(), e)
                 .or_else(|| astconv::ast_ty_to_prim_ty(tcx.ty_ctxt(), target_ty))
-                .unwrap_or_else(|| tcx.ty_ctxt().sess.span_fatal(
-                    target_ty.span,
-                    format!("target type not found for const cast")
-                ));
+                .unwrap_or_else(|| {
+                    tcx.ty_ctxt().sess.span_fatal(target_ty.span,
+                                                  "target type not found for \
+                                                   const cast")
+                });
 
         let base = eval_const_expr_partial(tcx, base);
         match base {
index 34a97c15f5c457d09be8354008e4a07856502368..a1de47f2fa8a64565f806bbd1536502241d16542 100644 (file)
@@ -102,14 +102,14 @@ fn pre(&self,
             let gens_str = if gens.iter().any(|&u| u != 0) {
                 format!(" gen: {}", bits_to_str(gens))
             } else {
-                "".to_owned()
+                "".to_strbuf()
             };
 
             let kills = self.kills.slice(start, end);
             let kills_str = if kills.iter().any(|&u| u != 0) {
                 format!(" kill: {}", bits_to_str(kills))
             } else {
-                "".to_owned()
+                "".to_strbuf()
             };
 
             try!(ps.synth_comment(format_strbuf!("id {}: {}{}{}",
@@ -652,8 +652,9 @@ fn pop_scopes(&mut self,
                     tcx.sess.span_bug(
                         from_expr.span,
                         format!("pop_scopes(from_expr={}, to_scope={:?}) \
-                              to_scope does not enclose from_expr",
-                             from_expr.repr(tcx), to_scope.loop_id));
+                                 to_scope does not enclose from_expr",
+                                from_expr.repr(tcx),
+                                to_scope.loop_id).as_slice());
                 }
             }
         }
@@ -765,7 +766,8 @@ fn find_scope<'a,'b>(
                             None => {
                                 self.tcx().sess.span_bug(
                                     expr.span,
-                                    format!("no loop scope for id {:?}", loop_id));
+                                    format!("no loop scope for id {:?}",
+                                            loop_id).as_slice());
                             }
                         }
                     }
@@ -773,7 +775,8 @@ fn find_scope<'a,'b>(
                     r => {
                         self.tcx().sess.span_bug(
                             expr.span,
-                            format!("bad entry `{:?}` in def_map for label", r));
+                            format!("bad entry `{:?}` in def_map for label",
+                                    r).as_slice());
                     }
                 }
             }
@@ -789,7 +792,9 @@ fn is_method_call(&self, expr: &ast::Expr) -> bool {
 
     fn reset(&mut self, bits: &mut [uint]) {
         let e = if self.dfcx.oper.initial_value() {uint::MAX} else {0};
-        for b in bits.mut_iter() { *b = e; }
+        for b in bits.mut_iter() {
+            *b = e;
+        }
     }
 
     fn add_to_entry_set(&mut self, id: ast::NodeId, pred_bits: &[uint]) {
@@ -841,7 +846,7 @@ fn bits_to_str(words: &[uint]) -> StrBuf {
         let mut v = word;
         for _ in range(0u, uint::BYTES) {
             result.push_char(sep);
-            result.push_str(format!("{:02x}", v & 0xFF));
+            result.push_str(format!("{:02x}", v & 0xFF).as_slice());
             v >>= 8;
             sep = '-';
         }
index ae88d64e2f0c90bfce7dacb6707fcab5a880c290..b9288fd9fe56fe8c53668fea721b4ddb0bb9a20a 100644 (file)
@@ -118,7 +118,7 @@ fn calculate_type(sess: &session::Session,
                 let src = sess.cstore.get_used_crate_source(cnum).unwrap();
                 if src.rlib.is_some() { return }
                 sess.err(format!("dependency `{}` not found in rlib format",
-                                 data.name));
+                                 data.name).as_slice());
             });
             return Vec::new();
         }
@@ -187,7 +187,7 @@ fn calculate_type(sess: &session::Session,
                                  match kind {
                                      cstore::RequireStatic => "rlib",
                                      cstore::RequireDynamic => "dylib",
-                                 }));
+                                 }).as_slice());
             }
         }
     }
@@ -211,7 +211,8 @@ fn add_library(sess: &session::Session,
             if link2 != link || link == cstore::RequireStatic {
                 let data = sess.cstore.get_crate_data(cnum);
                 sess.err(format!("cannot satisfy dependencies so `{}` only \
-                                  shows up once", data.name));
+                                  shows up once",
+                                 data.name).as_slice());
                 sess.note("having upstream crates all available in one format \
                            will likely make this go away");
             }
index 2819d7493a668deb2bf130fdb98c31f4b6925c75..b3b09ba631e264e2aa821cab8e479b13f9f8989b 100644 (file)
@@ -48,8 +48,9 @@ fn require_unsafe(&mut self, span: Span, description: &str) {
             SafeContext => {
                 // Report an error.
                 self.tcx.sess.span_err(span,
-                                  format!("{} requires unsafe function or block",
-                                       description))
+                                  format!("{} requires unsafe function or \
+                                           block",
+                                          description).as_slice())
             }
             UnsafeBlock(block_id) => {
                 // OK, but record this.
index f3977340064695482f2e7c194bcb9c63f00976b2..9d735dbaeae56cb952e0294f3970d482e131e0cc 100644 (file)
@@ -422,7 +422,7 @@ fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) {
                 self.tcx().sess.span_bug(
                     callee.span,
                     format!("unxpected callee type {}",
-                            callee_ty.repr(self.tcx())));
+                            callee_ty.repr(self.tcx())).as_slice());
             }
         }
     }
@@ -448,9 +448,7 @@ fn walk_stmt(&mut self, stmt: &ast::Stmt) {
             }
 
             ast::StmtMac(..) => {
-                self.tcx().sess.span_bug(
-                    stmt.span,
-                    format!("unexpanded stmt macro"));
+                self.tcx().sess.span_bug(stmt.span, "unexpanded stmt macro");
             }
         }
     }
@@ -518,7 +516,7 @@ fn walk_struct_expr(&mut self,
             _ => {
                 self.tcx().sess.span_bug(
                     with_expr.span,
-                    format!("with expression doesn't evaluate to a struct"));
+                    "with expression doesn't evaluate to a struct");
             }
         };
 
@@ -601,7 +599,7 @@ fn walk_autoderefs(&mut self,
                         ty::ty_rptr(r, ref m) => (m.mutbl, r),
                         _ => self.tcx().sess.span_bug(expr.span,
                                 format!("bad overloaded deref type {}",
-                                    method_ty.repr(self.tcx())))
+                                    method_ty.repr(self.tcx())).as_slice())
                     };
                     let bk = ty::BorrowKind::from_mutbl(m);
                     self.delegate.borrow(expr.id, expr.span, cmt,
index 81d6fc87a919c674c5aa7a3ac6e90d049b957e3c..64fa1a7270c9c6ee0168877923c7665a347fb59b 100644 (file)
@@ -127,10 +127,12 @@ fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_t
     check_builtin_bounds(cx, self_ty, trait_def.bounds, |missing| {
         cx.tcx.sess.span_err(self_type.span,
             format!("the type `{}', which does not fulfill `{}`, cannot implement this \
-                  trait", ty_to_str(cx.tcx, self_ty), missing.user_string(cx.tcx)));
+                    trait",
+                    ty_to_str(cx.tcx, self_ty),
+                    missing.user_string(cx.tcx)).as_slice());
         cx.tcx.sess.span_note(self_type.span,
             format!("types implementing this trait must fulfill `{}`",
-                 trait_def.bounds.user_string(cx.tcx)));
+                    trait_def.bounds.user_string(cx.tcx)).as_slice());
     });
 
     // If this is a destructor, check kinds.
@@ -210,8 +212,9 @@ fn check_for_bare(cx: &Context, fv: &freevar_entry) {
             b(check_for_bare)
         }
         ref s => {
-            cx.tcx.sess.bug(
-                format!("expect fn type in kind checker, not {:?}", s));
+            cx.tcx.sess.bug(format!("expect fn type in kind checker, not \
+                                     {:?}",
+                                    s).as_slice());
         }
     }
 }
@@ -390,9 +393,9 @@ pub fn check_typaram_bounds(cx: &Context,
         cx.tcx.sess.span_err(
             sp,
             format!("instantiating a type parameter with an incompatible type \
-                  `{}`, which does not fulfill `{}`",
-                 ty_to_str(cx.tcx, ty),
-                 missing.user_string(cx.tcx)));
+                     `{}`, which does not fulfill `{}`",
+                    ty_to_str(cx.tcx, ty),
+                    missing.user_string(cx.tcx)).as_slice());
     });
 }
 
@@ -403,19 +406,26 @@ pub fn check_freevar_bounds(cx: &Context, sp: Span, ty: ty::t,
         // Will be Some if the freevar is implicitly borrowed (stack closure).
         // Emit a less mysterious error message in this case.
         match referenced_ty {
-            Some(rty) => cx.tcx.sess.span_err(sp,
-                format!("cannot implicitly borrow variable of type `{}` in a bounded \
-                      stack closure (implicit reference does not fulfill `{}`)",
-                     ty_to_str(cx.tcx, rty), missing.user_string(cx.tcx))),
-            None => cx.tcx.sess.span_err(sp,
+            Some(rty) => {
+                cx.tcx.sess.span_err(sp,
+                format!("cannot implicitly borrow variable of type `{}` in a \
+                         bounded stack closure (implicit reference does not \
+                         fulfill `{}`)",
+                        ty_to_str(cx.tcx, rty),
+                        missing.user_string(cx.tcx)).as_slice())
+            }
+            None => {
+                cx.tcx.sess.span_err(sp,
                 format!("cannot capture variable of type `{}`, which does \
-                      not fulfill `{}`, in a bounded closure",
-                     ty_to_str(cx.tcx, ty), missing.user_string(cx.tcx))),
+                         not fulfill `{}`, in a bounded closure",
+                        ty_to_str(cx.tcx, ty),
+                        missing.user_string(cx.tcx)).as_slice())
+            }
         }
         cx.tcx.sess.span_note(
             sp,
             format!("this closure's environment must satisfy `{}`",
-                 bounds.user_string(cx.tcx)));
+                    bounds.user_string(cx.tcx)).as_slice());
     });
 }
 
@@ -424,9 +434,9 @@ pub fn check_trait_cast_bounds(cx: &Context, sp: Span, ty: ty::t,
     check_builtin_bounds(cx, ty, bounds, |missing| {
         cx.tcx.sess.span_err(sp,
             format!("cannot pack type `{}`, which does not fulfill \
-                  `{}`, as a trait bounded by {}",
-                 ty_to_str(cx.tcx, ty), missing.user_string(cx.tcx),
-                 bounds.user_string(cx.tcx)));
+                     `{}`, as a trait bounded by {}",
+                    ty_to_str(cx.tcx, ty), missing.user_string(cx.tcx),
+                    bounds.user_string(cx.tcx)).as_slice());
     });
 }
 
@@ -436,9 +446,10 @@ fn check_copy(cx: &Context, ty: ty::t, sp: Span, reason: &str) {
            ty::type_contents(cx.tcx, ty).to_str());
     if ty::type_moves_by_default(cx.tcx, ty) {
         cx.tcx.sess.span_err(
-            sp, format!("copying a value of non-copyable type `{}`",
-                     ty_to_str(cx.tcx, ty)));
-        cx.tcx.sess.span_note(sp, format!("{}", reason));
+            sp,
+            format!("copying a value of non-copyable type `{}`",
+                    ty_to_str(cx.tcx, ty)).as_slice());
+        cx.tcx.sess.span_note(sp, format!("{}", reason).as_slice());
     }
 }
 
@@ -448,7 +459,8 @@ pub fn check_static(tcx: &ty::ctxt, ty: ty::t, sp: Span) -> bool {
           ty::ty_param(..) => {
             tcx.sess.span_err(sp,
                 format!("value may contain references; \
-                         add `'static` bound to `{}`", ty_to_str(tcx, ty)));
+                         add `'static` bound to `{}`",
+                        ty_to_str(tcx, ty)).as_slice());
           }
           _ => {
             tcx.sess.span_err(sp, "value may contain references");
@@ -564,8 +576,11 @@ fn is_ReScope(r: ty::Region) -> bool {
 // Ensure that `ty` has a statically known size (i.e., it has the `Sized` bound).
 fn check_sized(tcx: &ty::ctxt, ty: ty::t, name: StrBuf, sp: Span) {
     if !ty::type_is_sized(tcx, ty) {
-        tcx.sess.span_err(sp, format!("variable `{}` has dynamically sized type `{}`",
-                                      name, ty_to_str(tcx, ty)));
+        tcx.sess.span_err(sp,
+                          format!("variable `{}` has dynamically sized type \
+                                   `{}`",
+                                  name,
+                                  ty_to_str(tcx, ty)).as_slice());
     }
 }
 
index 81e9c3f5ec6b22a3183a5c89624ddf1de993bde4..4c381aff1e3da03be9aa3ad32c61a6380982096c 100644 (file)
@@ -152,7 +152,8 @@ pub fn collect_item(&mut self, item_index: uint, item_def_id: ast::DefId) {
         match self.items.items.get(item_index) {
             &Some(original_def_id) if original_def_id != item_def_id => {
                 self.session.err(format!("duplicate entry for `{}`",
-                                      LanguageItems::item_name(item_index)));
+                                         LanguageItems::item_name(
+                                             item_index)).as_slice());
             }
             &Some(_) | &None => {
                 // OK.
index d0b7eed6e0099465e4d5e45b91d2915f1abff1c4..8feacba6e006de8639905346b799ab3203ecb58b 100644 (file)
@@ -506,8 +506,10 @@ fn span_lint(&self, lint: Lint, span: Span, msg: &str) {
         let mut note = None;
         let msg = match src {
             Default => {
-                format!("{}, \\#[{}({})] on by default", msg,
-                    level_to_str(level), self.lint_to_str(lint))
+                format_strbuf!("{}, \\#[{}({})] on by default",
+                               msg,
+                               level_to_str(level),
+                               self.lint_to_str(lint))
             },
             CommandLine => {
                 format!("{} [-{} {}]", msg,
@@ -522,8 +524,8 @@ fn span_lint(&self, lint: Lint, span: Span, msg: &str) {
             }
         };
         match level {
-            Warn =>          { self.tcx.sess.span_warn(span, msg); }
-            Deny | Forbid => { self.tcx.sess.span_err(span, msg);  }
+            Warn => self.tcx.sess.span_warn(span, msg.as_slice()),
+            Deny | Forbid => self.tcx.sess.span_err(span, msg.as_slice()),
             Allow => fail!(),
         }
 
@@ -552,7 +554,7 @@ fn with_lint_attrs(&mut self,
                         UnrecognizedLint,
                         meta.span,
                         format!("unknown `{}` attribute: `{}`",
-                        level_to_str(level), lintname));
+                                level_to_str(level), lintname).as_slice());
                 }
                 Some(lint) => {
                     let lint = lint.lint;
@@ -560,8 +562,9 @@ fn with_lint_attrs(&mut self,
                     if now == Forbid && level != Forbid {
                         self.tcx.sess.span_err(meta.span,
                         format!("{}({}) overruled by outer forbid({})",
-                        level_to_str(level),
-                        lintname, lintname));
+                                level_to_str(level),
+                                lintname,
+                                lintname).as_slice());
                     } else if now != level {
                         let src = self.get_source(lint);
                         self.lint_stack.push((lint, now, src));
@@ -965,13 +968,13 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
         if n_uniq > 0 && lint != ManagedHeapMemory {
             let s = ty_to_str(cx.tcx, ty);
             let m = format!("type uses owned (Box type) pointers: {}", s);
-            cx.span_lint(lint, span, m);
+            cx.span_lint(lint, span, m.as_slice());
         }
 
         if n_box > 0 && lint != OwnedHeapMemory {
             let s = ty_to_str(cx.tcx, ty);
             let m = format!("type uses managed (@ type) pointers: {}", s);
-            cx.span_lint(lint, span, m);
+            cx.span_lint(lint, span, m.as_slice());
         }
     }
 }
@@ -1122,7 +1125,8 @@ fn check_attrs_usage(cx: &Context, attrs: &[ast::Attribute]) {
         for &(obs_attr, obs_alter) in obsolete_attrs.iter() {
             if name.equiv(&obs_attr) {
                 cx.span_lint(AttributeUsage, attr.span,
-                             format!("obsolete attribute: {:s}", obs_alter));
+                             format!("obsolete attribute: {:s}",
+                                     obs_alter).as_slice());
                 return;
             }
         }
@@ -1233,7 +1237,7 @@ fn check_case(cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
             cx.span_lint(
                 NonCamelCaseTypes, span,
                 format!("{} `{}` should have a camel case identifier",
-                    sort, token::get_ident(ident)));
+                    sort, token::get_ident(ident)).as_slice());
         }
     }
 
@@ -1331,7 +1335,8 @@ fn check_unnecessary_parens_core(cx: &Context, value: &ast::Expr, msg: &str) {
     match value.node {
         ast::ExprParen(_) => {
             cx.span_lint(UnnecessaryParens, value.span,
-                         format!("unnecessary parentheses around {}", msg))
+                         format!("unnecessary parentheses around {}",
+                                 msg).as_slice())
         }
         _ => {}
     }
@@ -1506,8 +1511,10 @@ fn check_missing_doc_attrs(cx: &Context,
         }
     });
     if !has_doc {
-        cx.span_lint(MissingDoc, sp,
-                     format!("missing documentation for {}", desc));
+        cx.span_lint(MissingDoc,
+                     sp,
+                     format!("missing documentation for {}",
+                             desc).as_slice());
     }
 }
 
@@ -1675,7 +1682,7 @@ fn check_stability(cx: &Context, e: &ast::Expr) {
         _ => format!("use of {} item", label)
     };
 
-    cx.span_lint(lint, e.span, msg);
+    cx.span_lint(lint, e.span, msg.as_slice());
 }
 
 impl<'a> Visitor<()> for Context<'a> {
@@ -1906,8 +1913,11 @@ pub fn check_crate(tcx: &ty::ctxt,
     // in the iteration code.
     for (id, v) in tcx.sess.lints.borrow().iter() {
         for &(lint, span, ref msg) in v.iter() {
-            tcx.sess.span_bug(span, format!("unprocessed lint {:?} at {}: {}",
-                                            lint, tcx.map.node_to_str(*id), *msg))
+            tcx.sess.span_bug(span,
+                              format!("unprocessed lint {:?} at {}: {}",
+                                      lint,
+                                      tcx.map.node_to_str(*id),
+                                      *msg).as_slice())
         }
     }
 
index 1954c6d4123eebb92f7fa440ea72142f5a19ada5..322674a5c9b7d55675f74f91fef92c230c09aefd 100644 (file)
@@ -317,7 +317,7 @@ fn variable(&self, node_id: NodeId, span: Span) -> Variable {
             self.tcx
                 .sess
                 .span_bug(span, format!("no variable registered for id {}",
-                                        node_id));
+                                        node_id).as_slice());
           }
         }
     }
@@ -606,8 +606,9 @@ fn live_node(&self, node_id: NodeId, span: Span) -> LiveNode {
             // code have to agree about which AST nodes are worth
             // creating liveness nodes for.
             self.ir.tcx.sess.span_bug(
-                span, format!("no live node registered for node {}",
-                           node_id));
+                span,
+                format!("no live node registered for node {}",
+                        node_id).as_slice());
           }
         }
     }
index bd29398e5225daa73171a043a94196cc0da3415b..3198c0e839877f8ef10e01fafed1076c27f6fbb2 100644 (file)
@@ -224,7 +224,7 @@ pub fn deref_kind(tcx: &ty::ctxt, t: ty::t) -> deref_kind {
       None => {
         tcx.sess.bug(
             format!("deref_cat() invoked on non-derefable type {}",
-                 ty_to_str(tcx, t)));
+                    ty_to_str(tcx, t)).as_slice());
       }
     }
 }
@@ -578,7 +578,8 @@ pub fn cat_def(&self,
                       self.tcx().sess.span_bug(
                           span,
                           format!("Upvar of non-closure {} - {}",
-                                  fn_node_id, ty.repr(self.tcx())));
+                                  fn_node_id,
+                                  ty.repr(self.tcx())).as_slice());
                   }
               }
           }
@@ -727,7 +728,7 @@ fn cat_deref<N:ast_node>(&self,
                 self.tcx().sess.span_bug(
                     node.span(),
                     format!("Explicit deref of non-derefable type: {}",
-                            base_cmt.ty.repr(self.tcx())));
+                            base_cmt.ty.repr(self.tcx())).as_slice());
             }
         }
     }
@@ -800,7 +801,7 @@ pub fn cat_index<N:ast_node>(&self,
             self.tcx().sess.span_bug(
                 elt.span(),
                 format!("Explicit index of non-index type `{}`",
-                     base_cmt.ty.repr(self.tcx())));
+                        base_cmt.ty.repr(self.tcx())).as_slice());
           }
         };
 
@@ -884,9 +885,8 @@ fn vec_slice_info(tcx: &ty::ctxt,
                 },
 
                 _ => {
-                    tcx.sess.span_bug(
-                        pat.span,
-                        format!("Type of slice pattern is not a slice"));
+                    tcx.sess.span_bug(pat.span,
+                                      "type of slice pattern is not a slice");
                 }
             }
         }
index d7aba4208640a905ff0ae0b292efc706f1d67eac..191ac9aa9a37758c6e8fb554a2789344a91ca81e 100644 (file)
@@ -632,7 +632,7 @@ fn check_field(&mut self,
             UnnamedField(idx) => format!("field \\#{} of {} is private",
                                          idx + 1, struct_desc),
         };
-        self.tcx.sess.span_err(span, msg);
+        self.tcx.sess.span_err(span, msg.as_slice());
     }
 
     // Given the ID of a method, checks to ensure it's in scope.
@@ -647,7 +647,8 @@ fn check_static_method(&mut self, span: Span, method_id: ast::DefId,
         self.report_error(self.ensure_public(span,
                                              method_id,
                                              None,
-                                             format!("method `{}`", string)));
+                                             format!("method `{}`",
+                                                     string).as_slice()));
     }
 
     // Checks that a path is in scope.
@@ -661,8 +662,12 @@ fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
                                                 .unwrap()
                                                 .identifier);
                 let origdid = def_id_of_def(orig_def);
-                self.ensure_public(span, def, Some(origdid),
-                                   format!("{} `{}`", tyname, name))
+                self.ensure_public(span,
+                                   def,
+                                   Some(origdid),
+                                   format!("{} `{}`",
+                                           tyname,
+                                           name).as_slice())
             };
 
             match *self.last_private_map.get(&path_id) {
index 49e607f12406c2da081bb0220a0a87b9152d760d..3e4ebe845d7d5a8a11dd0362be8086bac00c8527 100644 (file)
@@ -234,7 +234,7 @@ fn propagate(&mut self) {
                 None => {
                     self.tcx.sess.bug(format!("found unmapped ID in worklist: \
                                                {}",
-                                              search_item))
+                                              search_item).as_slice())
                 }
             }
         }
@@ -324,9 +324,12 @@ fn propagate_node(&mut self, node: &ast_map::Node,
             ast_map::NodeVariant(_) |
             ast_map::NodeStructCtor(_) => {}
             _ => {
-                self.tcx.sess.bug(format!("found unexpected thingy in \
-                                           worklist: {}",
-                                          self.tcx.map.node_to_str(search_item)))
+                self.tcx
+                    .sess
+                    .bug(format!("found unexpected thingy in worklist: {}",
+                                 self.tcx
+                                     .map
+                                     .node_to_str(search_item)).as_slice())
             }
         }
     }
index ac37af05359d58355f85f30ded0c2aeffc087658..0a7da6e6d088fec9a3278cb07dcbdac6e8344983 100644 (file)
@@ -1085,14 +1085,14 @@ fn add_child(&self,
                     self.resolve_error(sp,
                         format!("duplicate definition of {} `{}`",
                              namespace_error_to_str(duplicate_type),
-                             token::get_ident(name)));
+                             token::get_ident(name)).as_slice());
                     {
                         let r = child.span_for_namespace(ns);
                         for sp in r.iter() {
                             self.session.span_note(*sp,
                                  format!("first definition of {} `{}` here",
                                       namespace_error_to_str(duplicate_type),
-                                      token::get_ident(name)));
+                                      token::get_ident(name)).as_slice());
                         }
                     }
                 }
@@ -2054,7 +2054,7 @@ fn resolve_imports_for_module(&mut self, module: Rc<Module>) {
                                        import_directive.module_path
                                                        .as_slice(),
                                        import_directive.subclass));
-                    self.resolve_error(import_directive.span, msg);
+                    self.resolve_error(import_directive.span, msg.as_slice());
                 }
                 Indeterminate => {
                     // Bail out. We'll come around next time.
@@ -2427,7 +2427,7 @@ fn get_binding(this: &mut Resolver,
                                `{}` in `{}`",
                               token::get_ident(source),
                               self.module_to_str(&*containing_module));
-            self.resolve_error(directive.span, msg);
+            self.resolve_error(directive.span, msg.as_slice());
             return Failed;
         }
         let value_used_public = value_used_reexport || value_used_public;
@@ -2651,14 +2651,17 @@ fn resolve_module_path_from_root(&mut self,
                             expn_info: span.expn_info,
                         };
                         self.resolve_error(span,
-                                              format!("unresolved import. maybe \
+                                           format!("unresolved import. maybe \
                                                     a missing `extern crate \
                                                     {}`?",
-                                                    segment_name));
+                                                   segment_name).as_slice());
                         return Failed;
                     }
-                    self.resolve_error(span, format!("unresolved import: could not find `{}` in \
-                                                     `{}`.", segment_name, module_name));
+                    self.resolve_error(span,
+                                       format!("unresolved import: could not \
+                                                find `{}` in `{}`.",
+                                               segment_name,
+                                               module_name).as_slice());
                     return Failed;
                 }
                 Indeterminate => {
@@ -2675,8 +2678,11 @@ fn resolve_module_path_from_root(&mut self,
                             match type_def.module_def {
                                 None => {
                                     // Not a module.
-                                    self.resolve_error(span, format!("not a module `{}`",
-                                                                 token::get_ident(name)));
+                                    self.resolve_error(
+                                        span,
+                                        format!("not a module `{}`",
+                                                token::get_ident(name))
+                                                .as_slice());
                                     return Failed;
                                 }
                                 Some(ref module_def) => {
@@ -2717,9 +2723,10 @@ fn resolve_module_path_from_root(&mut self,
                         }
                         None => {
                             // There are no type bindings at all.
-                            self.resolve_error(span,
-                                                  format!("not a module `{}`",
-                                                       token::get_ident(name)));
+                            self.resolve_error(
+                                span,
+                                format!("not a module `{}`",
+                                        token::get_ident(name)).as_slice());
                             return Failed;
                         }
                     }
@@ -2764,16 +2771,15 @@ fn resolve_module_path(&mut self,
                 let mpath = self.idents_to_str(module_path);
                 match mpath.as_slice().rfind(':') {
                     Some(idx) => {
-                        self.resolve_error(span,
-                                           format!("unresolved import: could \
-                                                    not find `{}` in `{}`",
-                                                   // idx +- 1 to account for
-                                                   // the colons on either
-                                                   // side
-                                                   mpath.as_slice()
-                                                        .slice_from(idx + 1),
-                                                   mpath.as_slice()
-                                                        .slice_to(idx - 1)));
+                        self.resolve_error(
+                            span,
+                            format!("unresolved import: could not find `{}` \
+                                     in `{}`",
+                                    // idx +- 1 to account for the colons on \
+                                    // either side
+                                    mpath.as_slice().slice_from(idx + 1),
+                                    mpath.as_slice()
+                                         .slice_to(idx - 1)).as_slice());
                     },
                     None => (),
                 };
@@ -3200,7 +3206,7 @@ fn report_unresolved_imports(&mut self, module_: Rc<Module>) {
             } else {
                 let err = format!("unresolved import (maybe you meant `{}::*`?)",
                                   sn.as_slice().slice(0, sn.len()));
-                self.resolve_error(imports.get(index).span, err);
+                self.resolve_error(imports.get(index).span, err.as_slice());
             }
         }
 
@@ -3870,7 +3876,7 @@ fn resolve_trait_reference(&mut self,
                 };
 
                 let msg = format!("attempt to {} a nonexistent trait `{}`", usage_str, path_str);
-                self.resolve_error(trait_reference.path.span, msg);
+                self.resolve_error(trait_reference.path.span, msg.as_slice());
             }
             Some(def) => {
                 debug!("(resolving trait) found trait def: {:?}", def);
@@ -4071,7 +4077,7 @@ fn check_consistent_bindings(&mut self, arm: &Arm) {
                         format!("variable `{}` from pattern \\#1 is \
                                   not bound in pattern \\#{}",
                                 token::get_name(key),
-                                i + 1));
+                                i + 1).as_slice());
                   }
                   Some(binding_i) => {
                     if binding_0.binding_mode != binding_i.binding_mode {
@@ -4080,7 +4086,7 @@ fn check_consistent_bindings(&mut self, arm: &Arm) {
                             format!("variable `{}` is bound with different \
                                       mode in pattern \\#{} than in pattern \\#1",
                                     token::get_name(key),
-                                    i + 1));
+                                    i + 1).as_slice());
                     }
                   }
                 }
@@ -4093,7 +4099,7 @@ fn check_consistent_bindings(&mut self, arm: &Arm) {
                         format!("variable `{}` from pattern \\#{} is \
                                   not bound in pattern \\#1",
                                 token::get_name(key),
-                                i + 1));
+                                i + 1).as_slice());
                 }
             }
         }
@@ -4220,7 +4226,7 @@ fn resolve_type(&mut self, ty: &Ty) {
                     None => {
                         let msg = format!("use of undeclared type name `{}`",
                                           self.path_idents_to_str(path));
-                        self.resolve_error(ty.span, msg);
+                        self.resolve_error(ty.span, msg.as_slice());
                     }
                 }
 
@@ -4285,12 +4291,12 @@ struct or enum variant",
                             self.record_def(pattern.id, (def, lp));
                         }
                         FoundStructOrEnumVariant(..) => {
-                            self.resolve_error(pattern.span,
-                                                  format!("declaration of `{}` \
-                                                        shadows an enum \
-                                                        variant or unit-like \
-                                                        struct in scope",
-                                                        token::get_name(renamed)));
+                            self.resolve_error(
+                                pattern.span,
+                                format!("declaration of `{}` shadows an enum \
+                                         variant or unit-like struct in \
+                                         scope",
+                                        token::get_name(renamed)).as_slice());
                         }
                         FoundConst(def, lp) if mode == RefutableMode => {
                             debug!("(resolving pattern) resolving `{}` to \
@@ -4359,9 +4365,10 @@ struct in scope",
                                       // in the same disjunct, which is an
                                       // error
                                      self.resolve_error(pattern.span,
-                                       format!("identifier `{}` is bound more \
-                                             than once in the same pattern",
-                                            path_to_str(path)));
+                                       format!("identifier `{}` is bound \
+                                                more than once in the same \
+                                                pattern",
+                                               path_to_str(path)).as_slice());
                                   }
                                   // Not bound in the same pattern: do nothing
                                 }
@@ -4406,8 +4413,11 @@ struct in scope",
                             self.resolve_error(
                                 path.span,
                                 format!("`{}` is not an enum variant or constant",
-                                     token::get_ident(
-                                         path.segments.last().unwrap().identifier)))
+                                        token::get_ident(
+                                            path.segments
+                                                .last()
+                                                .unwrap()
+                                                .identifier)).as_slice())
                         }
                         None => {
                             self.resolve_error(path.span,
@@ -4435,16 +4445,20 @@ struct in scope",
                         Some(_) => {
                             self.resolve_error(path.span,
                                 format!("`{}` is not an enum variant, struct or const",
-                                    token::get_ident(path.segments
-                                                         .last().unwrap()
-                                                         .identifier)));
+                                    token::get_ident(
+                                        path.segments
+                                            .last()
+                                            .unwrap()
+                                            .identifier)).as_slice());
                         }
                         None => {
                             self.resolve_error(path.span,
                                 format!("unresolved enum variant, struct or const `{}`",
-                                    token::get_ident(path.segments
-                                                         .last().unwrap()
-                                                         .identifier)));
+                                    token::get_ident(
+                                        path.segments
+                                            .last()
+                                            .unwrap()
+                                            .identifier)).as_slice());
                         }
                     }
 
@@ -4485,7 +4499,7 @@ struct in scope",
                                     def: {:?}", result);
                             let msg = format!("`{}` does not name a structure",
                                               self.path_idents_to_str(path));
-                            self.resolve_error(path.span, msg);
+                            self.resolve_error(path.span, msg.as_slice());
                         }
                     }
                 }
@@ -4705,7 +4719,7 @@ fn resolve_module_relative_path(&mut self,
             Failed => {
                 let msg = format!("use of undeclared module `{}`",
                                   self.idents_to_str(module_path_idents.as_slice()));
-                self.resolve_error(path.span, msg);
+                self.resolve_error(path.span, msg.as_slice());
                 return None;
             }
 
@@ -4776,7 +4790,7 @@ fn resolve_crate_relative_path(&mut self,
             Failed => {
                 let msg = format!("use of undeclared module `::{}`",
                                   self.idents_to_str(module_path_idents.as_slice()));
-                self.resolve_error(path.span, msg);
+                self.resolve_error(path.span, msg.as_slice());
                 return None;
             }
 
@@ -5096,12 +5110,12 @@ fn resolve_expr(&mut self, expr: &Expr) {
                                         format!("`{}` is a structure name, but \
                                                  this expression \
                                                  uses it like a function name",
-                                                wrong_name));
+                                                wrong_name).as_slice());
 
                                 self.session.span_note(expr.span,
                                     format!("Did you mean to write: \
                                             `{} \\{ /* fields */ \\}`?",
-                                            wrong_name));
+                                            wrong_name).as_slice());
 
                             }
                             _ => {
@@ -5119,10 +5133,11 @@ fn resolve_expr(&mut self, expr: &Expr) {
 
                                 if method_scope && token::get_name(self.self_ident.name).get()
                                                                         == wrong_name.as_slice() {
-                                        self.resolve_error(expr.span,
-                                                            format!("`self` is not available in a \
-                                                                    static method. Maybe a `self` \
-                                                                    argument is missing?"));
+                                        self.resolve_error(
+                                            expr.span,
+                                            "`self` is not available \
+                                             in a static method. Maybe a \
+                                             `self` argument is missing?");
                                 } else {
                                     let name = path_to_ident(path).name;
                                     let mut msg = match self.find_fallback_in_self_type(name) {
@@ -5130,7 +5145,7 @@ fn resolve_expr(&mut self, expr: &Expr) {
                                             // limit search to 5 to reduce the number
                                             // of stupid suggestions
                                             self.find_best_match_for_name(wrong_name.as_slice(), 5)
-                                                                .map_or("".into_owned(),
+                                                                .map_or("".to_strbuf(),
                                                                         |x| format!("`{}`", x))
                                         }
                                         Field =>
@@ -5147,8 +5162,11 @@ fn resolve_expr(&mut self, expr: &Expr) {
                                         msg = format!(" Did you mean {}?", msg)
                                     }
 
-                                    self.resolve_error(expr.span, format!("unresolved name `{}`.{}",
-                                                                            wrong_name, msg));
+                                    self.resolve_error(
+                                        expr.span,
+                                        format!("unresolved name `{}`.{}",
+                                                wrong_name,
+                                                msg).as_slice());
                                 }
                             }
                         }
@@ -5182,7 +5200,7 @@ fn resolve_expr(&mut self, expr: &Expr) {
                                 def: {:?}", result);
                         let msg = format!("`{}` does not name a structure",
                                           self.path_idents_to_str(path));
-                        self.resolve_error(path.span, msg);
+                        self.resolve_error(path.span, msg.as_slice());
                     }
                 }
 
@@ -5211,10 +5229,12 @@ fn resolve_expr(&mut self, expr: &Expr) {
                 let renamed = mtwt::resolve(label);
                 match self.search_ribs(self.label_ribs.borrow().as_slice(),
                                        renamed, expr.span) {
-                    None =>
-                        self.resolve_error(expr.span,
-                                              format!("use of undeclared label `{}`",
-                                                   token::get_ident(label))),
+                    None => {
+                        self.resolve_error(
+                            expr.span,
+                            format!("use of undeclared label `{}`",
+                                    token::get_ident(label)).as_slice())
+                    }
                     Some(DlDef(def @ DefLabel(_))) => {
                         // Since this def is a label, it is never read.
                         self.record_def(expr.id, (def, LastMod(AllPublic)))
@@ -5343,8 +5363,12 @@ fn record_def(&mut self, node_id: NodeId, (def, lp): (Def, LastPrivate)) {
             // times, so here is a sanity check it at least comes to
             // the same conclusion! - nmatsakis
             if def != *old_value {
-                self.session.bug(format!("node_id {:?} resolved first to {:?} \
-                                      and then {:?}", node_id, *old_value, def));
+                self.session
+                    .bug(format!("node_id {:?} resolved first to {:?} and \
+                                  then {:?}",
+                                 node_id,
+                                 *old_value,
+                                 def).as_slice());
             }
         });
     }
@@ -5356,10 +5380,10 @@ fn enforce_default_binding_mode(&mut self,
         match pat_binding_mode {
             BindByValue(_) => {}
             BindByRef(..) => {
-                self.resolve_error(
-                    pat.span,
-                    format!("cannot use `ref` binding mode with {}",
-                         descr));
+                self.resolve_error(pat.span,
+                                   format!("cannot use `ref` binding mode \
+                                            with {}",
+                                           descr).as_slice());
             }
         }
     }
index 048bbb7d4cd0daf44aa350accde0945359304269..7065772d74f6cc438ba8421129202084fb4b5706 100644 (file)
@@ -341,7 +341,7 @@ fn unresolved_lifetime_ref(&self,
         self.sess.span_err(
             lifetime_ref.span,
             format!("use of undeclared lifetime name `'{}`",
-                    token::get_name(lifetime_ref.name)));
+                    token::get_name(lifetime_ref.name)).as_slice());
     }
 
     fn check_lifetime_names(&self, lifetimes: &Vec<ast::Lifetime>) {
@@ -354,7 +354,7 @@ fn check_lifetime_names(&self, lifetimes: &Vec<ast::Lifetime>) {
                     self.sess.span_err(
                         lifetime.span,
                         format!("illegal lifetime parameter name: `{}`",
-                                token::get_name(lifetime.name)));
+                                token::get_name(lifetime.name)).as_slice());
                 }
             }
 
@@ -366,7 +366,7 @@ fn check_lifetime_names(&self, lifetimes: &Vec<ast::Lifetime>) {
                         lifetime_j.span,
                         format!("lifetime name `'{}` declared twice in \
                                 the same scope",
-                                token::get_name(lifetime_j.name)));
+                                token::get_name(lifetime_j.name)).as_slice());
                 }
             }
         }
index 96d2670134226d4521a8550debc7bef6fb78ce93..ebce96b0abbbb0bd2f752ce4cd01327b71288d95 100644 (file)
@@ -112,14 +112,17 @@ fn fold_ty(&mut self, t: ty::t) -> ty::t {
                     let root_msg = match self.root_ty {
                         Some(root) => format!(" in the substitution of `{}`",
                                               root.repr(self.tcx)),
-                        None => "".to_owned()
+                        None => "".to_strbuf()
                     };
                     let m = format!("can't use type parameters from outer \
                                     function{}; try using a local type \
-                                    parameter instead", root_msg);
+                                    parameter instead",
+                                    root_msg);
                     match self.span {
-                        Some(span) => self.tcx.sess.span_err(span, m),
-                        None => self.tcx.sess.err(m)
+                        Some(span) => {
+                            self.tcx.sess.span_err(span, m.as_slice())
+                        }
+                        None => self.tcx.sess.err(m.as_slice())
                     }
                     ty::mk_err()
                 }
@@ -131,12 +134,15 @@ fn fold_ty(&mut self, t: ty::t) -> ty::t {
                         let root_msg = match self.root_ty {
                             Some(root) => format!(" in the substitution of `{}`",
                                                   root.repr(self.tcx)),
-                            None => "".to_owned()
+                            None => "".to_strbuf()
                         };
-                        let m = format!("missing `Self` type param{}", root_msg);
+                        let m = format!("missing `Self` type param{}",
+                                        root_msg);
                         match self.span {
-                            Some(span) => self.tcx.sess.span_err(span, m),
-                            None => self.tcx.sess.err(m)
+                            Some(span) => {
+                                self.tcx.sess.span_err(span, m.as_slice())
+                            }
+                            None => self.tcx.sess.err(m.as_slice())
                         }
                         ty::mk_err()
                     }
index e609da6c33ddc14bcf2e47b88fbc6e5a806a676c..d86d414da43cb1d54ef01439dfb32455e0d6eb77 100644 (file)
@@ -462,7 +462,7 @@ fn assert_is_binding_or_wild(bcx: &Block, p: @ast::Pat) {
         bcx.sess().span_bug(
             p.span,
             format!("expected an identifier pattern but found p: {}",
-                 p.repr(bcx.tcx())));
+                    p.repr(bcx.tcx())).as_slice());
     }
 }
 
@@ -1229,8 +1229,10 @@ fn compare_str<'a>(cx: &'a Block<'a>,
                        rhs: ValueRef,
                        rhs_t: ty::t)
                        -> Result<'a> {
-        let did = langcall(cx, None,
-                           format!("comparison of `{}`", cx.ty_to_str(rhs_t)),
+        let did = langcall(cx,
+                           None,
+                           format!("comparison of `{}`",
+                                   cx.ty_to_str(rhs_t)).as_slice(),
                            StrEqFnLangItem);
         let result = callee::trans_lang_call(cx, did, [lhs, rhs], None);
         Result {
@@ -1252,8 +1254,10 @@ fn compare_str<'a>(cx: &'a Block<'a>,
                 Store(cx, lhs, scratch_lhs);
                 let scratch_rhs = alloca(cx, val_ty(rhs), "__rhs");
                 Store(cx, rhs, scratch_rhs);
-                let did = langcall(cx, None,
-                                   format!("comparison of `{}`", cx.ty_to_str(rhs_t)),
+                let did = langcall(cx,
+                                   None,
+                                   format!("comparison of `{}`",
+                                           cx.ty_to_str(rhs_t)).as_slice(),
                                    UniqStrEqFnLangItem);
                 let result = callee::trans_lang_call(cx, did, [scratch_lhs, scratch_rhs], None);
                 Result {
@@ -2154,7 +2158,7 @@ fn bind_irrefutable_pat<'a>(
 
     if bcx.sess().asm_comments() {
         add_comment(bcx, format!("bind_irrefutable_pat(pat={})",
-                              pat.repr(bcx.tcx())));
+                                 pat.repr(bcx.tcx())).as_slice());
     }
 
     let _indenter = indenter();
@@ -2273,7 +2277,7 @@ fn bind_irrefutable_pat<'a>(
         }
         ast::PatVec(..) => {
             bcx.sess().span_bug(pat.span,
-                format!("vector patterns are never irrefutable!"));
+                                "vector patterns are never irrefutable!");
         }
         ast::PatWild | ast::PatWildMulti | ast::PatLit(_) | ast::PatRange(_, _) => ()
     }
index 9cea6d0249cc4374d8ea550ca31388a310e5acaa..45baf07c07c0eb9c41d240ab543710930bb513ef 100644 (file)
@@ -192,7 +192,8 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr {
             if !cases.iter().enumerate().all(|(i,c)| c.discr == (i as Disr)) {
                 cx.sess().bug(format!("non-C-like enum {} with specified \
                                       discriminants",
-                                      ty::item_path_str(cx.tcx(), def_id)))
+                                      ty::item_path_str(cx.tcx(),
+                                                        def_id)).as_slice())
             }
 
             if cases.len() == 1 {
index e6004b4cb71f7d55fc5ff096b841a60193a6f9fe..fa299dc05036c0053fd66b06caba0206c7610de4 100644 (file)
@@ -67,7 +67,8 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
         StrBuf::from_str(constraints.iter()
                                     .map(|s| s.get().to_strbuf())
                                     .collect::<Vec<StrBuf>>()
-                                    .connect(","));
+                                    .connect(",")
+                                    .as_slice());
 
     let mut clobbers = getClobbers();
     if !ia.clobbers.get().is_empty() && !clobbers.is_empty() {
index fc5fcd98ef6f4d8c65b0544ee06e96c9e506fa8c..e208097e99b33a27cd8261bf66aad140039878ff 100644 (file)
@@ -341,7 +341,8 @@ fn require_alloc_fn(bcx: &Block, info_ty: ty::t, it: LangItem) -> ast::DefId {
         Ok(id) => id,
         Err(s) => {
             bcx.sess().fatal(format!("allocation of `{}` {}",
-                                     bcx.ty_to_str(info_ty), s));
+                                     bcx.ty_to_str(info_ty),
+                                     s).as_slice());
         }
     }
 }
@@ -476,7 +477,7 @@ pub fn unset_split_stack(f: ValueRef) {
 // silently mangles such symbols, breaking our linkage model.
 pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: StrBuf) {
     if ccx.all_llvm_symbols.borrow().contains(&sym) {
-        ccx.sess().bug(format!("duplicate LLVM symbol: {}", sym));
+        ccx.sess().bug(format!("duplicate LLVM symbol: {}", sym).as_slice());
     }
     ccx.all_llvm_symbols.borrow_mut().insert(sym);
 }
@@ -739,8 +740,11 @@ fn iter_variant<'r,
 
                   for variant in (*variants).iter() {
                       let variant_cx =
-                          fcx.new_temp_block("enum-iter-variant-".to_owned() +
-                                             variant.disr_val.to_str());
+                          fcx.new_temp_block(
+                              format_strbuf!("enum-iter-variant-{}",
+                                             variant.disr_val
+                                                    .to_str()
+                                                    .as_slice()).as_slice());
                       match adt::trans_case(cx, &*repr, variant.disr_val) {
                           _match::single_result(r) => {
                               AddCase(llswitch, r.val, variant_cx.llbb)
@@ -839,7 +843,7 @@ pub fn fail_if_zero<'a>(
       }
       _ => {
         cx.sess().bug(format!("fail-if-zero on unexpected type: {}",
-                              ty_to_str(cx.tcx(), rhs_t)));
+                              ty_to_str(cx.tcx(), rhs_t)).as_slice());
       }
     };
     with_cond(cx, is_zero, |bcx| {
@@ -1503,8 +1507,8 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
         ty::ty_bare_fn(ref bft) => bft.sig.output,
         _ => ccx.sess().bug(
             format!("trans_enum_variant_or_tuple_like_struct: \
-                  unexpected ctor return type {}",
-                 ty_to_str(ccx.tcx(), ctor_ty)))
+                     unexpected ctor return type {}",
+                    ty_to_str(ccx.tcx(), ctor_ty)).as_slice())
     };
 
     let arena = TypedArena::new();
@@ -2052,7 +2056,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
 
         ref variant => {
             ccx.sess().bug(format!("get_item_val(): unexpected variant: {:?}",
-                           variant))
+                                   variant).as_slice())
         }
     };
 
@@ -2116,7 +2120,9 @@ pub fn write_metadata(cx: &CrateContext, krate: &ast::Crate) -> Vec<u8> {
     let compressed = Vec::from_slice(encoder::metadata_encoding_version)
                      .append(match flate::deflate_bytes(metadata.as_slice()) {
                          Some(compressed) => compressed,
-                         None => cx.sess().fatal(format!("failed to compress metadata"))
+                         None => {
+                             cx.sess().fatal("failed to compress metadata")
+                         }
                      }.as_slice());
     let llmeta = C_bytes(cx, compressed.as_slice());
     let llconst = C_struct(cx, [llmeta], false);
index 17667003506b14b02f44b669a038a98f6196748c..f82a609d69572f0d90fb027aa079f4beceaedfed 100644 (file)
@@ -750,9 +750,11 @@ pub fn phi(&self, ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRe
 
     pub fn add_span_comment(&self, sp: Span, text: &str) {
         if self.ccx.sess().asm_comments() {
-            let s = format!("{} ({})", text, self.ccx.sess().codemap().span_to_str(sp));
-            debug!("{}", s);
-            self.add_comment(s);
+            let s = format!("{} ({})",
+                            text,
+                            self.ccx.sess().codemap().span_to_str(sp));
+            debug!("{}", s.as_slice());
+            self.add_comment(s.as_slice());
         }
     }
 
@@ -761,7 +763,7 @@ pub fn add_comment(&self, text: &str) {
             let sanitized = text.replace("$", "");
             let comment_text = format!("\\# {}", sanitized.replace("\n", "\n\t# "));
             self.count_insn("inlineasm");
-            let asm = comment_text.with_c_str(|c| {
+            let asm = comment_text.as_slice().with_c_str(|c| {
                 unsafe {
                     llvm::LLVMConstInlineAsm(Type::func([], &Type::void(self.ccx)).to_ref(),
                                              c, noname(), False, False)
index f32aa62d861d36796595a63de65709b54146a6cd..fe9581c638e7751cf886de89d2090334f37d1974 100644 (file)
@@ -102,8 +102,9 @@ fn datum_callee<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> {
             _ => {
                 bcx.tcx().sess.span_bug(
                     expr.span,
-                    format!("type of callee is neither bare-fn nor closure: {}",
-                         bcx.ty_to_str(datum.ty)));
+                    format!("type of callee is neither bare-fn nor closure: \
+                             {}",
+                            bcx.ty_to_str(datum.ty)).as_slice());
             }
         }
     }
@@ -151,7 +152,7 @@ fn trans_def<'a>(bcx: &'a Block<'a>, def: ast::Def, ref_expr: &ast::Expr)
                 bcx.tcx().sess.span_bug(
                     ref_expr.span,
                     format!("cannot translate def {:?} \
-                          to a callable thing!", def));
+                             to a callable thing!", def).as_slice());
             }
         }
     }
index 80ee555971d83412139a3b2c84f454c1ad555a57..68e66724d0c26914c239036f96c007090309306a 100644 (file)
@@ -329,7 +329,7 @@ fn schedule_clean_in_ast_scope(&self,
 
         self.ccx.sess().bug(
             format!("no cleanup scope {} found",
-                    self.ccx.tcx.map.node_to_str(cleanup_scope)));
+                    self.ccx.tcx.map.node_to_str(cleanup_scope)).as_slice());
     }
 
     fn schedule_clean_in_custom_scope(&self,
@@ -531,7 +531,7 @@ fn trans_cleanups_to_exit_scope(&'a self,
                     LoopExit(id, _) => {
                         self.ccx.sess().bug(format!(
                                 "cannot exit from scope {:?}, \
-                                not in scope", id));
+                                not in scope", id).as_slice());
                     }
                 }
             }
@@ -878,7 +878,8 @@ pub fn temporary_scope(tcx: &ty::ctxt,
             r
         }
         None => {
-            tcx.sess.bug(format!("no temporary scope available for expr {}", id))
+            tcx.sess.bug(format!("no temporary scope available for expr {}",
+                                 id).as_slice())
         }
     }
 }
index 80d35d88b2137b5e983e710d40e035c8e145c376..c804cb77fb29d0e8201195e4bc609e2a45b21eb0 100644 (file)
@@ -205,7 +205,7 @@ pub fn store_environment<'a>(
 
         if ccx.sess().asm_comments() {
             add_comment(bcx, format!("Copy {} into closure",
-                                  bv.to_str(ccx)));
+                                     bv.to_str(ccx)).as_slice());
         }
 
         let bound_data = GEPi(bcx, llbox, [0u, abi::box_field_body, i]);
@@ -386,8 +386,9 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
         ast::DefVariant(_, did, _) | ast::DefStruct(did) => did,
         _ => {
             ccx.sess().bug(format!("get_wrapper_for_bare_fn: \
-                                    expected a statically resolved fn, got {:?}",
-                                    def));
+                                    expected a statically resolved fn, got \
+                                    {:?}",
+                                    def).as_slice());
         }
     };
 
@@ -405,7 +406,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
         _ => {
             ccx.sess().bug(format!("get_wrapper_for_bare_fn: \
                                     expected a closure ty, got {}",
-                                    closure_ty.repr(tcx)));
+                                    closure_ty.repr(tcx)).as_slice());
         }
     };
 
index 75015bd2d9d2b53f0d0fdaffa28baf6be98fbc10..a7bce0019f15be06a6d560967686b1170671b7c5 100644 (file)
@@ -108,7 +108,7 @@ pub fn gensym_name(name: &str) -> PathElem {
     let num = token::gensym(name);
     // use one colon which will get translated to a period by the mangler, and
     // we're guaranteed that `num` is globally unique for this crate.
-    PathName(token::gensym(format!("{}:{}", name, num)))
+    PathName(token::gensym(format!("{}:{}", name, num).as_slice()))
 }
 
 pub struct tydesc_info {
@@ -459,7 +459,7 @@ pub fn def(&self, nid: ast::NodeId) -> ast::Def {
             Some(&v) => v,
             None => {
                 self.tcx().sess.bug(format!(
-                    "no def associated with node id {:?}", nid));
+                    "no def associated with node id {:?}", nid).as_slice());
             }
         }
     }
@@ -747,9 +747,10 @@ pub fn node_id_substs(bcx: &Block,
 
     if !substs.tps.iter().all(|t| !ty::type_needs_infer(*t)) {
         bcx.sess().bug(
-            format!("type parameters for node {:?} include inference types: {}",
+            format!("type parameters for node {:?} include inference types: \
+                     {}",
                     node,
-                    substs.repr(bcx.tcx())));
+                    substs.repr(bcx.tcx())).as_slice());
     }
 
     substs.substp(tcx, bcx.fcx.param_substs)
@@ -816,7 +817,7 @@ pub fn resolve_vtable_under_param_substs(tcx: &ty::ctxt,
                 _ => {
                     tcx.sess.bug(format!(
                         "resolve_vtable_under_param_substs: asked to lookup \
-                         but no vtables in the fn_ctxt!"))
+                         but no vtables in the fn_ctxt!").as_slice())
                 }
             }
         }
@@ -870,8 +871,8 @@ pub fn langcall(bcx: &Block,
         Err(s) => {
             let msg = format!("{} {}", msg, s);
             match span {
-                Some(span) => { bcx.tcx().sess.span_fatal(span, msg); }
-                None => { bcx.tcx().sess.fatal(msg); }
+                Some(span) => bcx.tcx().sess.span_fatal(span, msg.as_slice()),
+                None => bcx.tcx().sess.fatal(msg.as_slice()),
             }
         }
     }
index b5ab0a391f3b176fa8dda9bdb39ede7c9d739910..8b43e99b6ac6d47c1eac313bef993ecaadce291d 100644 (file)
@@ -55,8 +55,9 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit)
                     C_integral(Type::uint_from_ty(cx, t), i as u64, false)
                 }
                 _ => cx.sess().span_bug(lit.span,
-                        format!("integer literal has type {} (expected int or uint)",
-                                ty_to_str(cx.tcx(), lit_int_ty)))
+                        format!("integer literal has type {} (expected int \
+                                 or uint)",
+                                ty_to_str(cx.tcx(), lit_int_ty)).as_slice())
             }
         }
         ast::LitFloat(ref fs, t) => {
@@ -150,14 +151,14 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
                 }
                 _ => {
                     cx.sess().bug(format!("unexpected dereferenceable type {}",
-                                          ty_to_str(cx.tcx(), t)))
+                                          ty_to_str(cx.tcx(), t)).as_slice())
                 }
             };
             (dv, mt.ty)
         }
         None => {
             cx.sess().bug(format!("can't dereference const of type {}",
-                                  ty_to_str(cx.tcx(), t)))
+                                  ty_to_str(cx.tcx(), t)).as_slice())
         }
     }
 }
@@ -206,7 +207,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef
                     cx.sess()
                       .span_bug(e.span,
                                 format!("unexpected static function: {:?}",
-                                        store))
+                                        store).as_slice())
                 }
                 ty::AutoObject(..) => {
                     cx.sess()
@@ -256,11 +257,11 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef
                                     }
                                 }
                                 _ => {
-                                    cx.sess().span_bug(e.span,
-                                                       format!("unimplemented \
-                                                                const autoref \
-                                                                {:?}",
-                                                               autoref))
+                                    cx.sess()
+                                      .span_bug(e.span,
+                                                format!("unimplemented const \
+                                                         autoref {:?}",
+                                                        autoref).as_slice())
                                 }
                             }
                         }
@@ -281,7 +282,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef
         }
         cx.sess().bug(format!("const {} of type {} has size {} instead of {}",
                          e.repr(cx.tcx()), ty_to_str(cx.tcx(), ety),
-                         csize, tsize));
+                         csize, tsize).as_slice());
     }
     (llconst, inlineable)
 }
index 3b3852b3f45b12bbafe30b9976be2c06548f8c54..419b4f1e110a2944f750e7f36718824f5ba40286 100644 (file)
@@ -165,7 +165,7 @@ pub fn trans_if<'a>(bcx: &'a Block<'a>,
     }
 
     let name = format!("then-block-{}-", thn.id);
-    let then_bcx_in = bcx.fcx.new_id_block(name, thn.id);
+    let then_bcx_in = bcx.fcx.new_id_block(name.as_slice(), thn.id);
     let then_bcx_out = trans_block(then_bcx_in, thn, dest);
     debuginfo::clear_source_location(bcx.fcx);
 
@@ -287,7 +287,8 @@ pub fn trans_break_cont<'a>(bcx: &'a Block<'a>,
             match bcx.tcx().def_map.borrow().find(&expr_id) {
                 Some(&ast::DefLabel(loop_id)) => loop_id,
                 ref r => {
-                    bcx.tcx().sess.bug(format!("{:?} in def-map for label", r))
+                    bcx.tcx().sess.bug(format!("{:?} in def-map for label",
+                                               r).as_slice())
                 }
             }
         }
index ff43e4f9abb4c181bfea5ccbd942d6a9c2ed95de..48b429c6976c2bd89753e032ccd6702be96bc144 100644 (file)
@@ -317,16 +317,21 @@ pub fn create_global_var_metadata(cx: &CrateContext,
         ast_map::NodeItem(item) => {
             match item.node {
                 ast::ItemStatic(..) => (item.ident, item.span),
-                _ => cx.sess().span_bug(item.span,
-                                        format!("debuginfo::create_global_var_metadata() -
-                                                Captured var-id refers to unexpected ast_item
-                                                variant: {:?}",
-                                                var_item))
+                _ => {
+                    cx.sess()
+                      .span_bug(item.span,
+                                format!("debuginfo::\
+                                         create_global_var_metadata() -
+                                         Captured var-id refers to \
+                                         unexpected ast_item variant: {:?}",
+                                        var_item).as_slice())
+                }
             }
         },
-        _ => cx.sess().bug(format!("debuginfo::create_global_var_metadata() - Captured var-id \
-                                   refers to unexpected ast_map variant: {:?}",
-                                   var_item))
+        _ => cx.sess().bug(format!("debuginfo::create_global_var_metadata() \
+                                    - Captured var-id refers to unexpected \
+                                    ast_map variant: {:?}",
+                                   var_item).as_slice())
     };
 
     let filename = span_start(cx, span).file.name.clone();
@@ -340,7 +345,8 @@ pub fn create_global_var_metadata(cx: &CrateContext,
 
     let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id));
     let var_name = token::get_ident(ident).get().to_str();
-    let linkage_name = namespace_node.mangled_name_of_contained_item(var_name);
+    let linkage_name =
+        namespace_node.mangled_name_of_contained_item(var_name.as_slice());
     let var_scope = namespace_node.scope;
 
     var_name.as_slice().with_c_str(|var_name| {
@@ -380,7 +386,7 @@ pub fn create_local_var_metadata(bcx: &Block, local: &ast::Local) {
             None => {
                 bcx.sess().span_bug(span,
                     format!("no entry in lllocals table for {:?}",
-                            node_id));
+                            node_id).as_slice());
             }
         };
 
@@ -430,13 +436,17 @@ pub fn create_captured_var_metadata(bcx: &Block,
                                 "debuginfo::create_captured_var_metadata() - \
                                  Captured var-id refers to unexpected \
                                  ast_map variant: {:?}",
-                                 ast_item));
+                                 ast_item).as_slice());
                 }
             }
         }
         _ => {
-            cx.sess().span_bug(span, format!("debuginfo::create_captured_var_metadata() - \
-                Captured var-id refers to unexpected ast_map variant: {:?}", ast_item));
+            cx.sess()
+              .span_bug(span,
+                        format!("debuginfo::create_captured_var_metadata() - \
+                                 Captured var-id refers to unexpected \
+                                 ast_map variant: {:?}",
+                                ast_item).as_slice());
         }
     };
 
@@ -519,7 +529,7 @@ pub fn create_argument_metadata(bcx: &Block, arg: &ast::Arg) {
             None => {
                 bcx.sess().span_bug(span,
                     format!("no entry in llargs table for {:?}",
-                            node_id));
+                            node_id).as_slice());
             }
         };
 
@@ -653,7 +663,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
                 ast::ExprFnBlock(fn_decl, top_level_block) |
                 ast::ExprProc(fn_decl, top_level_block) => {
                     let name = format!("fn{}", token::gensym("fn"));
-                    let name = token::str_to_ident(name);
+                    let name = token::str_to_ident(name.as_slice());
                     (name, fn_decl,
                         // This is not quite right. It should actually inherit the generics of the
                         // enclosing function.
@@ -681,7 +691,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
                     cx.sess()
                       .bug(format!("create_function_debug_context: \
                                     unexpected sort of node: {:?}",
-                                    fnitem))
+                                    fnitem).as_slice())
                 }
             }
         }
@@ -691,7 +701,8 @@ pub fn create_function_debug_context(cx: &CrateContext,
             return FunctionDebugContext { repr: FunctionWithoutDebugInfo };
         }
         _ => cx.sess().bug(format!("create_function_debug_context: \
-                                    unexpected sort of node: {:?}", fnitem))
+                                    unexpected sort of node: {:?}",
+                                   fnitem).as_slice())
     };
 
     // This can be the case for functions inlined from another crate
@@ -1124,7 +1135,8 @@ fn scope_metadata(fcx: &FunctionContext,
             let node = fcx.ccx.tcx.map.get(node_id);
 
             fcx.ccx.sess().span_bug(span,
-                format!("debuginfo: Could not find scope info for node {:?}", node));
+                format!("debuginfo: Could not find scope info for node {:?}",
+                        node).as_slice());
         }
     }
 }
@@ -1499,14 +1511,17 @@ fn describe_enum_variant(cx: &CrateContext,
     // Get the argument names from the enum variant info
     let mut arg_names: Vec<_> = match variant_info.arg_names {
         Some(ref names) => {
-            names.iter().map(|ident| token::get_ident(*ident).get().to_str()).collect()
+            names.iter()
+                 .map(|ident| {
+                     token::get_ident(*ident).get().to_str().into_strbuf()
+                 }).collect()
         }
-        None => variant_info.args.iter().map(|_| "".to_owned()).collect()
+        None => variant_info.args.iter().map(|_| "".to_strbuf()).collect()
     };
 
     // If this is not a univariant enum, there is also the (unnamed) discriminant field
     if discriminant_type_metadata.is_some() {
-        arg_names.insert(0, "".to_owned());
+        arg_names.insert(0, "".to_strbuf());
     }
 
     // Build an array of (field name, field type) pairs to be captured in the factory closure.
@@ -1861,7 +1876,7 @@ fn boxed_type_metadata(cx: &CrateContext,
                     -> DICompositeType {
     let box_type_name = match content_type_name {
         Some(content_type_name) => format!("Boxed<{}>", content_type_name),
-        None                    => "BoxedType".to_owned()
+        None                    => "BoxedType".to_strbuf()
     };
 
     let box_llvm_type = Type::at_box(cx, content_llvm_type);
@@ -1913,7 +1928,7 @@ fn boxed_type_metadata(cx: &CrateContext,
     return composite_type_metadata(
         cx,
         box_llvm_type,
-        box_type_name,
+        box_type_name.as_slice(),
         member_descriptions,
         file_metadata,
         file_metadata,
@@ -1971,7 +1986,9 @@ fn vec_metadata(cx: &CrateContext,
     let (element_size, element_align) = size_and_align_of(cx, element_llvm_type);
 
     let vec_llvm_type = Type::vec(cx, &element_llvm_type);
-    let vec_type_name: &str = format!("[{}]", ppaux::ty_to_str(cx.tcx(), element_type));
+    let vec_type_name = format!("[{}]",
+                                ppaux::ty_to_str(cx.tcx(), element_type));
+    let vec_type_name = vec_type_name.as_slice();
 
     let member_llvm_types = vec_llvm_type.field_types();
 
@@ -2254,7 +2271,11 @@ fn create_pointer_to_box_metadata(cx: &CrateContext,
                                    elements.as_slice(),
                                    usage_site_span).finalize(cx)
         }
-        _ => cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {:?}", sty))
+        _ => {
+            cx.sess().bug(format!("debuginfo: unexpected type in \
+                                   type_metadata: {:?}",
+                                  sty).as_slice())
+        }
     };
 
     debug_context(cx).created_types.borrow_mut().insert(cache_id, type_metadata);
@@ -2852,13 +2873,13 @@ fn fill_nested(node: &NamespaceTreeNode, output: &mut StrBuf) {
                 None => {}
             }
             let string = token::get_name(node.name);
-            output.push_str(format!("{}", string.get().len()));
+            output.push_str(format!("{}", string.get().len()).as_slice());
             output.push_str(string.get());
         }
 
         let mut name = StrBuf::from_str("_ZN");
         fill_nested(self, &mut name);
-        name.push_str(format!("{}", item_name.len()));
+        name.push_str(format!("{}", item_name.len()).as_slice());
         name.push_str(item_name);
         name.push_char('E');
         name
@@ -2941,7 +2962,8 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
             Some(node) => node,
             None => {
                 cx.sess().bug(format!("debuginfo::namespace_for_item(): \
-                    path too short for {:?}", def_id));
+                                       path too short for {:?}",
+                                      def_id).as_slice());
             }
         }
     })
index bd25acad21d4d0cc30257eada8030cf8518515b7..024d47ac0ef0a635aca7570662f66bde7bbd6185 100644 (file)
@@ -421,8 +421,8 @@ fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>,
             bcx.tcx().sess.span_bug(
                 expr.span,
                 format!("trans_rvalue_datum_unadjusted reached \
-                      fall-through case: {:?}",
-                     expr.node));
+                         fall-through case: {:?}",
+                        expr.node).as_slice());
         }
     }
 }
@@ -635,8 +635,8 @@ fn trans_rvalue_stmt_unadjusted<'a>(bcx: &'a Block<'a>,
             bcx.tcx().sess.span_bug(
                 expr.span,
                 format!("trans_rvalue_stmt_unadjusted reached \
-                      fall-through case: {:?}",
-                     expr.node));
+                         fall-through case: {:?}",
+                        expr.node).as_slice());
         }
     }
 }
@@ -765,8 +765,9 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
         _ => {
             bcx.tcx().sess.span_bug(
                 expr.span,
-                format!("trans_rvalue_dps_unadjusted reached fall-through case: {:?}",
-                     expr.node));
+                format!("trans_rvalue_dps_unadjusted reached fall-through \
+                         case: {:?}",
+                        expr.node).as_slice());
         }
     }
 }
@@ -815,7 +816,7 @@ fn trans_def_dps_unadjusted<'a>(
         _ => {
             bcx.tcx().sess.span_bug(ref_expr.span, format!(
                 "Non-DPS def {:?} referened by {}",
-                def, bcx.node_id_to_str(ref_expr.id)));
+                def, bcx.node_id_to_str(ref_expr.id)).as_slice());
         }
     }
 }
@@ -839,7 +840,7 @@ fn trans_def_fn_unadjusted<'a>(bcx: &'a Block<'a>,
             bcx.tcx().sess.span_bug(ref_expr.span, format!(
                     "trans_def_fn_unadjusted invoked on: {:?} for {}",
                     def,
-                    ref_expr.repr(bcx.tcx())));
+                    ref_expr.repr(bcx.tcx())).as_slice());
         }
     };
 
@@ -865,7 +866,8 @@ pub fn trans_local_var<'a>(bcx: &'a Block<'a>,
                 Some(&val) => Datum(val, local_ty, Lvalue),
                 None => {
                     bcx.sess().bug(format!(
-                        "trans_local_var: no llval for upvar {:?} found", nid));
+                        "trans_local_var: no llval for upvar {:?} found",
+                        nid).as_slice());
                 }
             }
         }
@@ -877,7 +879,8 @@ pub fn trans_local_var<'a>(bcx: &'a Block<'a>,
         }
         _ => {
             bcx.sess().unimpl(format!(
-                "unsupported def type in trans_local_var: {:?}", def));
+                "unsupported def type in trans_local_var: {:?}",
+                def).as_slice());
         }
     };
 
@@ -889,7 +892,8 @@ fn take_local<'a>(bcx: &'a Block<'a>,
             Some(&v) => v,
             None => {
                 bcx.sess().bug(format!(
-                    "trans_local_var: no datum for local/arg {:?} found", nid));
+                    "trans_local_var: no datum for local/arg {:?} found",
+                    nid).as_slice());
             }
         };
         debug!("take_local(nid={:?}, v={}, ty={})",
@@ -922,7 +926,7 @@ pub fn with_field_tys<R>(tcx: &ty::ctxt,
                     tcx.sess.bug(format!(
                         "cannot get field types from the enum type {} \
                          without a node ID",
-                        ty.repr(tcx)));
+                        ty.repr(tcx)).as_slice());
                 }
                 Some(node_id) => {
                     let def = tcx.def_map.borrow().get_copy(&node_id);
@@ -947,7 +951,7 @@ pub fn with_field_tys<R>(tcx: &ty::ctxt,
         _ => {
             tcx.sess.bug(format!(
                 "cannot get field types from the type {}",
-                ty.repr(tcx)));
+                ty.repr(tcx)).as_slice());
         }
     }
 }
@@ -1586,16 +1590,22 @@ fn trans_imm_cast<'a>(bcx: &'a Block<'a>,
                                           val_ty(lldiscrim_a),
                                           lldiscrim_a, true),
                 cast_float => SIToFP(bcx, lldiscrim_a, ll_t_out),
-                _ => ccx.sess().bug(format!("translating unsupported cast: \
+                _ => {
+                    ccx.sess().bug(format!("translating unsupported cast: \
                                             {} ({:?}) -> {} ({:?})",
-                                            t_in.repr(bcx.tcx()), k_in,
-                                            t_out.repr(bcx.tcx()), k_out))
+                                            t_in.repr(bcx.tcx()),
+                                            k_in,
+                                            t_out.repr(bcx.tcx()),
+                                            k_out).as_slice())
+                }
             }
         }
         _ => ccx.sess().bug(format!("translating unsupported cast: \
                                     {} ({:?}) -> {} ({:?})",
-                                    t_in.repr(bcx.tcx()), k_in,
-                                    t_out.repr(bcx.tcx()), k_out))
+                                    t_in.repr(bcx.tcx()),
+                                    k_in,
+                                    t_out.repr(bcx.tcx()),
+                                    k_out).as_slice())
     };
     return immediate_rvalue_bcx(bcx, newval, t_out).to_expr_datumblock();
 }
@@ -1757,7 +1767,7 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
             bcx.tcx().sess.span_bug(
                 expr.span,
                 format!("deref invoked on expr of illegal type {}",
-                        datum.ty.repr(bcx.tcx())));
+                        datum.ty.repr(bcx.tcx())).as_slice());
         }
     };
 
index fb6aff0e26ed1d7ae27dfd1a63199d43d0d20033..e08ab33808ac95afcca84df0b8b2e8a61b6d095d 100644 (file)
@@ -81,13 +81,12 @@ pub fn llvm_calling_convention(ccx: &CrateContext,
         match abi {
             RustIntrinsic => {
                 // Intrinsics are emitted by monomorphic fn
-                ccx.sess().bug(format!("asked to register intrinsic fn"));
+                ccx.sess().bug("asked to register intrinsic fn");
             }
 
             Rust => {
                 // FIXME(#3678) Implement linking to foreign fns with Rust ABI
-                ccx.sess().unimpl(
-                    format!("foreign functions with Rust ABI"));
+                ccx.sess().unimpl("foreign functions with Rust ABI");
             }
 
             // It's the ABI's job to select this, not us.
@@ -164,7 +163,8 @@ pub fn register_static(ccx: &CrateContext,
                 });
                 lib::llvm::SetLinkage(g1, linkage);
 
-                let real_name = "_rust_extern_with_linkage_" + ident.get();
+                let mut real_name = "_rust_extern_with_linkage_".to_strbuf();
+                real_name.push_str(ident.get());
                 let g2 = real_name.with_c_str(|buf| {
                     llvm::LLVMAddGlobal(ccx.llmod, llty.to_ref(), buf)
                 });
@@ -202,14 +202,14 @@ pub fn register_foreign_item_fn(ccx: &CrateContext, abi: Abi, fty: ty::t,
                 Some(s) => {
                     ccx.sess().span_fatal(s,
                         format!("ABI `{}` has no suitable calling convention \
-                              for target architecture",
-                              abi.user_string(ccx.tcx())))
+                                 for target architecture",
+                                abi.user_string(ccx.tcx())).as_slice())
                 }
                 None => {
                     ccx.sess().fatal(
                         format!("ABI `{}` has no suitable calling convention \
-                              for target architecture",
-                              abi.user_string(ccx.tcx())))
+                                 for target architecture",
+                                abi.user_string(ccx.tcx())).as_slice())
                 }
             }
         }
@@ -370,8 +370,8 @@ pub fn trans_native_call<'a>(
             // FIXME(#8357) We really ought to report a span here
             ccx.sess().fatal(
                 format!("ABI string `{}` has no suitable ABI \
-                        for target architecture",
-                        fn_abi.user_string(ccx.tcx())));
+                         for target architecture",
+                         fn_abi.user_string(ccx.tcx())).as_slice());
         }
     };
 
@@ -555,9 +555,9 @@ fn build_rust_fn(ccx: &CrateContext,
             }
             _ => {
                 ccx.sess().bug(format!("build_rust_fn: extern fn {} has ty {}, \
-                                       expected a bare fn ty",
+                                        expected a bare fn ty",
                                        ccx.tcx.map.path_to_str(id),
-                                       t.repr(tcx)));
+                                       t.repr(tcx)).as_slice());
             }
         };
 
index b1b684ca3713aa9c7e3a404d5eaa1830ffce6614..c103a44aa754363aad881a381247ffad68050c42 100644 (file)
@@ -454,7 +454,10 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> tydesc_info {
 fn declare_generic_glue(ccx: &CrateContext, t: ty::t, llfnty: Type,
                         name: &str) -> ValueRef {
     let _icx = push_ctxt("declare_generic_glue");
-    let fn_nm = mangle_internal_name_by_type_and_seq(ccx, t, "glue_".to_owned() + name);
+    let fn_nm = mangle_internal_name_by_type_and_seq(
+        ccx,
+        t,
+        format!("glue_{}", name).as_slice());
     debug!("{} is for type {}", fn_nm, ppaux::ty_to_str(ccx.tcx(), t));
     let llfn = decl_cdecl_fn(ccx.llmod,
                              fn_nm.as_slice(),
index cd28d314772127d158b06e7cca1e6043c71b3866..aeb7a4641c08c60f4405e727174053a58da0b903 100644 (file)
@@ -396,7 +396,7 @@ fn count_zeros_intrinsic(bcx: &Block, name: &'static str) {
                             intype = ty_to_str(ccx.tcx(), in_type),
                             insize = in_type_size as uint,
                             outtype = ty_to_str(ccx.tcx(), out_type),
-                            outsize = out_type_size as uint));
+                            outsize = out_type_size as uint).as_slice());
             }
 
             if !return_type_is_void(ccx, out_type) {
index 861caa62515b517b0dcbe6cac2cc6f23be6145eb..3076a19228c39dc2acf04a79dbca156b3818c204 100644 (file)
@@ -205,7 +205,8 @@ pub fn monomorphic_fn(ccx: &CrateContext,
         hash_id.hash(&mut state);
         mono_ty.hash(&mut state);
 
-        exported_name(path, format!("h{}", state.result()),
+        exported_name(path,
+                      format!("h{}", state.result()).as_slice(),
                       ccx.link_meta.crateid.version_or_default())
     });
     debug!("monomorphize_fn mangled to {}", s);
@@ -287,7 +288,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
                 }
                 _ => {
                     ccx.sess().bug(format!("can't monomorphize a {:?}",
-                                           map_node))
+                                           map_node).as_slice())
                 }
             }
         }
@@ -311,7 +312,8 @@ pub fn monomorphic_fn(ccx: &CrateContext,
         ast_map::NodeBlock(..) |
         ast_map::NodePat(..) |
         ast_map::NodeLocal(..) => {
-            ccx.sess().bug(format!("can't monomorphize a {:?}", map_node))
+            ccx.sess().bug(format!("can't monomorphize a {:?}",
+                                   map_node).as_slice())
         }
     };
 
index 206fc07cd864ec5da95506b4ec52c6b3fe4ced89..a65802d2c36ff1c498a9834632e1712093da5c5d 100644 (file)
@@ -87,7 +87,8 @@ pub fn c_mt(&mut self, mt: &ty::mt) -> Vec<ValueRef> {
     pub fn visit(&mut self, ty_name: &str, args: &[ValueRef]) {
         let fcx = self.bcx.fcx;
         let tcx = self.bcx.tcx();
-        let mth_idx = ty::method_idx(token::str_to_ident("visit_".to_owned() + ty_name),
+        let mth_idx = ty::method_idx(token::str_to_ident(format!(
+                        "visit_{}", ty_name).as_slice()),
                                      self.visitor_methods.as_slice()).expect(
                 format!("couldn't find visit method for {}", ty_name));
         let mth_ty =
@@ -116,9 +117,9 @@ pub fn bracketed(&mut self,
                      bracket_name: &str,
                      extra: &[ValueRef],
                      inner: |&mut Reflector|) {
-        self.visit("enter_" + bracket_name, extra);
+        self.visit(format!("enter_{}", bracket_name).as_slice(), extra);
         inner(self);
-        self.visit("leave_" + bracket_name, extra);
+        self.visit(format!("leave_{}", bracket_name).as_slice(), extra);
     }
 
     pub fn leaf(&mut self, name: &str) {
@@ -154,7 +155,7 @@ pub fn visit_ty(&mut self, t: ty::t) {
           ty::ty_vec(ref mt, Some(sz)) => {
               let extra = (vec!(self.c_uint(sz))).append(self.c_size_and_align(t).as_slice());
               let extra = extra.append(self.c_mt(mt).as_slice());
-              self.visit("evec_fixed".to_owned(), extra.as_slice())
+              self.visit("evec_fixed", extra.as_slice())
           }
           ty::ty_vec(..) | ty::ty_str => fail!("unexpected unsized type"),
           // Should remove mt from box and uniq.
@@ -170,9 +171,9 @@ pub fn visit_ty(&mut self, t: ty::t) {
                   ty::ty_vec(ref mt, None) => {
                       let extra = Vec::new();
                       let extra = extra.append(self.c_mt(mt).as_slice());
-                      self.visit("evec_uniq".to_owned(), extra.as_slice())
+                      self.visit("evec_uniq", extra.as_slice())
                   }
-                  ty::ty_str => self.visit("estr_uniq".to_owned(), &[]),
+                  ty::ty_str => self.visit("estr_uniq", &[]),
                   _ => {
                       let extra = self.c_mt(&ty::mt {
                           ty: typ,
@@ -191,9 +192,10 @@ pub fn visit_ty(&mut self, t: ty::t) {
                   ty::ty_vec(ref mt, None) => {
                       let (name, extra) = ("slice".to_owned(), Vec::new());
                       let extra = extra.append(self.c_mt(mt).as_slice());
-                      self.visit("evec_".to_owned() + name, extra.as_slice())
+                      self.visit(format!("evec_{}", name).as_slice(),
+                                 extra.as_slice())
                   }
-                  ty::ty_str => self.visit("estr_slice".to_owned(), &[]),
+                  ty::ty_str => self.visit("estr_slice", &[]),
                   _ => {
                       let extra = self.c_mt(mt);
                       self.visit("rptr", extra.as_slice())
index 9d13fa56e1e73a037303626c3452146c3e460531..ff485a9cf5dfb7996831f838cbc029b1a9dd6928 100644 (file)
@@ -155,7 +155,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
         ty::ty_self(_) | ty::ty_infer(..) | ty::ty_param(..) |
         ty::ty_err(..) | ty::ty_vec(_, None) | ty::ty_str => {
             cx.sess().bug(format!("fictitious type {:?} in sizing_type_of()",
-                                  ty::get(t).sty))
+                                  ty::get(t).sty).as_slice())
         }
     };
 
index 517be1bde2f3a980ecb45115a643cc3d789bbb40..6a7ad8f0bd9170e8677cd94d49d4084331639f2a 100644 (file)
@@ -2620,7 +2620,7 @@ pub fn node_id_to_trait_ref(cx: &ctxt, id: ast::NodeId) -> Rc<ty::TraitRef> {
         Some(t) => t.clone(),
         None => cx.sess.bug(
             format!("node_id_to_trait_ref: no trait ref for node `{}`",
-                cx.map.node_to_str(id)))
+                    cx.map.node_to_str(id)).as_slice())
     }
 }
 
@@ -2633,7 +2633,7 @@ pub fn node_id_to_type(cx: &ctxt, id: ast::NodeId) -> t {
        Some(t) => t,
        None => cx.sess.bug(
            format!("node_id_to_type: no type for node `{}`",
-               cx.map.node_to_str(id)))
+                   cx.map.node_to_str(id)).as_slice())
     }
 }
 
@@ -2717,7 +2717,8 @@ pub fn ty_region(tcx: &ctxt,
         ref s => {
             tcx.sess.span_bug(
                 span,
-                format!("ty_region() invoked on in appropriate ty: {:?}", s));
+                format!("ty_region() invoked on in appropriate ty: {:?}",
+                        s).as_slice());
         }
     }
 }
@@ -2774,11 +2775,12 @@ pub fn expr_span(cx: &ctxt, id: NodeId) -> Span {
         }
         Some(f) => {
             cx.sess.bug(format!("Node id {} is not an expr: {:?}",
-                                id, f));
+                                id,
+                                f).as_slice());
         }
         None => {
             cx.sess.bug(format!("Node id {} is not present \
-                                in the node map", id));
+                                in the node map", id).as_slice());
         }
     }
 }
@@ -2793,14 +2795,15 @@ pub fn local_var_name_str(cx: &ctxt, id: NodeId) -> InternedString {
                 _ => {
                     cx.sess.bug(
                         format!("Variable id {} maps to {:?}, not local",
-                                id, pat));
+                                id,
+                                pat).as_slice());
                 }
             }
         }
         r => {
-            cx.sess.bug(
-                format!("Variable id {} maps to {:?}, not local",
-                        id, r));
+            cx.sess.bug(format!("Variable id {} maps to {:?}, not local",
+                                id,
+                                r).as_slice());
         }
     }
 }
@@ -2832,7 +2835,7 @@ pub fn adjust_ty(cx: &ctxt,
                             cx.sess.bug(
                                 format!("add_env adjustment on non-bare-fn: \
                                          {:?}",
-                                        b));
+                                        b).as_slice());
                         }
                     }
                 }
@@ -2857,7 +2860,8 @@ pub fn adjust_ty(cx: &ctxt,
                                         format!("the {}th autoderef failed: \
                                                 {}",
                                                 i,
-                                                ty_to_str(cx, adjusted_ty)));
+                                                ty_to_str(cx, adjusted_ty))
+                                                          .as_slice());
                                 }
                             }
                         }
@@ -2923,7 +2927,8 @@ fn borrow_vec(cx: &ctxt,
                 _ => {
                     cx.sess.span_bug(
                         span,
-                        format!("borrow-vec associated with bad sty: {:?}", get(ty).sty));
+                        format!("borrow-vec associated with bad sty: {:?}",
+                                get(ty).sty).as_slice());
                 }
             },
             ty_vec(mt, Some(_)) => ty::mk_slice(cx, r, ty::mt {ty: mt.ty, mutbl: m}),
@@ -2931,7 +2936,8 @@ fn borrow_vec(cx: &ctxt,
             ref s => {
                 cx.sess.span_bug(
                     span,
-                    format!("borrow-vec associated with bad sty: {:?}", s));
+                    format!("borrow-vec associated with bad sty: {:?}",
+                            s).as_slice());
             }
         }
     }
@@ -2947,7 +2953,7 @@ fn borrow_obj(cx: &ctxt, span: Span, r: Region,
                 cx.sess.span_bug(
                     span,
                     format!("borrow-trait-obj associated with bad sty: {:?}",
-                         s));
+                            s).as_slice());
             }
         }
     }
@@ -2996,7 +3002,7 @@ pub fn resolve_expr(tcx: &ctxt, expr: &ast::Expr) -> ast::Def {
         Some(&def) => def,
         None => {
             tcx.sess.span_bug(expr.span, format!(
-                "no def-map entry for expr {:?}", expr.id));
+                "no def-map entry for expr {:?}", expr.id).as_slice());
         }
     }
 }
@@ -3070,9 +3076,11 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
                 ast::DefLocal(..) => LvalueExpr,
 
                 def => {
-                    tcx.sess.span_bug(expr.span, format!(
-                        "uncategorized def for expr {:?}: {:?}",
-                        expr.id, def));
+                    tcx.sess.span_bug(
+                        expr.span,
+                        format!("uncategorized def for expr {:?}: {:?}",
+                                expr.id,
+                                def).as_slice());
                 }
             }
         }
@@ -3193,7 +3201,7 @@ pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
         token::get_name(name),
         fields.iter()
               .map(|f| token::get_ident(f.ident).get().to_strbuf())
-              .collect::<Vec<StrBuf>>()));
+              .collect::<Vec<StrBuf>>()).as_slice());
 }
 
 pub fn method_idx(id: ast::Ident, meths: &[Rc<Method>]) -> Option<uint> {
@@ -3444,10 +3452,18 @@ pub fn provided_trait_methods(cx: &ctxt, id: ast::DefId) -> Vec<Rc<Method>> {
                         let (_, p) = ast_util::split_trait_methods(ms.as_slice());
                         p.iter().map(|m| method(cx, ast_util::local_def(m.id))).collect()
                     }
-                    _ => cx.sess.bug(format!("provided_trait_methods: `{}` is not a trait", id))
+                    _ => {
+                        cx.sess.bug(format!("provided_trait_methods: `{}` is \
+                                             not a trait",
+                                            id).as_slice())
+                    }
                 }
             }
-            _ => cx.sess.bug(format!("provided_trait_methods: `{}` is not a trait", id))
+            _ => {
+                cx.sess.bug(format!("provided_trait_methods: `{}` is not a \
+                                     trait",
+                                    id).as_slice())
+            }
         }
     } else {
         csearch::get_provided_trait_methods(cx, id)
@@ -3800,7 +3816,7 @@ pub fn enum_variants(cx: &ctxt, id: ast::DefId) -> Rc<Vec<Rc<VariantInfo>>> {
                                         cx.sess
                                           .span_err(e.span,
                                                     format!("expected constant: {}",
-                                                            *err));
+                                                            *err).as_slice());
                                     }
                                 },
                                 None => {}
@@ -3963,7 +3979,7 @@ fn each_super_struct(cx: &ctxt, mut did: ast::DefId, f: |ast::DefId|) {
             None => {
                 cx.sess.bug(
                     format!("ID not mapped to super-struct: {}",
-                        cx.map.node_to_str(did.node)));
+                            cx.map.node_to_str(did.node)).as_slice());
             }
         }
     }
@@ -3985,7 +4001,7 @@ pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
                 _ => {
                     cx.sess.bug(
                         format!("ID not mapped to struct fields: {}",
-                            cx.map.node_to_str(did.node)));
+                                cx.map.node_to_str(did.node)).as_slice());
                 }
             }
         });
index cb3e900af7dfe9fd3e165d3249c3b1b196eeef7f..9cc5d2d73ca1d71fc0e9cc0e199bceb24f84a1f7 100644 (file)
@@ -180,7 +180,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
                 format!("wrong number of lifetime parameters: \
                         expected {} but found {}",
                         expected_num_region_params,
-                        supplied_num_region_params));
+                        supplied_num_region_params).as_slice());
         }
 
         match anon_regions {
@@ -204,7 +204,9 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
         };
         this.tcx().sess.span_fatal(path.span,
             format!("wrong number of type arguments: {} {} but found {}",
-                expected, required_ty_param_count, supplied_ty_param_count));
+                    expected,
+                    required_ty_param_count,
+                    supplied_ty_param_count).as_slice());
     } else if supplied_ty_param_count > formal_ty_param_count {
         let expected = if required_ty_param_count < formal_ty_param_count {
             "expected at most"
@@ -213,7 +215,9 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
         };
         this.tcx().sess.span_fatal(path.span,
             format!("wrong number of type arguments: {} {} but found {}",
-                expected, formal_ty_param_count, supplied_ty_param_count));
+                    expected,
+                    formal_ty_param_count,
+                    supplied_ty_param_count).as_slice());
     }
 
     if supplied_ty_param_count > required_ty_param_count
@@ -317,8 +321,11 @@ pub fn ast_ty_to_prim_ty(tcx: &ty::ctxt, ast_ty: &ast::Ty) -> Option<ty::t> {
     match ast_ty.node {
         ast::TyPath(ref path, _, id) => {
             let a_def = match tcx.def_map.borrow().find(&id) {
-                None => tcx.sess.span_bug(
-                    ast_ty.span, format!("unbound path {}", path_to_str(path))),
+                None => {
+                    tcx.sess.span_bug(ast_ty.span,
+                                      format!("unbound path {}",
+                                              path_to_str(path)).as_slice())
+                }
                 Some(&d) => d
             };
             match a_def {
@@ -382,8 +389,13 @@ pub fn ast_ty_to_builtin_ty<AC:AstConv,
     match ast_ty.node {
         ast::TyPath(ref path, _, id) => {
             let a_def = match this.tcx().def_map.borrow().find(&id) {
-                None => this.tcx().sess.span_bug(
-                    ast_ty.span, format!("unbound path {}", path_to_str(path))),
+                None => {
+                    this.tcx()
+                        .sess
+                        .span_bug(ast_ty.span,
+                                  format!("unbound path {}",
+                                          path_to_str(path)).as_slice())
+                }
                 Some(&d) => d
             };
 
@@ -493,8 +505,11 @@ fn mk_pointer<AC:AstConv,
                         RPtr(r) => {
                             return ty::mk_str_slice(tcx, r, ast::MutImmutable);
                         }
-                        _ => tcx.sess.span_err(path.span,
-                                               format!("managed strings are not supported")),
+                        _ => {
+                            tcx.sess
+                               .span_err(path.span,
+                                         "managed strings are not supported")
+                        }
                     }
                 }
                 Some(&ast::DefTrait(trait_def_id)) => {
@@ -635,8 +650,12 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
             }
             ast::TyPath(ref path, ref bounds, id) => {
                 let a_def = match tcx.def_map.borrow().find(&id) {
-                    None => tcx.sess.span_bug(
-                        ast_ty.span, format!("unbound path {}", path_to_str(path))),
+                    None => {
+                        tcx.sess
+                           .span_bug(ast_ty.span,
+                                     format!("unbound path {}",
+                                             path_to_str(path)).as_slice())
+                    }
                     Some(&d) => d
                 };
                 // Kind bounds on path types are only supported for traits.
@@ -653,8 +672,10 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
                         let path_str = path_to_str(path);
                         tcx.sess.span_err(
                             ast_ty.span,
-                            format!("reference to trait `{name}` where a type is expected; \
-                                    try `Box<{name}>` or `&{name}`", name=path_str));
+                            format!("reference to trait `{name}` where a \
+                                     type is expected; try `Box<{name}>` or \
+                                     `&{name}`",
+                                    name=path_str).as_slice());
                         ty::mk_err()
                     }
                     ast::DefTy(did) | ast::DefStruct(did) => {
@@ -675,14 +696,16 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
                     ast::DefMod(id) => {
                         tcx.sess.span_fatal(ast_ty.span,
                             format!("found module name used as a type: {}",
-                                    tcx.map.node_to_str(id.node)));
+                                    tcx.map.node_to_str(id.node)).as_slice());
                     }
                     ast::DefPrimTy(_) => {
                         fail!("DefPrimTy arm missed in previous ast_ty_to_prim_ty call");
                     }
                     _ => {
                         tcx.sess.span_fatal(ast_ty.span,
-                            format!("found value name used as a type: {:?}", a_def));
+                                            format!("found value name used \
+                                                     as a type: {:?}",
+                                                    a_def).as_slice());
                     }
                 }
             }
@@ -705,7 +728,9 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
                     Err(ref r) => {
                         tcx.sess.span_fatal(
                             ast_ty.span,
-                            format!("expected constant expr for vector length: {}", *r));
+                            format!("expected constant expr for vector \
+                                     length: {}",
+                                    *r).as_slice());
                     }
                 }
             }
@@ -897,8 +922,8 @@ fn conv_builtin_bounds(tcx: &ty::ctxt, ast_bounds: &Option<OwnedSlice<ast::TyPar
                         }
                         tcx.sess.span_fatal(
                             b.path.span,
-                            format!("only the builtin traits can be used \
-                                  as closure or object bounds"));
+                            "only the builtin traits can be used as closure \
+                             or object bounds");
                     }
                     ast::StaticRegionTyParamBound => {
                         builtin_bounds.add(ty::BoundStatic);
@@ -907,8 +932,8 @@ fn conv_builtin_bounds(tcx: &ty::ctxt, ast_bounds: &Option<OwnedSlice<ast::TyPar
                         if !tcx.sess.features.issue_5723_bootstrap.get() {
                             tcx.sess.span_err(
                                 span,
-                                format!("only the 'static lifetime is \
-                                         accepted here."));
+                                "only the 'static lifetime is accepted \
+                                 here.");
                         }
                     }
                 }
index 740539cbddd7d17a0c87b7ea7fbb192c3314f8fb..6e164d07015d2cd104111e9b4a0d795d9c392259 100644 (file)
@@ -263,7 +263,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
                          npat = subpats_len,
                          kind = kind_name,
                          narg = arg_len);
-            tcx.sess.span_err(pat.span, s);
+            tcx.sess.span_err(pat.span, s.as_slice());
             error_happened = true;
         }
 
@@ -280,7 +280,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
                                    {npat, plural, =1{# field} other{# fields}}, \
                                    but the corresponding {kind} has no fields",
                                npat = subpats_len,
-                               kind = kind_name));
+                               kind = kind_name).as_slice());
         error_happened = true;
     }
 
@@ -324,7 +324,7 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
             Some(&(_, true)) => {
                 tcx.sess.span_err(span,
                     format!("field `{}` bound twice in pattern",
-                            token::get_ident(field.ident)));
+                            token::get_ident(field.ident)).as_slice());
             }
             Some(&(index, ref mut used)) => {
                 *used = true;
@@ -343,8 +343,8 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
                 check_pat(pcx, field.pat, ty::mk_err());
                 tcx.sess.span_err(span,
                     format!("struct `{}` does not have a field named `{}`",
-                         name,
-                         token::get_ident(field.ident)));
+                            name,
+                            token::get_ident(field.ident)).as_slice());
             }
         }
     }
@@ -356,9 +356,10 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
                 continue;
             }
 
-            tcx.sess.span_err(span,
-                              format!("pattern does not mention field `{}`",
-                                  token::get_name(field.name)));
+            tcx.sess
+               .span_err(span,
+                         format!("pattern does not mention field `{}`",
+                                 token::get_name(field.name)).as_slice());
         }
     }
 }
@@ -381,10 +382,12 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::NodeId, span: Span,
         }
         Some(&ast::DefStruct(..)) | Some(&ast::DefVariant(..)) => {
             let name = pprust::path_to_str(path);
-            tcx.sess.span_err(span,
-                              format!("mismatched types: expected `{}` but found `{}`",
-                                   fcx.infcx().ty_to_str(expected),
-                                   name));
+            tcx.sess
+               .span_err(span,
+                         format!("mismatched types: expected `{}` but found \
+                                  `{}`",
+                                 fcx.infcx().ty_to_str(expected),
+                                 name).as_slice());
         }
         _ => {
             tcx.sess.span_bug(span, "resolve didn't write in struct ID");
@@ -421,9 +424,9 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt,
             let name = pprust::path_to_str(path);
             tcx.sess.span_err(span,
                               format!("mismatched types: expected `{}` but \
-                                    found `{}`",
-                                   fcx.infcx().ty_to_str(expected),
-                                   name));
+                                       found `{}`",
+                                      fcx.infcx().ty_to_str(expected),
+                                      name).as_slice());
         }
         _ => {
             tcx.sess.span_bug(span, "resolve didn't write in variant");
index 9e8edfccd5b5fd0358c38f83e1b65eb8a4f6efe8..d512de670bc80a79f1364a95719bbf1e76dcf96d 100644 (file)
@@ -284,7 +284,7 @@ fn construct_transformed_self_ty_for_object(
                 _ => {
                     tcx.sess.span_bug(span,
                         format!("'impossible' transformed_self_ty: {}",
-                                transformed_self_ty.repr(tcx)));
+                                transformed_self_ty.repr(tcx)).as_slice());
                 }
             }
         }
@@ -950,7 +950,7 @@ fn search_for_autoptrd_method(&self, self_ty: ty::t, autoderefs: uint)
 
             ty_infer(TyVar(_)) => {
                 self.bug(format!("unexpected type: {}",
-                              self.ty_to_str(self_ty)));
+                                 self.ty_to_str(self_ty)).as_slice());
             }
         }
     }
@@ -1235,9 +1235,10 @@ fn confirm_candidate(&self, rcvr_ty: ty::t, candidate: &Candidate)
                                 rcvr_ty, transformed_self_ty) {
             Ok(_) => {}
             Err(_) => {
-                self.bug(format!("{} was a subtype of {} but now is not?",
-                              self.ty_to_str(rcvr_ty),
-                              self.ty_to_str(transformed_self_ty)));
+                self.bug(format!(
+                        "{} was a subtype of {} but now is not?",
+                        self.ty_to_str(rcvr_ty),
+                        self.ty_to_str(transformed_self_ty)).as_slice());
             }
         }
 
@@ -1465,25 +1466,25 @@ fn report_static_candidate(&self, idx: uint, did: DefId) {
         self.tcx().sess.span_note(
             span,
             format!("candidate \\#{} is `{}`",
-                 idx+1u,
-                 ty::item_path_str(self.tcx(), did)));
+                    idx + 1u,
+                    ty::item_path_str(self.tcx(), did)).as_slice());
     }
 
     fn report_param_candidate(&self, idx: uint, did: DefId) {
         self.tcx().sess.span_note(
             self.span,
             format!("candidate \\#{} derives from the bound `{}`",
-                 idx+1u,
-                 ty::item_path_str(self.tcx(), did)));
+                    idx + 1u,
+                    ty::item_path_str(self.tcx(), did)).as_slice());
     }
 
     fn report_trait_candidate(&self, idx: uint, did: DefId) {
         self.tcx().sess.span_note(
             self.span,
             format!("candidate \\#{} derives from the type of the receiver, \
-                  which is the trait `{}`",
-                 idx+1u,
-                 ty::item_path_str(self.tcx(), did)));
+                     which is the trait `{}`",
+                    idx + 1u,
+                    ty::item_path_str(self.tcx(), did)).as_slice());
     }
 
     fn infcx(&'a self) -> &'a infer::InferCtxt<'a> {
index 820c5bd859ca2e4a57707b30d1c4ce709cd2e218..cc9bff899478aa978bd7cc3dc085ccd65bdf09be 100644 (file)
@@ -546,8 +546,11 @@ fn span_for_field(tcx: &ty::ctxt, field: &ty::field_ty, struct_id: ast::DefId) -
                 _ => false,
             }) {
                 Some(f) => f.span,
-                None => tcx.sess.bug(format!("Could not find field {}",
-                                             token::get_name(field.name))),
+                None => {
+                    tcx.sess
+                       .bug(format!("Could not find field {}",
+                                    token::get_name(field.name)).as_slice())
+                }
             }
         },
         _ => tcx.sess.bug("Field found outside of a struct?"),
@@ -569,8 +572,9 @@ fn check_for_field_shadowing(tcx: &ty::ctxt,
                 match super_fields.iter().find(|sf| f.name == sf.name) {
                     Some(prev_field) => {
                         tcx.sess.span_err(span_for_field(tcx, f, id),
-                            format!("field `{}` hides field declared in super-struct",
-                                    token::get_name(f.name)));
+                            format!("field `{}` hides field declared in \
+                                     super-struct",
+                                    token::get_name(f.name)).as_slice());
                         tcx.sess.span_note(span_for_field(tcx, prev_field, parent_id),
                             "previously declared here");
                     },
@@ -593,11 +597,13 @@ fn check_fields_sized(tcx: &ty::ctxt,
         if !ty::type_is_sized(tcx, t) {
             match f.node.kind {
                 ast::NamedField(ident, _) => {
-                    tcx.sess.span_err(f.span, format!("type `{}` is dynamically sized. \
-                                                       dynamically sized types may only \
-                                                       appear as the type of the final \
-                                                       field in a struct",
-                                                      token::get_ident(ident)));
+                    tcx.sess.span_err(
+                        f.span,
+                        format!("type `{}` is dynamically sized. \
+                                 dynamically sized types may only \
+                                 appear as the type of the final \
+                                 field in a struct",
+                                 token::get_ident(ident)).as_slice());
                 }
                 ast::UnnamedField(_) => {
                     tcx.sess.span_err(f.span, "dynamically sized type in field");
@@ -814,9 +820,10 @@ fn check_impl_methods_against_trait(ccx: &CrateCtxt,
             None => {
                 tcx.sess.span_err(
                     impl_method.span,
-                    format!("method `{}` is not a member of trait `{}`",
-                            token::get_ident(impl_method_ty.ident),
-                            pprust::path_to_str(&ast_trait_ref.path)));
+                    format!(
+                        "method `{}` is not a member of trait `{}`",
+                        token::get_ident(impl_method_ty.ident),
+                        pprust::path_to_str(&ast_trait_ref.path)).as_slice());
             }
         }
     }
@@ -842,7 +849,7 @@ fn check_impl_methods_against_trait(ccx: &CrateCtxt,
         tcx.sess.span_err(
             impl_span,
             format!("not all trait methods implemented, missing: {}",
-                    missing_methods.connect(", ")));
+                    missing_methods.connect(", ")).as_slice());
     }
 }
 
@@ -886,7 +893,8 @@ fn compare_impl_method(tcx: &ty::ctxt,
                 format!("method `{}` has a `{}` declaration in the impl, \
                         but not in the trait",
                         token::get_ident(trait_m.ident),
-                        pprust::explicit_self_to_str(impl_m.explicit_self)));
+                        pprust::explicit_self_to_str(
+                            impl_m.explicit_self)).as_slice());
             return;
         }
         (_, &ast::SelfStatic) => {
@@ -895,7 +903,8 @@ fn compare_impl_method(tcx: &ty::ctxt,
                 format!("method `{}` has a `{}` declaration in the trait, \
                         but not in the impl",
                         token::get_ident(trait_m.ident),
-                        pprust::explicit_self_to_str(trait_m.explicit_self)));
+                        pprust::explicit_self_to_str(
+                            trait_m.explicit_self)).as_slice());
             return;
         }
         _ => {
@@ -914,7 +923,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
                                                                  other{# type parameters}}",
                     method = token::get_ident(trait_m.ident),
                     nimpl = num_impl_m_type_params,
-                    ntrait = num_trait_m_type_params));
+                    ntrait = num_trait_m_type_params).as_slice());
         return;
     }
 
@@ -927,7 +936,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
                  method = token::get_ident(trait_m.ident),
                  nimpl = impl_m.fty.sig.inputs.len(),
                  trait = ty::item_path_str(tcx, trait_m.def_id),
-                 ntrait = trait_m.fty.sig.inputs.len()));
+                 ntrait = trait_m.fty.sig.inputs.len()).as_slice());
         return;
     }
 
@@ -950,7 +959,7 @@ trait = ty::item_path_str(tcx, trait_m.def_id),
                        in the trait declaration",
                        token::get_ident(trait_m.ident),
                        i,
-                       extra_bounds.user_string(tcx)));
+                       extra_bounds.user_string(tcx)).as_slice());
            return;
         }
 
@@ -971,7 +980,9 @@ trait = ty::item_path_str(tcx, trait_m.def_id),
                         method = token::get_ident(trait_m.ident),
                         typaram = i,
                         nimpl = impl_param_def.bounds.trait_bounds.len(),
-                        ntrait = trait_param_def.bounds.trait_bounds.len()));
+                        ntrait = trait_param_def.bounds
+                                                .trait_bounds
+                                                .len()).as_slice());
             return;
         }
     }
@@ -1040,7 +1051,7 @@ trait = ty::item_path_str(tcx, trait_m.def_id),
                 impl_m_span,
                 format!("method `{}` has an incompatible type for trait: {}",
                         token::get_ident(trait_m.ident),
-                        ty::type_err_to_str(tcx, terr)));
+                        ty::type_err_to_str(tcx, terr)).as_slice());
             ty::note_and_explain_type_err(tcx, terr);
         }
     }
@@ -1099,7 +1110,8 @@ pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {
             None => {
                 self.tcx().sess.span_bug(
                     span,
-                    format!("no type for local variable {:?}", nid));
+                    format!("no type for local variable {:?}",
+                            nid).as_slice());
             }
         }
     }
@@ -1173,7 +1185,7 @@ pub fn expr_ty(&self, ex: &ast::Expr) -> ty::t {
             Some(&t) => t,
             None => {
                 self.tcx().sess.bug(format!("no type for expr in fcx {}",
-                                            self.tag()));
+                                            self.tag()).as_slice());
             }
         }
     }
@@ -1185,7 +1197,7 @@ pub fn node_ty(&self, id: ast::NodeId) -> ty::t {
                 self.tcx().sess.bug(
                     format!("no type for node {}: {} in fcx {}",
                             id, self.tcx().map.node_to_str(id),
-                            self.tag()));
+                            self.tag()).as_slice());
             }
         }
     }
@@ -1197,7 +1209,7 @@ pub fn method_ty_substs(&self, id: ast::NodeId) -> ty::substs {
                 self.tcx().sess.bug(
                     format!("no method entry for node {}: {} in fcx {}",
                             id, self.tcx().map.node_to_str(id),
-                            self.tag()));
+                            self.tag()).as_slice());
             }
         }
     }
@@ -1350,7 +1362,7 @@ pub fn autoderef<T>(fcx: &FnCtxt, sp: Span, base_ty: ty::t,
     // We've reached the recursion limit, error gracefully.
     fcx.tcx().sess.span_err(sp,
         format!("reached the recursion limit while auto-dereferencing {}",
-                base_ty.repr(fcx.tcx())));
+                base_ty.repr(fcx.tcx())).as_slice());
     (ty::mk_err(), 0, None)
 }
 
@@ -1607,7 +1619,7 @@ fn check_type_parameter_positions_in_path(function_context: &FnCtxt,
                                        found {nsupplied, plural, =1{# lifetime parameter} \
                                                               other{# lifetime parameters}}",
                                       nexpected = trait_region_parameter_count,
-                                      nsupplied = supplied_region_parameter_count));
+                                      nsupplied = supplied_region_parameter_count).as_slice());
             }
 
             // Make sure the number of type parameters supplied on the trait
@@ -1638,7 +1650,8 @@ fn check_type_parameter_positions_in_path(function_context: &FnCtxt,
                             nexpected = required_ty_param_count,
                             nsupplied = supplied_ty_param_count)
                 };
-                function_context.tcx().sess.span_err(path.span, msg)
+                function_context.tcx().sess.span_err(path.span,
+                                                     msg.as_slice())
             } else if supplied_ty_param_count > formal_ty_param_count {
                 let msg = if required_ty_param_count < generics.type_param_defs().len() {
                     format!("the {trait_or_impl} referenced by this path needs at most \
@@ -1659,7 +1672,8 @@ fn check_type_parameter_positions_in_path(function_context: &FnCtxt,
                             nexpected = formal_ty_param_count,
                             nsupplied = supplied_ty_param_count)
                 };
-                function_context.tcx().sess.span_err(path.span, msg)
+                function_context.tcx().sess.span_err(path.span,
+                                                     msg.as_slice())
             }
         }
         _ => {
@@ -1727,9 +1741,8 @@ fn check_method_argument_types(
                     fty.sig.output
                 }
                 _ => {
-                    fcx.tcx().sess.span_bug(
-                        callee_expr.span,
-                        format!("method without bare fn type"));
+                    fcx.tcx().sess.span_bug(callee_expr.span,
+                                            "method without bare fn type");
                 }
             }
         }
@@ -1768,7 +1781,7 @@ fn check_argument_types(fcx: &FnCtxt,
                      nexpected = expected_arg_count,
                      nsupplied = supplied_arg_count);
 
-                tcx.sess.span_err(sp, msg);
+                tcx.sess.span_err(sp, msg.as_slice());
 
                 err_args(supplied_arg_count)
             }
@@ -1781,7 +1794,7 @@ fn check_argument_types(fcx: &FnCtxt,
                  nexpected = expected_arg_count,
                  nsupplied = supplied_arg_count);
 
-            tcx.sess.span_err(sp, msg);
+            tcx.sess.span_err(sp, msg.as_slice());
 
             err_args(supplied_arg_count)
         };
@@ -2484,7 +2497,8 @@ fn check_struct_or_variant_fields(fcx: &FnCtxt,
                     tcx.sess.span_err(
                         field.ident.span,
                         format!("field `{}` specified more than once",
-                            token::get_ident(field.ident.node)));
+                                token::get_ident(field.ident
+                                                      .node)).as_slice());
                     error_happened = true;
                 }
                 Some((field_id, false)) => {
@@ -2517,14 +2531,16 @@ fn check_struct_or_variant_fields(fcx: &FnCtxt,
                     let name = class_field.name;
                     let (_, seen) = *class_field_map.get(&name);
                     if !seen {
-                        missing_fields.push("`".to_owned() + token::get_name(name).get() + "`");
+                        missing_fields.push(
+                            format!("`{}`", token::get_name(name).get()))
                     }
                 }
 
                 tcx.sess.span_err(span,
-                    format!("missing {nfields, plural, =1{field} other{fields}}: {fields}",
-                            nfields = missing_fields.len(),
-                            fields = missing_fields.connect(", ")));
+                    format!(
+                        "missing {nfields, plural, =1{field} other{fields}}: {fields}",
+                        nfields = missing_fields.len(),
+                        fields = missing_fields.connect(", ")).as_slice());
              }
         }
 
@@ -3589,7 +3605,7 @@ pub fn check_representable(tcx: &ty::ctxt,
         tcx.sess.span_err(
           sp, format!("illegal recursive {} type; \
                        wrap the inner value in a box to make it representable",
-                      designation));
+                      designation).as_slice());
         return false
       }
       ty::Representable | ty::ContainsRecursive => (),
@@ -3614,10 +3630,12 @@ pub fn check_instantiable(tcx: &ty::ctxt,
                           -> bool {
     let item_ty = ty::node_id_to_type(tcx, item_id);
     if !ty::is_instantiable(tcx, item_ty) {
-        tcx.sess.span_err(sp, format!("this type cannot be instantiated \
-                  without an instance of itself; \
-                  consider using `Option<{}>`",
-                                   ppaux::ty_to_str(tcx, item_ty)));
+        tcx.sess
+           .span_err(sp,
+                     format!("this type cannot be instantiated without an \
+                              instance of itself; consider using \
+                              `Option<{}>`",
+                             ppaux::ty_to_str(tcx, item_ty)).as_slice());
         false
     } else {
         true
@@ -3670,11 +3688,16 @@ pub fn check_enum_variants_sized(ccx: &CrateCtxt,
                     // A struct value with an unsized final field is itself
                     // unsized and we must track this in the type system.
                     if !ty::type_is_sized(ccx.tcx, *t) {
-                        ccx.tcx.sess.span_err(args.get(i).ty.span,
-                                              format!("type `{}` is dynamically sized. \
-                                                       dynamically sized types may only \
-                                                       appear as the final type in a variant",
-                                                      ppaux::ty_to_str(ccx.tcx, *t)));
+                        ccx.tcx
+                           .sess
+                           .span_err(
+                               args.get(i).ty.span,
+                               format!("type `{}` is dynamically sized. \
+                                        dynamically sized types may only \
+                                        appear as the final type in a \
+                                        variant",
+                                       ppaux::ty_to_str(ccx.tcx,
+                                                        *t)).as_slice());
                     }
                 }
             },
@@ -3755,7 +3778,11 @@ fn do_check(ccx: &CrateCtxt,
                             ccx.tcx.sess.span_err(e.span, "expected signed integer constant");
                         }
                         Err(ref err) => {
-                            ccx.tcx.sess.span_err(e.span, format!("expected constant: {}", *err));
+                            ccx.tcx
+                               .sess
+                               .span_err(e.span,
+                                         format!("expected constant: {}",
+                                                 *err).as_slice());
                         }
                     }
                 },
@@ -3906,7 +3933,7 @@ pub fn instantiate_path(fcx: &FnCtxt,
                          found {nsupplied, plural, =1{# lifetime parameter} \
                                                 other{# lifetime parameters}}",
                         nexpected = num_expected_regions,
-                        nsupplied = num_supplied_regions));
+                        nsupplied = num_supplied_regions).as_slice());
         }
 
         fcx.infcx().region_vars_for_defs(span, tpt.generics.region_param_defs.as_slice())
@@ -3945,7 +3972,7 @@ pub fn instantiate_path(fcx: &FnCtxt,
         fcx.ccx.tcx.sess.span_err
             (span,
              format!("too many type parameters provided: {} {}, found {}",
-                  expected, user_ty_param_count, ty_substs_len));
+                  expected, user_ty_param_count, ty_substs_len).as_slice());
         (fcx.infcx().next_ty_vars(ty_param_count), regions)
     } else if ty_substs_len < user_ty_param_req {
         let expected = if user_ty_param_req < user_ty_param_count {
@@ -3953,10 +3980,12 @@ pub fn instantiate_path(fcx: &FnCtxt,
         } else {
             "expected"
         };
-        fcx.ccx.tcx.sess.span_err
-            (span,
-             format!("not enough type parameters provided: {} {}, found {}",
-                  expected, user_ty_param_req, ty_substs_len));
+        fcx.ccx.tcx.sess.span_err(
+            span,
+            format!("not enough type parameters provided: {} {}, found {}",
+                    expected,
+                    user_ty_param_req,
+                    ty_substs_len).as_slice());
         (fcx.infcx().next_ty_vars(ty_param_count), regions)
     } else {
         if ty_substs_len > user_ty_param_req
@@ -4128,8 +4157,9 @@ pub fn ast_expr_vstore_to_ty(fcx: &FnCtxt,
                     }
                 }
                 _ => {
-                    fcx.ccx.tcx.sess.span_bug(
-                        e.span, format!("vstore with unexpected contents"))
+                    fcx.ccx.tcx.sess.span_bug(e.span,
+                                              "vstore with unexpected \
+                                               contents")
                 }
             }
         }
@@ -4184,8 +4214,9 @@ pub fn check_bounds_are_used(ccx: &CrateCtxt,
     for (i, b) in tps_used.iter().enumerate() {
         if !*b {
             ccx.tcx.sess.span_err(
-                span, format!("type parameter `{}` is unused",
-                              token::get_ident(tps.get(i).ident)));
+                span,
+                format!("type parameter `{}` is unused",
+                        token::get_ident(tps.get(i).ident)).as_slice());
         }
     }
 }
@@ -4222,8 +4253,9 @@ fn param(ccx: &CrateCtxt, n: uint) -> ty::t {
             }
             op => {
                 tcx.sess.span_err(it.span,
-                                  format!("unrecognized atomic operation function: `{}`",
-                                       op));
+                                  format!("unrecognized atomic operation \
+                                           function: `{}`",
+                                          op).as_slice());
                 return;
             }
         }
@@ -4450,7 +4482,7 @@ fn param(ccx: &CrateCtxt, n: uint) -> ty::t {
             ref other => {
                 tcx.sess.span_err(it.span,
                                   format!("unrecognized intrinsic function: `{}`",
-                                       *other));
+                                          *other).as_slice());
                 return;
             }
         }
@@ -4468,9 +4500,11 @@ fn param(ccx: &CrateCtxt, n: uint) -> ty::t {
     let i_ty = ty::lookup_item_type(ccx.tcx, local_def(it.id));
     let i_n_tps = i_ty.generics.type_param_defs().len();
     if i_n_tps != n_tps {
-        tcx.sess.span_err(it.span, format!("intrinsic has wrong number \
-                                         of type parameters: found {}, \
-                                         expected {}", i_n_tps, n_tps));
+        tcx.sess.span_err(it.span,
+                          format!("intrinsic has wrong number of type \
+                                   parameters: found {}, expected {}",
+                                  i_n_tps,
+                                  n_tps).as_slice());
     } else {
         require_same_types(tcx,
                            None,
index d8da67fff7fa324e0596d282f37b3643d323d88e..34e8b5e169ff8f68c54a7566ba1ffeaad24d15ca 100644 (file)
@@ -183,7 +183,7 @@ fn region_of_def(fcx: &FnCtxt, def: ast::Def) -> ty::Region {
         }
         _ => {
             tcx.sess.bug(format!("unexpected def in region_of_def: {:?}",
-                              def))
+                                 def).as_slice())
         }
     }
 }
@@ -880,7 +880,7 @@ fn constrain_autoderefs(rcx: &mut Rcx,
                     ty::ty_rptr(r, ref m) => (m.mutbl, r),
                     _ => rcx.tcx().sess.span_bug(deref_expr.span,
                             format!("bad overloaded deref type {}",
-                                method.ty.repr(rcx.tcx())))
+                                    method.ty.repr(rcx.tcx())).as_slice())
                 };
                 {
                     let mc = mc::MemCategorizationContext::new(rcx);
@@ -1235,7 +1235,8 @@ fn link_region(rcx: &Rcx,
                                 rcx.tcx().sess.span_bug(
                                     span,
                                     format!("Illegal upvar id: {}",
-                                            upvar_id.repr(rcx.tcx())));
+                                            upvar_id.repr(
+                                                rcx.tcx())).as_slice());
                             }
                         }
                     }
index 04facc1426dba4e34e25a8f7593e8656a42721a1..5e67cb54ccc66eede8067cef4a99bfb51f7d6cf2 100644 (file)
@@ -154,7 +154,7 @@ fn lookup_vtables_for_param(vcx: &VtableContext,
                     format!("failed to find an implementation of \
                           trait {} for {}",
                          vcx.infcx.trait_ref_to_str(&*trait_ref),
-                         vcx.infcx.ty_to_str(ty)));
+                         vcx.infcx.ty_to_str(ty)).as_slice());
             }
         }
         true
@@ -206,9 +206,9 @@ fn relate_trait_refs(vcx: &VtableContext,
                 let tcx = vcx.tcx();
                 tcx.sess.span_err(span,
                     format!("expected {}, but found {} ({})",
-                         ppaux::trait_ref_to_str(tcx, &r_exp_trait_ref),
-                         ppaux::trait_ref_to_str(tcx, &r_act_trait_ref),
-                         ty::type_err_to_str(tcx, err)));
+                            ppaux::trait_ref_to_str(tcx, &r_exp_trait_ref),
+                            ppaux::trait_ref_to_str(tcx, &r_act_trait_ref),
+                            ty::type_err_to_str(tcx, err)).as_slice());
             }
         }
     }
@@ -491,9 +491,9 @@ fn fixup_ty(vcx: &VtableContext,
         Ok(new_type) => Some(new_type),
         Err(e) if !is_early => {
             tcx.sess.span_fatal(span,
-                format!("cannot determine a type \
-                      for this bounded type parameter: {}",
-                     fixup_err_to_str(e)))
+                format!("cannot determine a type for this bounded type \
+                         parameter: {}",
+                        fixup_err_to_str(e)).as_slice())
         }
         Err(_) => {
             None
@@ -550,8 +550,9 @@ fn mutability_allowed(a_mutbl: ast::Mutability,
               match (&ty::get(ty).sty, store) {
                   (&ty::ty_rptr(_, mt), ty::RegionTraitStore(_, mutbl))
                     if !mutability_allowed(mt.mutbl, mutbl) => {
-                      fcx.tcx().sess.span_err(ex.span,
-                                              format!("types differ in mutability"));
+                      fcx.tcx()
+                         .sess
+                         .span_err(ex.span, "types differ in mutability");
                   }
 
                   (&ty::ty_uniq(..), ty::UniqTraitStore) |
@@ -609,15 +610,15 @@ fn mutability_allowed(a_mutbl: ast::Mutability,
                           ex.span,
                           format!("can only cast an boxed pointer \
                                    to a boxed object, not a {}",
-                               ty::ty_sort_str(fcx.tcx(), ty)));
+                               ty::ty_sort_str(fcx.tcx(), ty)).as_slice());
                   }
 
                   (_, ty::RegionTraitStore(..)) => {
                       fcx.ccx.tcx.sess.span_err(
                           ex.span,
                           format!("can only cast an &-pointer \
-                                to an &-object, not a {}",
-                               ty::ty_sort_str(fcx.tcx(), ty)));
+                                   to an &-object, not a {}",
+                                  ty::ty_sort_str(fcx.tcx(), ty)).as_slice());
                   }
               }
           }
index 993a678bd267e35a8425b537f687099df3f30816..133fc9b1530abeeee6dcee392a79f2a98260712a 100644 (file)
@@ -402,7 +402,7 @@ fn report_error(&self, e: infer::fixup_err) {
                         span,
                         format!("cannot determine a type for \
                                  this expression: {}",
-                                infer::fixup_err_to_str(e)))
+                                infer::fixup_err_to_str(e)).as_slice())
                 }
 
                 ResolvingLocal(span) => {
@@ -410,7 +410,7 @@ fn report_error(&self, e: infer::fixup_err) {
                         span,
                         format!("cannot determine a type for \
                                  this local variable: {}",
-                                infer::fixup_err_to_str(e)))
+                                infer::fixup_err_to_str(e)).as_slice())
                 }
 
                 ResolvingPattern(span) => {
@@ -418,7 +418,7 @@ fn report_error(&self, e: infer::fixup_err) {
                         span,
                         format!("cannot determine a type for \
                                  this pattern binding: {}",
-                                infer::fixup_err_to_str(e)))
+                                infer::fixup_err_to_str(e)).as_slice())
                 }
 
                 ResolvingUpvar(upvar_id) => {
@@ -430,13 +430,15 @@ fn report_error(&self, e: infer::fixup_err) {
                                 ty::local_var_name_str(
                                     self.tcx,
                                     upvar_id.var_id).get().to_str(),
-                                infer::fixup_err_to_str(e)));
+                                infer::fixup_err_to_str(e)).as_slice());
                 }
 
                 ResolvingImplRes(span) => {
-                    self.tcx.sess.span_err(
-                        span,
-                        format!("cannot determine a type for impl supertrait"));
+                    self.tcx
+                        .sess
+                        .span_err(span,
+                                  "cannot determine a type for impl \
+                                   supertrait");
                 }
             }
         }
index d80e9f0888865b2e16415461f84c98524f44cd2e..042bebf573f753ba0eb42de6f5555488e6e7a8ef 100644 (file)
@@ -431,8 +431,9 @@ fn check_implementation_coherence_of(&self, trait_def_id: DefId) {
                         session.span_err(
                             self.span_of_impl(impl_a),
                             format!("conflicting implementations for trait `{}`",
-                                 ty::item_path_str(self.crate_context.tcx,
-                                                   trait_def_id)));
+                                    ty::item_path_str(
+                                        self.crate_context.tcx,
+                                        trait_def_id)).as_slice());
                         if impl_b.krate == LOCAL_CRATE {
                             session.span_note(self.span_of_impl(impl_b),
                                               "note conflicting implementation here");
@@ -442,7 +443,7 @@ fn check_implementation_coherence_of(&self, trait_def_id: DefId) {
                             session.note(
                                 format!("conflicting implementation in crate \
                                          `{}`",
-                                        cdata.name));
+                                        cdata.name).as_slice());
                         }
                     }
                 }
index c70204098e0a749e7f91cd84b366217fc608dd05..447f8dfa278d609ffb6d62cb05909495b257e0c8 100644 (file)
@@ -123,7 +123,8 @@ fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty {
             }
             x => {
                 self.tcx.sess.bug(format!("unexpected sort of node \
-                                           in get_item_ty(): {:?}", x));
+                                           in get_item_ty(): {:?}",
+                                          x).as_slice());
             }
         }
     }
@@ -134,7 +135,8 @@ fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
 
     fn ty_infer(&self, span: Span) -> ty::t {
         self.tcx.sess.span_err(span, "the type placeholder `_` is not \
-                                      allowed within types on item signatures.");
+                                      allowed within types on item \
+                                      signatures.");
         ty::mk_err()
     }
 }
@@ -573,7 +575,8 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
         if ty_param.bounds.len() > 0 {
             ccx.tcx.sess.span_err(
                 span,
-                format!("trait bounds are not allowed in {} definitions", thing));
+                format!("trait bounds are not allowed in {} definitions",
+                        thing).as_slice());
         }
     }
 }
@@ -711,10 +714,12 @@ pub fn convert_struct(ccx: &CrateCtxt,
         if result.name != special_idents::unnamed_field.name {
             let dup = match seen_fields.find(&result.name) {
                 Some(prev_span) => {
-                    tcx.sess.span_err(f.span,
-                        format!("field `{}` is already declared", token::get_name(result.name)));
+                    tcx.sess.span_err(
+                        f.span,
+                        format!("field `{}` is already declared",
+                                token::get_name(result.name)).as_slice());
                     tcx.sess.span_note(*prev_span,
-                        "previously declared here");
+                                       "previously declared here");
                     true
                 },
                 None => false,
@@ -840,7 +845,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt,
             ccx.tcx.sess.span_fatal(
                 ast_trait_ref.path.span,
                 format!("`{}` is not a trait",
-                    path_to_str(&ast_trait_ref.path)));
+                        path_to_str(&ast_trait_ref.path)).as_slice());
         }
     }
 }
@@ -852,8 +857,10 @@ fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> Rc<ty::TraitDef> {
 
     match ccx.tcx.map.get(trait_id.node) {
         ast_map::NodeItem(item) => trait_def_of_item(ccx, item),
-        _ => ccx.tcx.sess.bug(format!("get_trait_def({}): not an item",
-                                   trait_id.node))
+        _ => {
+            ccx.tcx.sess.bug(format!("get_trait_def({}): not an item",
+                                     trait_id.node).as_slice())
+        }
     }
 }
 
@@ -889,7 +896,7 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> {
         ref s => {
             tcx.sess.span_bug(
                 it.span,
-                format!("trait_def_of_item invoked on {:?}", s));
+                format!("trait_def_of_item invoked on {:?}", s).as_slice());
         }
     }
 }
@@ -960,9 +967,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item)
             return tpt;
         }
         ast::ItemTrait(..) => {
-            tcx.sess.span_bug(
-                it.span,
-                format!("invoked ty_of_item on trait"));
+            tcx.sess.span_bug(it.span, "invoked ty_of_item on trait");
         }
         ast::ItemStruct(_, ref generics) => {
             let ty_generics = ty_generics_for_type(ccx, generics);
@@ -1113,8 +1118,7 @@ fn compute_bounds(
                     if !ccx.tcx.sess.features.issue_5723_bootstrap.get() {
                         ccx.tcx.sess.span_err(
                             span,
-                            format!("only the 'static lifetime is \
-                                     accepted here."));
+                            "only the 'static lifetime is accepted here.");
                     }
                 }
             }
@@ -1151,7 +1155,8 @@ fn check_bounds_compatible(tcx: &ty::ctxt,
                         format!("incompatible bounds on type parameter {}, \
                                  bound {} does not allow unsized type",
                         token::get_ident(ident),
-                        ppaux::trait_ref_to_str(tcx, &*trait_ref)));
+                        ppaux::trait_ref_to_str(tcx,
+                                                &*trait_ref)).as_slice());
                 }
                 true
             });
index d50e36c31a0376c8c3da6f9bd5e92781e13104d7..819a69cfad18eb0da58c5c20bb5b9c6031606028 100644 (file)
@@ -212,7 +212,7 @@ pub fn unpack_actual_value(&self, a: ty::t, f: |&ty::sty| -> CoerceResult)
                 self.get_ref().infcx.tcx.sess.span_bug(
                     self.get_ref().trace.origin.span(),
                     format!("failed to resolve even without \
-                          any force options: {:?}", e));
+                          any force options: {:?}", e).as_slice());
             }
         }
     }
index 84df7230544e6568566a78cb06db91ff59ad1a9b..d80e8400a3a89f646ef70fbcb5cdc64a427e628f 100644 (file)
@@ -118,10 +118,9 @@ fn self_tys(&self, a: Option<ty::t>, b: Option<ty::t>)
                 // I think it should never happen that we unify two
                 // substs and one of them has a self_ty and one
                 // doesn't...? I could be wrong about this.
-                self.infcx().tcx.sess.bug(
-                                          format!("substitution a had a self_ty \
-                                               and substitution b didn't, \
-                                               or vice versa"));
+                self.infcx().tcx.sess.bug("substitution a had a self_ty \
+                                           and substitution b didn't, or \
+                                           vice versa");
             }
         }
     }
@@ -403,9 +402,9 @@ fn check_ptr_to_vec<C:Combine>(this: &C,
       (_, &ty::ty_infer(TyVar(_))) => {
         tcx.sess.bug(
             format!("{}: bot and var types should have been handled ({},{})",
-                 this.tag(),
-                 a.inf_str(this.infcx()),
-                 b.inf_str(this.infcx())));
+                    this.tag(),
+                    a.inf_str(this.infcx()),
+                    b.inf_str(this.infcx())).as_slice());
       }
 
         // Relate integral variables to other types
index 6f99a0a5ffb2b7a4d53e6f47f3972cf84e665555..6b6b9fab5c6b75ffbf97ec9f89c691020d6b694f 100644 (file)
@@ -355,7 +355,7 @@ fn report_type_error(&self, trace: TypeTrace, terr: &ty::type_err) {
             format!("{}: {} ({})",
                  message_root_str,
                  expected_found_str,
-                 ty::type_err_to_str(self.tcx, terr)));
+                 ty::type_err_to_str(self.tcx, terr)).as_slice());
     }
 
     fn report_and_explain_type_error(&self,
@@ -430,7 +430,10 @@ fn report_concrete_failure(&self,
                     span,
                     format!("lifetime of borrowed pointer outlives \
                             lifetime of captured variable `{}`...",
-                            ty::local_var_name_str(self.tcx, upvar_id.var_id).get().to_str()));
+                            ty::local_var_name_str(self.tcx,
+                                                   upvar_id.var_id)
+                                .get()
+                                .to_str()).as_slice());
                 note_and_explain_region(
                     self.tcx,
                     "...the borrowed pointer is valid for ",
@@ -439,7 +442,10 @@ fn report_concrete_failure(&self,
                 note_and_explain_region(
                     self.tcx,
                     format!("...but `{}` is only valid for ",
-                            ty::local_var_name_str(self.tcx, upvar_id.var_id).get().to_str()),
+                            ty::local_var_name_str(self.tcx,
+                                                   upvar_id.var_id)
+                                .get()
+                                .to_str()).as_slice(),
                     sup,
                     "");
             }
@@ -483,7 +489,9 @@ fn report_concrete_failure(&self,
                     span,
                     format!("captured variable `{}` does not \
                             outlive the enclosing closure",
-                            ty::local_var_name_str(self.tcx, id).get().to_str()));
+                            ty::local_var_name_str(self.tcx,
+                                                   id).get()
+                                                      .to_str()).as_slice());
                 note_and_explain_region(
                     self.tcx,
                     "captured variable is valid for ",
@@ -496,9 +504,8 @@ fn report_concrete_failure(&self,
                     "");
             }
             infer::IndexSlice(span) => {
-                self.tcx.sess.span_err(
-                    span,
-                    format!("index of slice outside its lifetime"));
+                self.tcx.sess.span_err(span,
+                                       "index of slice outside its lifetime");
                 note_and_explain_region(
                     self.tcx,
                     "the slice is only valid for ",
@@ -591,7 +598,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("in type `{}`, pointer has a longer lifetime than \
                           the data it references",
-                         ty.user_string(self.tcx)));
+                         ty.user_string(self.tcx)).as_slice());
                 note_and_explain_region(
                     self.tcx,
                     "the pointer is valid for ",
@@ -1022,8 +1029,13 @@ fn rebuild_arg_ty_or_output(&self,
                 }
                 ast::TyPath(ref path, _, id) => {
                     let a_def = match self.tcx.def_map.borrow().find(&id) {
-                        None => self.tcx.sess.fatal(format!("unbound path {}",
-                                                    pprust::path_to_str(path))),
+                        None => {
+                            self.tcx
+                                .sess
+                                .fatal(format!(
+                                        "unbound path {}",
+                                        pprust::path_to_str(path)).as_slice())
+                        }
                         Some(&d) => d
                     };
                     match a_def {
@@ -1209,18 +1221,18 @@ fn give_expl_lifetime_param(&self,
                                               opt_explicit_self, generics);
         let msg = format!("consider using an explicit lifetime \
                            parameter as shown: {}", suggested_fn);
-        self.tcx.sess.span_note(span, msg);
+        self.tcx.sess.span_note(span, msg.as_slice());
     }
 
     fn report_inference_failure(&self,
                                 var_origin: RegionVariableOrigin) {
         let var_description = match var_origin {
-            infer::MiscVariable(_) => "".to_owned(),
-            infer::PatternRegion(_) => " for pattern".to_owned(),
-            infer::AddrOfRegion(_) => " for borrow expression".to_owned(),
-            infer::AddrOfSlice(_) => " for slice expression".to_owned(),
-            infer::Autoref(_) => " for autoref".to_owned(),
-            infer::Coercion(_) => " for automatic coercion".to_owned(),
+            infer::MiscVariable(_) => "".to_strbuf(),
+            infer::PatternRegion(_) => " for pattern".to_strbuf(),
+            infer::AddrOfRegion(_) => " for borrow expression".to_strbuf(),
+            infer::AddrOfSlice(_) => " for slice expression".to_strbuf(),
+            infer::Autoref(_) => " for autoref".to_strbuf(),
+            infer::Coercion(_) => " for automatic coercion".to_strbuf(),
             infer::LateBoundRegion(_, br) => {
                 format!(" for {}in function call",
                         bound_region_to_str(self.tcx, "lifetime parameter ", true, br))
@@ -1247,7 +1259,7 @@ fn report_inference_failure(&self,
             var_origin.span(),
             format!("cannot infer an appropriate lifetime{} \
                     due to conflicting requirements",
-                    var_description));
+                    var_description).as_slice());
     }
 
     fn note_region_origin(&self, origin: SubregionOrigin) {
@@ -1282,7 +1294,7 @@ fn note_region_origin(&self, origin: SubregionOrigin) {
                         self.tcx.sess.span_note(
                             trace.origin.span(),
                             format!("...so that {} ({})",
-                                    desc, values_str));
+                                    desc, values_str).as_slice());
                     }
                     None => {
                         // Really should avoid printing this error at
@@ -1291,7 +1303,7 @@ fn note_region_origin(&self, origin: SubregionOrigin) {
                         // doing right now. - nmatsakis
                         self.tcx.sess.span_note(
                             trace.origin.span(),
-                            format!("...so that {}", desc));
+                            format!("...so that {}", desc).as_slice());
                     }
                 }
             }
@@ -1304,8 +1316,11 @@ fn note_region_origin(&self, origin: SubregionOrigin) {
             infer::ReborrowUpvar(span, ref upvar_id) => {
                 self.tcx.sess.span_note(
                     span,
-                    format!("...so that closure can access `{}`",
-                            ty::local_var_name_str(self.tcx, upvar_id.var_id).get().to_str()))
+                    format!(
+                        "...so that closure can access `{}`",
+                        ty::local_var_name_str(self.tcx, upvar_id.var_id)
+                            .get()
+                            .to_str()).as_slice())
             }
             infer::InfStackClosure(span) => {
                 self.tcx.sess.span_note(
@@ -1328,7 +1343,9 @@ fn note_region_origin(&self, origin: SubregionOrigin) {
                     span,
                     format!("...so that captured variable `{}` \
                             does not outlive the enclosing closure",
-                            ty::local_var_name_str(self.tcx, id).get().to_str()));
+                            ty::local_var_name_str(
+                                self.tcx,
+                                id).get().to_str()).as_slice());
             }
             infer::IndexSlice(span) => {
                 self.tcx.sess.span_note(
index 5ca5945a4f42f39460491e4e0997e65d685b11b5..73684a63ac12447c82693cacf3e62203cd38fee9 100644 (file)
@@ -249,7 +249,8 @@ fn rev_lookup(this: &Glb,
             }
             this.get_ref().infcx.tcx.sess.span_bug(
                 this.get_ref().trace.origin.span(),
-                format!("could not find original bound region for {:?}", r))
+                format!("could not find original bound region for {:?}",
+                        r).as_slice())
         }
 
         fn fresh_bound_variable(this: &Glb, binder_id: NodeId) -> ty::Region {
index ebfb17a887633a646d11ee65cb3584fe71f5f0e4..41a59dae740831ad74682f377ec4ad2fd3c5eb21 100644 (file)
@@ -529,7 +529,7 @@ pub fn var_ids<T:Combine>(this: &T,
             r => {
                 this.infcx().tcx.sess.span_bug(
                     this.trace().origin.span(),
-                    format!("found non-region-vid: {:?}", r));
+                    format!("found non-region-vid: {:?}", r).as_slice());
             }
         }).collect()
 }
index 7ba2210a2c4fcbb5811ca66a645c98c0969f4547..1df16f868013d50a860be7348942adfcbe3579e3 100644 (file)
@@ -185,8 +185,9 @@ fn generalize_region(this: &Lub,
 
             this.get_ref().infcx.tcx.sess.span_bug(
                 this.get_ref().trace.origin.span(),
-                format!("Region {:?} is not associated with \
-                        any bound region from A!", r0))
+                format!("region {:?} is not associated with \
+                         any bound region from A!",
+                        r0).as_slice())
         }
     }
 
index 30eb928a979b2fae25f345eb6cf5053e5e7cc973..7fed5e4ee1ae9ed65ec67c24f889e9c6ccc06896 100644 (file)
@@ -693,9 +693,9 @@ pub fn resolve_type_vars_in_trait_ref_if_possible(&self,
             _ => {
                 self.tcx.sess.bug(
                     format!("resolve_type_vars_if_possible() yielded {} \
-                          when supplied with {}",
-                         self.ty_to_str(dummy0),
-                         self.ty_to_str(dummy1)));
+                             when supplied with {}",
+                            self.ty_to_str(dummy0),
+                            self.ty_to_str(dummy1)).as_slice());
             }
         }
     }
@@ -729,7 +729,7 @@ pub fn type_error_message_str_with_expected(&self,
                                                 err: Option<&ty::type_err>) {
         debug!("hi! expected_ty = {:?}, actual_ty = {}", expected_ty, actual_ty);
 
-        let error_str = err.map_or("".to_owned(), |t_err| {
+        let error_str = err.map_or("".to_strbuf(), |t_err| {
             format!(" ({})", ty::type_err_to_str(self.tcx, t_err))
         });
         let resolved_expected = expected_ty.map(|e_ty| {
@@ -737,11 +737,19 @@ pub fn type_error_message_str_with_expected(&self,
         });
         if !resolved_expected.map_or(false, |e| { ty::type_is_error(e) }) {
             match resolved_expected {
-                None => self.tcx.sess.span_err(sp,
-                            format!("{}{}", mk_msg(None, actual_ty), error_str)),
+                None => {
+                    self.tcx
+                        .sess
+                        .span_err(sp,
+                                  format!("{}{}",
+                                          mk_msg(None, actual_ty),
+                                          error_str).as_slice())
+                }
                 Some(e) => {
                     self.tcx.sess.span_err(sp,
-                        format!("{}{}", mk_msg(Some(self.ty_to_str(e)), actual_ty), error_str));
+                        format!("{}{}",
+                                mk_msg(Some(self.ty_to_str(e)), actual_ty),
+                                error_str).as_slice());
                 }
             }
             for err in err.iter() {
index 24265d342eb411f574efbc89a70b4f4cd8f2de37..1178e1dfa46e97acb22e68c8094debaf2b3eb7d1 100644 (file)
@@ -297,7 +297,7 @@ pub fn make_subregion(&self,
                 origin.span(),
                 format!("cannot relate bound region: {} <= {}",
                         sub.repr(self.tcx),
-                        sup.repr(self.tcx)));
+                        sup.repr(self.tcx)).as_slice());
           }
           (_, ReStatic) => {
             // all regions are subregions of static, so we can ignore this
@@ -369,8 +369,8 @@ pub fn resolve_var(&self, rid: RegionVid) -> ty::Region {
             None => {
                 self.tcx.sess.span_bug(
                     self.var_origins.borrow().get(rid.to_uint()).span(),
-                    format!("attempt to resolve region variable before \
-                             values have been computed!"))
+                    "attempt to resolve region variable before values have \
+                     been computed!")
             }
             Some(ref values) => *values.get(rid.to_uint())
         };
@@ -546,7 +546,7 @@ fn lub_concrete_regions(&self, a: Region, b: Region) -> Region {
             self.tcx.sess.bug(
                 format!("cannot relate bound region: LUB({}, {})",
                         a.repr(self.tcx),
-                        b.repr(self.tcx)));
+                        b.repr(self.tcx)).as_slice());
           }
 
           (ReStatic, _) | (_, ReStatic) => {
@@ -561,7 +561,9 @@ fn lub_concrete_regions(&self, a: Region, b: Region) -> Region {
             self.tcx.sess.span_bug(
                 self.var_origins.borrow().get(v_id.to_uint()).span(),
                 format!("lub_concrete_regions invoked with \
-                      non-concrete regions: {:?}, {:?}", a, b));
+                         non-concrete regions: {:?}, {:?}",
+                        a,
+                        b).as_slice());
           }
 
           (f @ ReFree(ref fr), ReScope(s_id)) |
@@ -647,7 +649,7 @@ fn glb_concrete_regions(&self,
               self.tcx.sess.bug(
                   format!("cannot relate bound region: GLB({}, {})",
                           a.repr(self.tcx),
-                          b.repr(self.tcx)));
+                          b.repr(self.tcx)).as_slice());
             }
 
             (ReStatic, r) | (r, ReStatic) => {
@@ -665,7 +667,9 @@ fn glb_concrete_regions(&self,
                 self.tcx.sess.span_bug(
                     self.var_origins.borrow().get(v_id.to_uint()).span(),
                     format!("glb_concrete_regions invoked with \
-                          non-concrete regions: {:?}, {:?}", a, b));
+                             non-concrete regions: {:?}, {:?}",
+                            a,
+                            b).as_slice());
             }
 
             (ReFree(ref fr), s @ ReScope(s_id)) |
@@ -1175,7 +1179,7 @@ fn free_regions_first(a: &RegionAndOrigin,
                  upper_bounds.iter()
                              .map(|x| x.region)
                              .collect::<Vec<ty::Region>>()
-                             .repr(self.tcx)));
+                             .repr(self.tcx)).as_slice());
     }
 
     fn collect_error_for_contracting_node(
@@ -1222,7 +1226,7 @@ fn collect_error_for_contracting_node(
                  upper_bounds.iter()
                              .map(|x| x.region)
                              .collect::<Vec<ty::Region>>()
-                             .repr(self.tcx)));
+                             .repr(self.tcx)).as_slice());
     }
 
     fn collect_concrete_regions(&self,
index 2ee4f8fedd25b8711e5cb857fa14e39464ef3265..f36b98628507da66f4787a0d6c6a00089493a6ac 100644 (file)
@@ -87,7 +87,7 @@ fn helper<T:Clone, V:Clone+Eq+Vid>(
                 Some(&ref var_val) => (*var_val).clone(),
                 None => {
                     tcx.sess.bug(format!(
-                        "failed lookup of vid `{}`", vid_u));
+                        "failed lookup of vid `{}`", vid_u).as_slice());
                 }
             };
             match var_val {
index 165c573d056edc83f27532a9a5ff0826c6164397..253ab22d4704c525e85cf76ecb625f70cc5335ee 100644 (file)
@@ -311,7 +311,8 @@ pub fn require_same_types(tcx: &ty::ctxt,
             tcx.sess.span_err(span,
                               format!("{}: {}",
                                       msg(),
-                                      ty::type_err_to_str(tcx, terr)));
+                                      ty::type_err_to_str(tcx,
+                                                          terr)).as_slice());
             ty::note_and_explain_type_err(tcx, terr);
             false
         }
@@ -359,8 +360,10 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
         }
         _ => {
             tcx.sess.span_bug(main_span,
-                              format!("main has a non-function type: found `{}`",
-                                   ppaux::ty_to_str(tcx, main_t)));
+                              format!("main has a non-function type: found \
+                                       `{}`",
+                                      ppaux::ty_to_str(tcx,
+                                                       main_t)).as_slice());
         }
     }
 }
@@ -411,8 +414,10 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
         }
         _ => {
             tcx.sess.span_bug(start_span,
-                              format!("start has a non-function type: found `{}`",
-                                   ppaux::ty_to_str(tcx, start_t)));
+                              format!("start has a non-function type: found \
+                                       `{}`",
+                                      ppaux::ty_to_str(tcx,
+                                                       start_t)).as_slice());
         }
     }
 }
index 42850f8876338d002114ee3b88ef054e40022258..a6bf8e109c48587f033c29a29750d8b0ebe5c9c8 100644 (file)
@@ -538,8 +538,8 @@ fn inferred_index(&self, param_id: ast::NodeId) -> InferredIndex {
             Some(&index) => index,
             None => {
                 self.tcx().sess.bug(format!(
-                        "No inferred index entry for {}",
-                        self.tcx().map.node_to_str(param_id)));
+                        "no inferred index entry for {}",
+                        self.tcx().map.node_to_str(param_id)).as_slice());
             }
         }
     }
@@ -787,7 +787,7 @@ fn add_constraints_from_ty(&mut self,
                 self.tcx().sess.bug(
                     format!("unexpected type encountered in \
                             variance inference: {}",
-                            ty.repr(self.tcx())));
+                            ty.repr(self.tcx())).as_slice());
             }
         }
     }
@@ -858,9 +858,11 @@ fn add_constraints_from_region(&mut self,
             ty::ReEmpty => {
                 // We don't expect to see anything but 'static or bound
                 // regions when visiting member types or method types.
-                self.tcx().sess.bug(format!("unexpected region encountered in \
-                                            variance inference: {}",
-                                            region.repr(self.tcx())));
+                self.tcx()
+                    .sess
+                    .bug(format!("unexpected region encountered in variance \
+                                  inference: {}",
+                                 region.repr(self.tcx())).as_slice());
             }
         }
     }
index cbe04e4fcda79ae2a60f634d6235995c38f8c824..19233f0a59fe53b799a71bf77e4fc179f075dda4 100644 (file)
@@ -85,7 +85,7 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) {
     $(
         if missing.contains(&lang_items::$item) && items.$name().is_none() {
             sess.err(format!("language item required, but not found: `{}`",
-                             stringify!($name)));
+                             stringify!($name)).as_slice());
 
         }
     )*
@@ -100,7 +100,7 @@ fn register(&mut self, name: &str, span: Span) {
         } else)* {
             self.sess.span_err(span,
                                format!("unknown external lang item: `{}`",
-                                       name));
+                                       name).as_slice());
         }
     }
 }
index 95ae05985d38e2954c2ea755657580d3dfc993fb..087a4e58d497808299dcf75127e0969e387ddb32 100644 (file)
@@ -50,11 +50,11 @@ pub fn note_and_explain_region(cx: &ctxt,
       (ref str, Some(span)) => {
         cx.sess.span_note(
             span,
-            format!("{}{}{}", prefix, *str, suffix));
+            format!("{}{}{}", prefix, *str, suffix).as_slice());
       }
       (ref str, None) => {
         cx.sess.note(
-            format!("{}{}{}", prefix, *str, suffix));
+            format!("{}{}{}", prefix, *str, suffix).as_slice());
       }
     }
 }
@@ -255,13 +255,13 @@ fn bare_fn_to_str(cx: &ctxt,
         match fn_style {
             ast::NormalFn => {}
             _ => {
-                s.push_str(fn_style.to_str());
+                s.push_str(fn_style.to_str().as_slice());
                 s.push_char(' ');
             }
         };
 
         if abi != abi::Rust {
-            s.push_str(format!("extern {} ", abi.to_str()));
+            s.push_str(format!("extern {} ", abi.to_str()).as_slice());
         };
 
         s.push_str("fn");
@@ -292,7 +292,7 @@ fn closure_to_str(cx: &ctxt, cty: &ty::ClosureTy) -> StrBuf {
         match cty.fn_style {
             ast::NormalFn => {}
             _ => {
-                s.push_str(cty.fn_style.to_str());
+                s.push_str(cty.fn_style.to_str().as_slice());
                 s.push_char(' ');
             }
         };
@@ -327,7 +327,7 @@ fn push_sig_to_str(cx: &ctxt,
                        sig: &ty::FnSig) {
         s.push_char(bra);
         let strs: Vec<StrBuf> = sig.inputs.iter().map(|a| fn_input_to_str(cx, *a)).collect();
-        s.push_str(strs.connect(", "));
+        s.push_str(strs.connect(", ").as_slice());
         if sig.variadic {
             s.push_str(", ...");
         }
index 236c98b72e65a125a6db14051286257134e3eec2..fb2a80333e82d0e6377c70458135cbb240b3fe19 100644 (file)
@@ -1015,7 +1015,10 @@ fn clean(&self) -> Type {
                 let fqn: Vec<StrBuf> = fqn.move_iter().map(|i| {
                     i.to_str().to_strbuf()
                 }).collect();
-                let mut path = external_path(fqn.last().unwrap().to_str());
+                let mut path = external_path(fqn.last()
+                                                .unwrap()
+                                                .to_str()
+                                                .as_slice());
                 let kind = match ty::get(*self).sty {
                     ty::ty_struct(..) => TypeStruct,
                     ty::ty_trait(..) => TypeTrait,
index 948d47b2eaf7e25d20f27c7712e36d57b44b7d79..65bc9f544f6f726b17fba79d15ef94da62b3a549 100644 (file)
@@ -184,12 +184,12 @@ fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool,
         for lifetime in last.lifetimes.iter() {
             if counter > 0 { generics.push_str(", "); }
             counter += 1;
-            generics.push_str(format!("{}", *lifetime));
+            generics.push_str(format!("{}", *lifetime).as_slice());
         }
         for ty in last.types.iter() {
             if counter > 0 { generics.push_str(", "); }
             counter += 1;
-            generics.push_str(format!("{}", *ty));
+            generics.push_str(format!("{}", *ty).as_slice());
         }
         generics.push_str("&gt;");
     }
@@ -206,7 +206,7 @@ fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool,
         let amt = path.segments.len() - 1;
         match rel_root {
             Some(root) => {
-                let mut root = StrBuf::from_str(root);
+                let mut root = StrBuf::from_str(root.as_slice());
                 for seg in path.segments.slice_to(amt).iter() {
                     if "super" == seg.name.as_slice() ||
                             "self" == seg.name.as_slice() {
@@ -323,18 +323,22 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                            {arrow, select, yes{ -&gt; {ret}} other{}}",
                        style = FnStyleSpace(decl.fn_style),
                        lifetimes = if decl.lifetimes.len() == 0 {
-                           "".to_owned()
+                           "".to_strbuf()
                        } else {
                            format!("&lt;{:#}&gt;", decl.lifetimes)
                        },
                        args = decl.decl.inputs,
-                       arrow = match decl.decl.output { clean::Unit => "no", _ => "yes" },
+                       arrow = match decl.decl.output {
+                           clean::Unit => "no",
+                           _ => "yes",
+                       },
                        ret = decl.decl.output,
                        bounds = {
                            let mut ret = StrBuf::new();
                            match *region {
                                Some(ref lt) => {
-                                   ret.push_str(format!(": {}", *lt));
+                                   ret.push_str(format!(": {}",
+                                                        *lt).as_slice());
                                }
                                None => {}
                            }
@@ -347,7 +351,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                                         } else {
                                             ret.push_str(" + ");
                                         }
-                                        ret.push_str(format!("{}", *t));
+                                        ret.push_str(format!("{}",
+                                                             *t).as_slice());
                                     }
                                 }
                            }
@@ -416,7 +421,10 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                        }, **t)
             }
             clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
-                let lt = match *l { Some(ref l) => format!("{} ", *l), _ => "".to_owned() };
+                let lt = match *l {
+                    Some(ref l) => format!("{} ", *l),
+                    _ => "".to_strbuf(),
+                };
                 write!(f, "&amp;{}{}{}",
                        lt,
                        match mutability {
@@ -460,10 +468,10 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             clean::SelfValue => args.push_str("self"),
             clean::SelfOwned => args.push_str("~self"),
             clean::SelfBorrowed(Some(ref lt), clean::Immutable) => {
-                args.push_str(format!("&amp;{} self", *lt));
+                args.push_str(format!("&amp;{} self", *lt).as_slice());
             }
             clean::SelfBorrowed(Some(ref lt), clean::Mutable) => {
-                args.push_str(format!("&amp;{} mut self", *lt));
+                args.push_str(format!("&amp;{} mut self", *lt).as_slice());
             }
             clean::SelfBorrowed(None, clean::Mutable) => {
                 args.push_str("&amp;mut self");
@@ -475,9 +483,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         for (i, input) in d.inputs.values.iter().enumerate() {
             if i > 0 || args.len() > 0 { args.push_str(", "); }
             if input.name.len() > 0 {
-                args.push_str(format!("{}: ", input.name));
+                args.push_str(format!("{}: ", input.name).as_slice());
             }
-            args.push_str(format!("{}", input.type_));
+            args.push_str(format!("{}", input.type_).as_slice());
         }
         write!(f,
                "({args}){arrow, select, yes{ -&gt; {ret}} other{}}",
index b64e77615e1f5905f1632d5971b3bd1de453f064..5f3c19d57549dcdff4d15525a9ae66b05d55849a 100644 (file)
@@ -177,8 +177,9 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
                 };
 
                 if !rendered {
-                    let output = highlight::highlight(text, None).as_slice()
-                                                                 .to_c_str();
+                    let output = highlight::highlight(text.as_slice(),
+                                                      None).as_slice()
+                                                           .to_c_str();
                     output.with_ref(|r| {
                         hoedown_buffer_puts(ob, r)
                     })
@@ -202,7 +203,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
         };
 
         // Transform the contents of the header into a hyphenated string
-        let id = (s.words().map(|s| {
+        let id = (s.as_slice().words().map(|s| {
             match s.to_ascii_opt() {
                 Some(s) => s.to_lower().into_str().to_strbuf(),
                 None => s.to_strbuf()
index 752f193fa3f35e76421ce04c629bf580bab49341..8744553955a632634547f8825054f74cbf368240 100644 (file)
@@ -407,8 +407,11 @@ fn collect(path: &Path, krate: &str,
             if path.exists() {
                 for line in BufferedReader::new(File::open(path)).lines() {
                     let line = try!(line);
-                    if !line.starts_with(key) { continue }
-                    if line.starts_with(format!("{}['{}']", key, krate)) {
+                    if !line.as_slice().starts_with(key) {
+                        continue
+                    }
+                    if line.as_slice().starts_with(
+                            format!("{}['{}']", key, krate).as_slice()) {
                         continue
                     }
                     ret.push(line.to_strbuf());
@@ -646,7 +649,7 @@ fn emit_source(&mut self, filename: &str) -> io::IoResult<()> {
 
         let title = format!("{} -- source", cur.filename_display());
         let page = layout::Page {
-            title: title,
+            title: title.as_slice(),
             ty: "source",
             root_path: root_path.as_slice(),
         };
@@ -968,7 +971,7 @@ fn render(w: io::File, cx: &mut Context, it: &clean::Item,
             // does make formatting *a lot* nicer.
             current_location_key.replace(Some(cx.current.clone()));
 
-            let mut title = StrBuf::from_str(cx.current.connect("::"));
+            let mut title = cx.current.connect("::");
             if pushname {
                 if title.len() > 0 {
                     title.push_str("::");
@@ -1138,7 +1141,7 @@ fn item_path(item: &clean::Item) -> StrBuf {
 }
 
 fn full_path(cx: &Context, item: &clean::Item) -> StrBuf {
-    let mut s = StrBuf::from_str(cx.current.connect("::"));
+    let mut s = cx.current.connect("::");
     s.push_str("::");
     s.push_str(item.name.get_ref().as_slice());
     return s
@@ -1344,7 +1347,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
         parents.push_str(": ");
         for (i, p) in t.parents.iter().enumerate() {
             if i > 0 { parents.push_str(" + "); }
-            parents.push_str(format!("{}", *p));
+            parents.push_str(format!("{}", *p).as_slice());
         }
     }
 
index 48db910fc3908eddf5121f6870c6fff9aa8708ef..984ef458c8f4512a44fbe067430719850ff8f1f7 100644 (file)
@@ -132,7 +132,7 @@ pub fn opts() -> Vec<getopts::OptGroup> {
 
 pub fn usage(argv0: &str) {
     println!("{}",
-             getopts::usage(format!("{} [options] <input>", argv0),
+             getopts::usage(format!("{} [options] <input>", argv0).as_slice(),
                             opts().as_slice()));
 }
 
index e43e7d69a2d006df146e66594032773f7fa95452..de9c2839e739861c70cc7e3f822aaf4a691500b5 100644 (file)
@@ -80,7 +80,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
     let mut css = StrBuf::new();
     for name in matches.opt_strs("markdown-css").iter() {
         let s = format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">\n", name);
-        css.push_str(s)
+        css.push_str(s.as_slice())
     }
 
     let input_str = load_or_return!(input, 1, 2);
index a0d993dfe7d036262596d0c071a9d843ee6387fc..da18b7e8e9278e9c09e7bf4bf6c472944131d690 100644 (file)
@@ -346,14 +346,14 @@ mod unindent_tests {
     #[test]
     fn should_unindent() {
         let s = "    line1\n    line2".to_owned();
-        let r = unindent(s);
+        let r = unindent(s.as_slice());
         assert_eq!(r.as_slice(), "line1\nline2");
     }
 
     #[test]
     fn should_unindent_multiple_paragraphs() {
         let s = "    line1\n\n    line2".to_owned();
-        let r = unindent(s);
+        let r = unindent(s.as_slice());
         assert_eq!(r.as_slice(), "line1\n\nline2");
     }
 
@@ -362,7 +362,7 @@ fn should_leave_multiple_indent_levels() {
         // Line 2 is indented another level beyond the
         // base indentation and should be preserved
         let s = "    line1\n\n        line2".to_owned();
-        let r = unindent(s);
+        let r = unindent(s.as_slice());
         assert_eq!(r.as_slice(), "line1\n\n    line2");
     }
 
@@ -374,14 +374,14 @@ fn should_ignore_first_line_indent() {
         // #[doc = "Start way over here
         //          and continue here"]
         let s = "line1\n    line2".to_owned();
-        let r = unindent(s);
+        let r = unindent(s.as_slice());
         assert_eq!(r.as_slice(), "line1\nline2");
     }
 
     #[test]
     fn should_not_ignore_first_line_indent_in_a_single_line_para() {
         let s = "line1\n\n    line2".to_owned();
-        let r = unindent(s);
+        let r = unindent(s.as_slice());
         assert_eq!(r.as_slice(), "line1\n\n    line2");
     }
 }
index 5b4a9bd27b76c83aabf487eb8532628a9e75a851..63e6b7e36644b8611bb08959d48514d0b0cb5258 100644 (file)
@@ -171,7 +171,7 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool,
 
         // Remove the previous dylib search path var
         let var = DynamicLibrary::envvar();
-        let mut env: Vec<(~str,~str)> = os::env().move_iter().collect();
+        let mut env: Vec<(StrBuf,StrBuf)> = os::env().move_iter().collect();
         match env.iter().position(|&(ref k, _)| k.as_slice() == var) {
             Some(i) => { env.remove(i); }
             None => {}
@@ -213,7 +213,8 @@ fn maketest(s: &str, cratename: &str, loose_feature_gating: bool) -> StrBuf {
 
     if !s.contains("extern crate") {
         if s.contains(cratename) {
-            prog.push_str(format!("extern crate {};\n", cratename));
+            prog.push_str(format!("extern crate {};\n",
+                                  cratename).as_slice());
         }
     }
     if s.contains("fn main") {
@@ -275,7 +276,7 @@ pub fn add_test(&mut self, test: StrBuf, should_fail: bool, no_run: bool, should
             },
             testfn: testing::DynTestFn(proc() {
                 runtest(test.as_slice(),
-                        cratename,
+                        cratename.as_slice(),
                         libs,
                         should_fail,
                         no_run,
index 0a6a305a3b78084c9d7a2ae4471a33c4e7ebc0d8..857e07a2af17a32ee902909a6687232344263ad1 100644 (file)
@@ -387,7 +387,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 #[test]
 fn error_smoke_test() {
     let err: UvError = UvError(uvll::EOF);
-    assert_eq!(err.to_str(), "EOF: end of file".to_owned());
+    assert_eq!(err.to_str(), "EOF: end of file".to_strbuf());
 }
 
 pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
index 104efbeab0a3cd61ff45459399c8ca3a3311af93..3a387972ff7c1fa5b1ba87c3fb9e76b26499979b 100644 (file)
@@ -663,7 +663,7 @@ fn write_sized_vuint<W: Writer>(w: &mut W, n: uint, size: uint) -> EncodeResult
             _ => Err(io::IoError {
                 kind: io::OtherIoError,
                 desc: "int too big",
-                detail: Some(format!("{}", n))
+                detail: Some(format_strbuf!("{}", n))
             })
         }
     }
@@ -676,7 +676,7 @@ fn write_vuint<W: Writer>(w: &mut W, n: uint) -> EncodeResult {
         Err(io::IoError {
             kind: io::OtherIoError,
             desc: "int too big",
-            detail: Some(format!("{}", n))
+            detail: Some(format_strbuf!("{}", n))
         })
     }
 
index 3b8500753cb3f5170b7d3120152395413f9ddece..82ab5fd5b048bbc5ea0859619c307d3ac6aa6869 100644 (file)
@@ -182,8 +182,16 @@ pub fn test_to_hex_all_bytes() {
     #[test]
     pub fn test_from_hex_all_bytes() {
         for i in range(0, 256) {
-            assert_eq!(format!("{:02x}", i as uint).from_hex().unwrap().as_slice(), &[i as u8]);
-            assert_eq!(format!("{:02X}", i as uint).from_hex().unwrap().as_slice(), &[i as u8]);
+            assert_eq!(format!("{:02x}", i as uint).as_slice()
+                                                   .from_hex()
+                                                   .unwrap()
+                                                   .as_slice(),
+                       &[i as u8]);
+            assert_eq!(format!("{:02X}", i as uint).as_slice()
+                                                   .from_hex()
+                                                   .unwrap()
+                                                   .as_slice(),
+                       &[i as u8]);
         }
     }
 
index 422914b1405706bf60ff1d9681890c7009ca18c5..92e3d5a26887a1e7ca70eb9a1330d117ed233d88 100644 (file)
@@ -425,7 +425,9 @@ fn emit_f64(&mut self, v: f64) -> EncodeResult {
     }
     fn emit_f32(&mut self, v: f32) -> EncodeResult { self.emit_f64(v as f64) }
 
-    fn emit_char(&mut self, v: char) -> EncodeResult { self.emit_str(str::from_char(v)) }
+    fn emit_char(&mut self, v: char) -> EncodeResult {
+        self.emit_str(str::from_char(v).as_slice())
+    }
     fn emit_str(&mut self, v: &str) -> EncodeResult {
         write!(self.wr, "{}", escape_str(v))
     }
@@ -614,9 +616,13 @@ fn emit_bool(&mut self, v: bool) -> EncodeResult {
     fn emit_f64(&mut self, v: f64) -> EncodeResult {
         write!(self.wr, "{}", f64::to_str_digits(v, 6u))
     }
-    fn emit_f32(&mut self, v: f32) -> EncodeResult { self.emit_f64(v as f64) }
+    fn emit_f32(&mut self, v: f32) -> EncodeResult {
+        self.emit_f64(v as f64)
+    }
 
-    fn emit_char(&mut self, v: char) -> EncodeResult { self.emit_str(str::from_char(v)) }
+    fn emit_char(&mut self, v: char) -> EncodeResult {
+        self.emit_str(str::from_char(v).as_slice())
+    }
     fn emit_str(&mut self, v: &str) -> EncodeResult {
         write!(self.wr, "{}", escape_str(v))
     }
@@ -2477,7 +2483,7 @@ fn test_write_object() {
 
         // We can't compare the strings directly because the object fields be
         // printed in a different order.
-        assert_eq!(a.clone(), from_str(a.to_str()).unwrap());
+        assert_eq!(a.clone(), from_str(a.to_str().as_slice()).unwrap());
         assert_eq!(a.clone(),
                    from_str(a.to_pretty_str().as_slice()).unwrap());
     }
index e087b3d1774995f5486beac433064bf4fcb9231a..e5689158601bc8cd8fcb0357c145dc2280c011a4 100644 (file)
 use mem;
 use option::{Option, Some, None};
 use slice::{ImmutableVector, MutableVector, Vector};
-use str::OwnedStr;
-use str::Str;
-use str::{StrAllocating, StrSlice};
+use str::{OwnedStr, Str, StrAllocating, StrSlice};
 use str;
+use strbuf::StrBuf;
 use to_str::{IntoStr};
 use vec::Vec;
 
@@ -249,7 +248,7 @@ unsafe fn into_ascii_nocheck(self) -> Vec<Ascii> {
     }
 }
 
-impl OwnedAsciiCast for ~str {
+impl OwnedAsciiCast for StrBuf {
     #[inline]
     fn is_ascii(&self) -> bool {
         self.as_slice().is_ascii()
@@ -257,7 +256,7 @@ fn is_ascii(&self) -> bool {
 
     #[inline]
     unsafe fn into_ascii_nocheck(self) -> Vec<Ascii> {
-        let v: ~[u8] = mem::transmute(self);
+        let v: Vec<u8> = mem::transmute(self);
         v.into_ascii_nocheck()
     }
 }
@@ -314,17 +313,18 @@ fn eq_ignore_case(self, other: &[Ascii]) -> bool {
 
 impl IntoStr for ~[Ascii] {
     #[inline]
-    fn into_str(self) -> ~str {
-        unsafe { mem::transmute(self) }
+    fn into_str(self) -> StrBuf {
+        let vector: Vec<Ascii> = self.as_slice().iter().map(|x| *x).collect();
+        vector.into_str()
     }
 }
 
 impl IntoStr for Vec<Ascii> {
     #[inline]
-    fn into_str(self) -> ~str {
+    fn into_str(self) -> StrBuf {
         unsafe {
             let s: &str = mem::transmute(self.as_slice());
-            s.to_owned()
+            s.to_strbuf()
         }
     }
 }
@@ -346,12 +346,12 @@ pub trait OwnedStrAsciiExt {
     /// Convert the string to ASCII upper case:
     /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
     /// but non-ASCII letters are unchanged.
-    fn into_ascii_upper(self) -> ~str;
+    fn into_ascii_upper(self) -> StrBuf;
 
     /// Convert the string to ASCII lower case:
     /// ASCII letters 'A' to 'Z' are mapped to 'a' to 'z',
     /// but non-ASCII letters are unchanged.
-    fn into_ascii_lower(self) -> ~str;
+    fn into_ascii_lower(self) -> StrBuf;
 }
 
 /// Extension methods for ASCII-subset only operations on string slices
@@ -359,12 +359,12 @@ pub trait StrAsciiExt {
     /// Makes a copy of the string in ASCII upper case:
     /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
     /// but non-ASCII letters are unchanged.
-    fn to_ascii_upper(&self) -> ~str;
+    fn to_ascii_upper(&self) -> StrBuf;
 
     /// Makes a copy of the string in ASCII lower case:
     /// ASCII letters 'A' to 'Z' are mapped to 'a' to 'z',
     /// but non-ASCII letters are unchanged.
-    fn to_ascii_lower(&self) -> ~str;
+    fn to_ascii_lower(&self) -> StrBuf;
 
     /// Check that two strings are an ASCII case-insensitive match.
     /// Same as `to_ascii_lower(a) == to_ascii_lower(b)`,
@@ -374,12 +374,12 @@ pub trait StrAsciiExt {
 
 impl<'a> StrAsciiExt for &'a str {
     #[inline]
-    fn to_ascii_upper(&self) -> ~str {
+    fn to_ascii_upper(&self) -> StrBuf {
         unsafe { str_copy_map_bytes(*self, ASCII_UPPER_MAP) }
     }
 
     #[inline]
-    fn to_ascii_lower(&self) -> ~str {
+    fn to_ascii_lower(&self) -> StrBuf {
         unsafe { str_copy_map_bytes(*self, ASCII_LOWER_MAP) }
     }
 
@@ -394,36 +394,36 @@ fn eq_ignore_ascii_case(&self, other: &str) -> bool {
     }
 }
 
-impl OwnedStrAsciiExt for ~str {
+impl OwnedStrAsciiExt for StrBuf {
     #[inline]
-    fn into_ascii_upper(self) -> ~str {
+    fn into_ascii_upper(self) -> StrBuf {
         unsafe { str_map_bytes(self, ASCII_UPPER_MAP) }
     }
 
     #[inline]
-    fn into_ascii_lower(self) -> ~str {
+    fn into_ascii_lower(self) -> StrBuf {
         unsafe { str_map_bytes(self, ASCII_LOWER_MAP) }
     }
 }
 
 #[inline]
-unsafe fn str_map_bytes(string: ~str, map: &'static [u8]) -> ~str {
+unsafe fn str_map_bytes(string: StrBuf, map: &'static [u8]) -> StrBuf {
     let mut bytes = string.into_bytes();
 
     for b in bytes.mut_iter() {
         *b = map[*b as uint];
     }
 
-    str::raw::from_utf8_owned(bytes)
+    str::from_utf8(bytes.as_slice()).unwrap().to_strbuf()
 }
 
 #[inline]
-unsafe fn str_copy_map_bytes(string: &str, map: &'static [u8]) -> ~str {
-    let mut s = string.to_owned();
-    for b in str::raw::as_owned_vec(&mut s).mut_iter() {
+unsafe fn str_copy_map_bytes(string: &str, map: &'static [u8]) -> StrBuf {
+    let mut s = string.to_strbuf();
+    for b in s.as_mut_bytes().mut_iter() {
         *b = map[*b as uint];
     }
-    s
+    s.into_strbuf()
 }
 
 static ASCII_LOWER_MAP: &'static [u8] = &[
@@ -552,15 +552,17 @@ fn test_ascii_vec() {
         assert_eq!("( ;".to_ascii(),                 v2ascii!([40, 32, 59]));
         // FIXME: #5475 borrowchk error, owned vectors do not live long enough
         // if chained-from directly
-        let v = box [40u8, 32u8, 59u8]; assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59]));
-        let v = "( ;".to_owned();              assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59]));
+        let v = box [40u8, 32u8, 59u8];
+        assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59]));
+        let v = "( ;".to_strbuf();
+        assert_eq!(v.as_slice().to_ascii(), v2ascii!([40, 32, 59]));
 
-        assert_eq!("abCDef&?#".to_ascii().to_lower().into_str(), "abcdef&?#".to_owned());
-        assert_eq!("abCDef&?#".to_ascii().to_upper().into_str(), "ABCDEF&?#".to_owned());
+        assert_eq!("abCDef&?#".to_ascii().to_lower().into_str(), "abcdef&?#".to_strbuf());
+        assert_eq!("abCDef&?#".to_ascii().to_upper().into_str(), "ABCDEF&?#".to_strbuf());
 
-        assert_eq!("".to_ascii().to_lower().into_str(), "".to_owned());
-        assert_eq!("YMCA".to_ascii().to_lower().into_str(), "ymca".to_owned());
-        assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_str(), "ABCDEFXYZ:.;".to_owned());
+        assert_eq!("".to_ascii().to_lower().into_str(), "".to_strbuf());
+        assert_eq!("YMCA".to_ascii().to_lower().into_str(), "ymca".to_strbuf());
+        assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_str(), "ABCDEFXYZ:.;".to_strbuf());
 
         assert!("aBcDeF&?#".to_ascii().eq_ignore_case("AbCdEf&?#".to_ascii()));
 
@@ -572,16 +574,16 @@ fn test_ascii_vec() {
 
     #[test]
     fn test_ascii_vec_ng() {
-        assert_eq!("abCDef&?#".to_ascii().to_lower().into_str(), "abcdef&?#".to_owned());
-        assert_eq!("abCDef&?#".to_ascii().to_upper().into_str(), "ABCDEF&?#".to_owned());
-        assert_eq!("".to_ascii().to_lower().into_str(), "".to_owned());
-        assert_eq!("YMCA".to_ascii().to_lower().into_str(), "ymca".to_owned());
-        assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_str(), "ABCDEFXYZ:.;".to_owned());
+        assert_eq!("abCDef&?#".to_ascii().to_lower().into_str(), "abcdef&?#".to_strbuf());
+        assert_eq!("abCDef&?#".to_ascii().to_upper().into_str(), "ABCDEF&?#".to_strbuf());
+        assert_eq!("".to_ascii().to_lower().into_str(), "".to_strbuf());
+        assert_eq!("YMCA".to_ascii().to_lower().into_str(), "ymca".to_strbuf());
+        assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_str(), "ABCDEFXYZ:.;".to_strbuf());
     }
 
     #[test]
     fn test_owned_ascii_vec() {
-        assert_eq!(("( ;".to_owned()).into_ascii(), vec2ascii![40, 32, 59]);
+        assert_eq!(("( ;".to_strbuf()).into_ascii(), vec2ascii![40, 32, 59]);
         assert_eq!((box [40u8, 32u8, 59u8]).into_ascii(), vec2ascii![40, 32, 59]);
     }
 
@@ -593,8 +595,8 @@ fn test_ascii_as_str() {
 
     #[test]
     fn test_ascii_into_str() {
-        assert_eq!(vec2ascii![40, 32, 59].into_str(), "( ;".to_owned());
-        assert_eq!(vec2ascii!(40, 32, 59).into_str(), "( ;".to_owned());
+        assert_eq!(vec2ascii![40, 32, 59].into_str(), "( ;".to_strbuf());
+        assert_eq!(vec2ascii!(40, 32, 59).into_str(), "( ;".to_strbuf());
     }
 
     #[test]
@@ -641,70 +643,70 @@ fn test_opt() {
         assert_eq!((vec![40u8, 32u8, 59u8]).into_ascii_opt(), Some(vec2ascii![40, 32, 59]));
         assert_eq!((vec![127u8, 128u8, 255u8]).into_ascii_opt(), None);
 
-        assert_eq!(("( ;".to_owned()).into_ascii_opt(), Some(vec2ascii![40, 32, 59]));
-        assert_eq!(("zoä华".to_owned()).into_ascii_opt(), None);
+        assert_eq!(("( ;".to_strbuf()).into_ascii_opt(), Some(vec2ascii![40, 32, 59]));
+        assert_eq!(("zoä华".to_strbuf()).into_ascii_opt(), None);
     }
 
     #[test]
     fn test_to_ascii_upper() {
-        assert_eq!("url()URL()uRl()ürl".to_ascii_upper(), "URL()URL()URL()üRL".to_owned());
-        assert_eq!("hıKß".to_ascii_upper(), "HıKß".to_owned());
+        assert_eq!("url()URL()uRl()ürl".to_ascii_upper(), "URL()URL()URL()üRL".to_strbuf());
+        assert_eq!("hıKß".to_ascii_upper(), "HıKß".to_strbuf());
 
         let mut i = 0;
         while i <= 500 {
             let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 }
                         else { i };
-            assert_eq!(from_char(from_u32(i).unwrap()).to_ascii_upper(),
-                       from_char(from_u32(upper).unwrap()))
+            assert_eq!(from_char(from_u32(i).unwrap()).as_slice().to_ascii_upper(),
+                       from_char(from_u32(upper).unwrap()).to_strbuf())
             i += 1;
         }
     }
 
     #[test]
     fn test_to_ascii_lower() {
-        assert_eq!("url()URL()uRl()Ürl".to_ascii_lower(), "url()url()url()Ürl".to_owned());
+        assert_eq!("url()URL()uRl()Ürl".to_ascii_lower(), "url()url()url()Ürl".to_strbuf());
         // Dotted capital I, Kelvin sign, Sharp S.
-        assert_eq!("HİKß".to_ascii_lower(), "hİKß".to_owned());
+        assert_eq!("HİKß".to_ascii_lower(), "hİKß".to_strbuf());
 
         let mut i = 0;
         while i <= 500 {
             let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
                         else { i };
-            assert_eq!(from_char(from_u32(i).unwrap()).to_ascii_lower(),
-                       from_char(from_u32(lower).unwrap()))
+            assert_eq!(from_char(from_u32(i).unwrap()).as_slice().to_ascii_lower(),
+                       from_char(from_u32(lower).unwrap()).to_strbuf())
             i += 1;
         }
     }
 
     #[test]
     fn test_into_ascii_upper() {
-        assert_eq!(("url()URL()uRl()ürl".to_owned()).into_ascii_upper(),
-                   "URL()URL()URL()üRL".to_owned());
-        assert_eq!(("hıKß".to_owned()).into_ascii_upper(), "HıKß".to_owned());
+        assert_eq!(("url()URL()uRl()ürl".to_strbuf()).into_ascii_upper(),
+                   "URL()URL()URL()üRL".to_strbuf());
+        assert_eq!(("hıKß".to_strbuf()).into_ascii_upper(), "HıKß".to_strbuf());
 
         let mut i = 0;
         while i <= 500 {
             let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 }
                         else { i };
-            assert_eq!(from_char(from_u32(i).unwrap()).into_ascii_upper(),
-                       from_char(from_u32(upper).unwrap()))
+            assert_eq!(from_char(from_u32(i).unwrap()).to_strbuf().into_ascii_upper(),
+                       from_char(from_u32(upper).unwrap()).to_strbuf())
             i += 1;
         }
     }
 
     #[test]
     fn test_into_ascii_lower() {
-        assert_eq!(("url()URL()uRl()Ürl".to_owned()).into_ascii_lower(),
-                   "url()url()url()Ürl".to_owned());
+        assert_eq!(("url()URL()uRl()Ürl".to_strbuf()).into_ascii_lower(),
+                   "url()url()url()Ürl".to_strbuf());
         // Dotted capital I, Kelvin sign, Sharp S.
-        assert_eq!(("HİKß".to_owned()).into_ascii_lower(), "hİKß".to_owned());
+        assert_eq!(("HİKß".to_strbuf()).into_ascii_lower(), "hİKß".to_strbuf());
 
         let mut i = 0;
         while i <= 500 {
             let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
                         else { i };
-            assert_eq!(from_char(from_u32(i).unwrap()).into_ascii_lower(),
-                       from_char(from_u32(lower).unwrap()))
+            assert_eq!(from_char(from_u32(i).unwrap()).to_strbuf().into_ascii_lower(),
+                       from_char(from_u32(lower).unwrap()).to_strbuf())
             i += 1;
         }
     }
@@ -724,8 +726,11 @@ fn test_eq_ignore_ascii_case() {
             let c = i;
             let lower = if 'A' as u32 <= c && c <= 'Z' as u32 { c + 'a' as u32 - 'A' as u32 }
                         else { c };
-            assert!(from_char(from_u32(i).unwrap()).
-                eq_ignore_ascii_case(from_char(from_u32(lower).unwrap())));
+            assert!(from_char(from_u32(i).unwrap()).as_slice()
+                                                   .eq_ignore_ascii_case(
+                                                       from_char(
+                                                           from_u32(lower)
+                                                            .unwrap()).as_slice()));
             i += 1;
         }
     }
@@ -733,12 +738,12 @@ fn test_eq_ignore_ascii_case() {
     #[test]
     fn test_to_str() {
         let s = Ascii{ chr: 't' as u8 }.to_str();
-        assert_eq!(s, "t".to_owned());
+        assert_eq!(s, "t".to_strbuf());
     }
 
     #[test]
     fn test_show() {
         let c = Ascii { chr: 't' as u8 };
-        assert_eq!(format!("{}", c), "t".to_owned());
+        assert_eq!(format_strbuf!("{}", c), "t".to_strbuf());
     }
 }
index 0c529ee4d963e64404c013325956b5f5e43ef65b..4622c0934fe44b06a6abad43d50770ab1fd6e16e 100644 (file)
@@ -323,29 +323,6 @@ unsafe fn with_c_str_unchecked<T>(&self, f: |*libc::c_char| -> T) -> T {
     }
 }
 
-impl ToCStr for ~str {
-    #[inline]
-    fn to_c_str(&self) -> CString {
-        self.as_bytes().to_c_str()
-    }
-
-    #[inline]
-    unsafe fn to_c_str_unchecked(&self) -> CString {
-        self.as_bytes().to_c_str_unchecked()
-    }
-
-    #[inline]
-    fn with_c_str<T>(&self, f: |*libc::c_char| -> T) -> T {
-        self.as_bytes().with_c_str(f)
-    }
-
-    #[inline]
-    unsafe fn with_c_str_unchecked<T>(&self, f: |*libc::c_char| -> T) -> T {
-        self.as_bytes().with_c_str_unchecked(f)
-    }
-}
-
-
 impl ToCStr for StrBuf {
     #[inline]
     fn to_c_str(&self) -> CString {
index fd5b92ba46913e26fe3468c16a62d45294925ad0..b2521f2978a541d1d3a9006d2c1606b359e383ec 100644 (file)
@@ -990,7 +990,7 @@ mod test {
 
     pub fn stress_factor() -> uint {
         match os::getenv("RUST_TEST_STRESS") {
-            Some(val) => from_str::<uint>(val).unwrap(),
+            Some(val) => from_str::<uint>(val.as_slice()).unwrap(),
             None => 1,
         }
     }
@@ -1523,7 +1523,7 @@ mod sync_tests {
 
     pub fn stress_factor() -> uint {
         match os::getenv("RUST_TEST_STRESS") {
-            Some(val) => from_str::<uint>(val).unwrap(),
+            Some(val) => from_str::<uint>(val.as_slice()).unwrap(),
             None => 1,
         }
     }
index 86b77a46a39809a165a96d7acda41d06201ffeac..db23a5f1720221b12f096bc1cd0f8817a477ba05 100644 (file)
@@ -27,9 +27,9 @@
 
 The `format!` macro is intended to be familiar to those coming from C's
 printf/fprintf functions or Python's `str.format` function. In its current
-revision, the `format!` macro returns a `~str` type which is the result of the
-formatting. In the future it will also be able to pass in a stream to format
-arguments directly while performing minimal allocations.
+revision, the `format!` macro returns a `StrBuf` type which is the result of
+the formatting. In the future it will also be able to pass in a stream to
+format arguments directly while performing minimal allocations.
 
 Some examples of the `format!` extension are:
 
@@ -282,7 +282,7 @@ fn main() {
 
 # #[allow(unused_must_use)]
 # fn main() {
-format_args!(fmt::format, "this returns {}", "~str");
+format_args!(fmt::format, "this returns {}", "StrBuf");
 
 let some_writer: &mut io::Writer = &mut io::stdout();
 format_args!(|args| { write!(some_writer, "{}", args) }, "print with a {}", "closure");
@@ -488,7 +488,7 @@ fn my_fmt_fn(args: &fmt::Arguments) {
 use option::None;
 use repr;
 use result::{Ok, Err};
-use str::{StrAllocating};
+use str::{Str, StrAllocating};
 use str;
 use strbuf::StrBuf;
 use slice::Vector;
@@ -545,10 +545,10 @@ pub trait Poly {
 /// let s = format_args!(fmt::format, "Hello, {}!", "world");
 /// assert_eq!(s, "Hello, world!".to_owned());
 /// ```
-pub fn format(args: &Arguments) -> ~str {
+pub fn format(args: &Arguments) -> StrBuf{
     let mut output = io::MemWriter::new();
     let _ = write!(&mut output, "{}", args);
-    str::from_utf8(output.unwrap().as_slice()).unwrap().to_owned()
+    str::from_utf8(output.unwrap().as_slice()).unwrap().into_strbuf()
 }
 
 /// Temporary transition utility
@@ -572,7 +572,7 @@ fn fmt(&self, f: &mut Formatter) -> Result {
             // this allocation of a new string
             _ => {
                 let s = repr::repr_to_str(self);
-                f.pad(s)
+                f.pad(s.as_slice())
             }
         }
     }
index a510aa90343e5bec8a61409e87d07ad88ada0523..1dad1667ebd45ef811cb53bea7d351a99a427531 100644 (file)
@@ -23,7 +23,7 @@
  * #[deriving(Hash)]
  * struct Person {
  *     id: uint,
- *     name: ~str,
+ *     name: StrBuf,
  *     phone: u64,
  * }
  *
@@ -43,7 +43,7 @@
  *
  * struct Person {
  *     id: uint,
- *     name: ~str,
+ *     name: StrBuf,
  *     phone: u64,
  * }
  *
@@ -145,13 +145,6 @@ fn hash(&self, state: &mut S) {
     }
 }
 
-impl<S: Writer> Hash<S> for ~str {
-    #[inline]
-    fn hash(&self, state: &mut S) {
-        self.as_slice().hash(state);
-    }
-}
-
 macro_rules! impl_hash_tuple(
     () => (
         impl<S: Writer> Hash<S> for () {
index 58e0f4c717dedee7b0215058988737e33d0ccf2d..1434e3c7ad71e693f60ea4a57615087f02e5f1f8 100644 (file)
@@ -458,12 +458,12 @@ fn test_siphash() {
         let mut state_inc = SipState::new_with_keys(k0, k1);
         let mut state_full = SipState::new_with_keys(k0, k1);
 
-        fn to_hex_str(r: &[u8, ..8]) -> ~str {
+        fn to_hex_str(r: &[u8, ..8]) -> StrBuf {
             let mut s = StrBuf::new();
             for b in r.iter() {
-                s.push_str((*b as uint).to_str_radix(16u));
+                s.push_str((*b as uint).to_str_radix(16u).as_slice());
             }
-            s.into_owned()
+            s
         }
 
         fn result_bytes(h: u64) -> ~[u8] {
@@ -478,13 +478,13 @@ fn result_bytes(h: u64) -> ~[u8] {
             ]
         }
 
-        fn result_str(h: u64) -> ~str {
+        fn result_str(h: u64) -> StrBuf {
             let r = result_bytes(h);
             let mut s = StrBuf::new();
             for b in r.iter() {
-                s.push_str((*b as uint).to_str_radix(16u));
+                s.push_str((*b as uint).to_str_radix(16u).as_slice());
             }
-            s.into_owned()
+            s
         }
 
         while t < 64 {
@@ -636,7 +636,6 @@ fn bench_u64(b: &mut Bencher) {
     struct Compound {
         x: u8,
         y: u64,
-        z: ~str,
     }
 
     #[bench]
@@ -644,7 +643,6 @@ fn bench_compound_1(b: &mut Bencher) {
         let compound = Compound {
             x: 1,
             y: 2,
-            z: "foobarbaz".to_owned(),
         };
         b.iter(|| {
             assert_eq!(hash(&compound), 15783192367317361799);
index 2880365cf348f5c6a15f63988af56ded515bb8b9..c7b0d66062460c4b7fea342ac6f389925740c5c8 100644 (file)
@@ -537,9 +537,9 @@ fn test_line_buffer() {
     fn test_read_line() {
         let in_buf = MemReader::new(Vec::from_slice(bytes!("a\nb\nc")));
         let mut reader = BufferedReader::with_capacity(2, in_buf);
-        assert_eq!(reader.read_line(), Ok("a\n".to_owned()));
-        assert_eq!(reader.read_line(), Ok("b\n".to_owned()));
-        assert_eq!(reader.read_line(), Ok("c".to_owned()));
+        assert_eq!(reader.read_line(), Ok("a\n".to_strbuf()));
+        assert_eq!(reader.read_line(), Ok("b\n".to_strbuf()));
+        assert_eq!(reader.read_line(), Ok("c".to_strbuf()));
         assert!(reader.read_line().is_err());
     }
 
@@ -548,9 +548,9 @@ fn test_lines() {
         let in_buf = MemReader::new(Vec::from_slice(bytes!("a\nb\nc")));
         let mut reader = BufferedReader::with_capacity(2, in_buf);
         let mut it = reader.lines();
-        assert_eq!(it.next(), Some(Ok("a\n".to_owned())));
-        assert_eq!(it.next(), Some(Ok("b\n".to_owned())));
-        assert_eq!(it.next(), Some(Ok("c".to_owned())));
+        assert_eq!(it.next(), Some(Ok("a\n".to_strbuf())));
+        assert_eq!(it.next(), Some(Ok("b\n".to_strbuf())));
+        assert_eq!(it.next(), Some(Ok("c".to_strbuf())));
         assert_eq!(it.next(), None);
     }
 
index a497ffd40a0707b6bbe648c31d1ef458163db046..d8edd6517d5874c8e1b29d10ed6c69e6084ab8c8 100644 (file)
@@ -745,7 +745,8 @@ fn drop(&mut self) {
     pub fn tmpdir() -> TempDir {
         use os;
         use rand;
-        let ret = os::tmpdir().join(format!("rust-{}", rand::random::<u32>()));
+        let ret = os::tmpdir().join(
+            format_strbuf!("rust-{}", rand::random::<u32>()));
         check!(io::fs::mkdir(&ret, io::UserRWX));
         TempDir(ret)
     }
@@ -854,7 +855,7 @@ pub fn tmpdir() -> TempDir {
         }
         check!(unlink(filename));
         let read_str = str::from_utf8(read_mem).unwrap();
-        assert!(read_str == final_msg.to_owned());
+        assert!(read_str.as_slice() == final_msg.as_slice());
     })
 
     iotest!(fn file_test_io_seek_shakedown() {
@@ -952,10 +953,10 @@ pub fn tmpdir() -> TempDir {
         check!(mkdir(dir, io::UserRWX));
         let prefix = "foo";
         for n in range(0,3) {
-            let f = dir.join(format!("{}.txt", n));
+            let f = dir.join(format_strbuf!("{}.txt", n));
             let mut w = check!(File::create(&f));
-            let msg_str = (prefix + n.to_str().to_owned()).to_owned();
-            let msg = msg_str.as_bytes();
+            let msg_str = format!("{}{}", prefix, n.to_str());
+            let msg = msg_str.as_slice().as_bytes();
             check!(w.write(msg));
         }
         let files = check!(readdir(dir));
@@ -967,7 +968,7 @@ pub fn tmpdir() -> TempDir {
                 let read_str = str::from_utf8(mem).unwrap();
                 let expected = match n {
                     None|Some("") => fail!("really shouldn't happen.."),
-                    Some(n) => prefix+n
+                    Some(n) => format!("{}{}", prefix, n),
                 };
                 assert_eq!(expected.as_slice(), read_str);
             }
@@ -1039,7 +1040,7 @@ pub fn tmpdir() -> TempDir {
         let tmpdir = tmpdir();
 
         let mut dirpath = tmpdir.path().clone();
-        dirpath.push(format!("test-가一ー你好"));
+        dirpath.push(format_strbuf!("test-가一ー你好"));
         check!(mkdir(&dirpath, io::UserRWX));
         assert!(dirpath.is_dir());
 
@@ -1056,7 +1057,7 @@ pub fn tmpdir() -> TempDir {
 
         let tmpdir = tmpdir();
         let unicode = tmpdir.path();
-        let unicode = unicode.join(format!("test-각丁ー再见"));
+        let unicode = unicode.join(format_strbuf!("test-각丁ー再见"));
         check!(mkdir(&unicode, io::UserRWX));
         assert!(unicode.exists());
         assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists());
index 92b546d5770e6a165c9cdfa0bec5624245c17550..c1e228cd693b59890cb2dd7f7cdafe5efd0e4557 100644 (file)
@@ -497,7 +497,7 @@ fn test_write_strings() {
         writer.write_line("testing").unwrap();
         writer.write_str("testing").unwrap();
         let mut r = BufReader::new(writer.get_ref());
-        assert_eq!(r.read_to_str().unwrap(), "testingtesting\ntesting".to_owned());
+        assert_eq!(r.read_to_str().unwrap(), "testingtesting\ntesting".to_strbuf());
     }
 
     #[test]
@@ -507,7 +507,7 @@ fn test_write_char() {
         writer.write_char('\n').unwrap();
         writer.write_char('ệ').unwrap();
         let mut r = BufReader::new(writer.get_ref());
-        assert_eq!(r.read_to_str().unwrap(), "a\nệ".to_owned());
+        assert_eq!(r.read_to_str().unwrap(), "a\nệ".to_strbuf());
     }
 
     #[test]
index a043722581ba26d337d839bfed215c293b41a312..50bd3e7067c85db49e7c0a30a0cf74249a758219 100644 (file)
@@ -76,7 +76,7 @@
 
     let path = Path::new("message.txt");
     let mut file = BufferedReader::new(File::open(&path));
-    let lines: Vec<~str> = file.lines().map(|x| x.unwrap()).collect();
+    let lines: Vec<StrBuf> = file.lines().map(|x| x.unwrap()).collect();
     ```
 
 * Make a simple TCP client connection and request
@@ -228,6 +228,7 @@ fn file_product(p: &Path) -> IoResult<u32> {
 use slice::{Vector, MutableVector, ImmutableVector};
 use str::{StrSlice, StrAllocating};
 use str;
+use strbuf::StrBuf;
 use uint;
 use vec::Vec;
 
@@ -292,7 +293,7 @@ pub struct IoError {
     /// A human-readable description about the error
     pub desc: &'static str,
     /// Detailed information about this error, not always available
-    pub detail: Option<~str>
+    pub detail: Option<StrBuf>
 }
 
 impl IoError {
@@ -364,7 +365,11 @@ fn get_err(errno: i32) -> (IoErrorKind, &'static str) {
         IoError {
             kind: kind,
             desc: desc,
-            detail: if detail {Some(os::error_string(errno))} else {None},
+            detail: if detail {
+                Some(os::error_string(errno))
+            } else {
+                None
+            },
         }
     }
 
@@ -490,8 +495,10 @@ pub trait Reader {
     /// bytes are read.
     fn read_at_least(&mut self, min: uint, buf: &mut [u8]) -> IoResult<uint> {
         if min > buf.len() {
-            return Err(IoError { detail: Some("the buffer is too short".to_owned()),
-                                 ..standard_error(InvalidInput) });
+            return Err(IoError {
+                detail: Some("the buffer is too short".to_strbuf()),
+                ..standard_error(InvalidInput)
+            });
         }
         let mut read = 0;
         while read < min {
@@ -556,8 +563,10 @@ fn push(&mut self, len: uint, buf: &mut Vec<u8>) -> IoResult<uint> {
     /// bytes are read.
     fn push_at_least(&mut self, min: uint, len: uint, buf: &mut Vec<u8>) -> IoResult<uint> {
         if min > len {
-            return Err(IoError { detail: Some("the buffer is too short".to_owned()),
-                                 ..standard_error(InvalidInput) });
+            return Err(IoError {
+                detail: Some("the buffer is too short".to_strbuf()),
+                ..standard_error(InvalidInput)
+            });
         }
 
         let start_len = buf.len();
@@ -623,10 +632,10 @@ fn read_to_end(&mut self) -> IoResult<Vec<u8>> {
     /// This function returns all of the same errors as `read_to_end` with an
     /// additional error if the reader's contents are not a valid sequence of
     /// UTF-8 bytes.
-    fn read_to_str(&mut self) -> IoResult<~str> {
+    fn read_to_str(&mut self) -> IoResult<StrBuf> {
         self.read_to_end().and_then(|s| {
             match str::from_utf8(s.as_slice()) {
-                Some(s) => Ok(s.to_owned()),
+                Some(s) => Ok(s.to_strbuf()),
                 None => Err(standard_error(InvalidInput)),
             }
         })
@@ -1235,8 +1244,8 @@ pub struct Lines<'r, T> {
     buffer: &'r mut T,
 }
 
-impl<'r, T: Buffer> Iterator<IoResult<~str>> for Lines<'r, T> {
-    fn next(&mut self) -> Option<IoResult<~str>> {
+impl<'r, T: Buffer> Iterator<IoResult<StrBuf>> for Lines<'r, T> {
+    fn next(&mut self) -> Option<IoResult<StrBuf>> {
         match self.buffer.read_line() {
             Ok(x) => Some(Ok(x)),
             Err(IoError { kind: EndOfFile, ..}) => None,
@@ -1321,10 +1330,10 @@ pub trait Buffer: Reader {
     ///
     /// Additionally, this function can fail if the line of input read is not a
     /// valid UTF-8 sequence of bytes.
-    fn read_line(&mut self) -> IoResult<~str> {
+    fn read_line(&mut self) -> IoResult<StrBuf> {
         self.read_until('\n' as u8).and_then(|line|
             match str::from_utf8(line.as_slice()) {
-                Some(s) => Ok(s.to_owned()),
+                Some(s) => Ok(s.to_strbuf()),
                 None => Err(standard_error(InvalidInput)),
             }
         )
index f469c419e8ef7962b0994a7a8f1c8082aed5fd1b..4bf71b5480e2f84552c7aa55361ff649aeaf86d0 100644 (file)
@@ -445,8 +445,8 @@ fn test_from_str_socket_addr() {
     #[test]
     fn ipv6_addr_to_str() {
         let a1 = Ipv6Addr(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x280);
-        assert!(a1.to_str() == "::ffff:192.0.2.128".to_owned() ||
-                a1.to_str() == "::FFFF:192.0.2.128".to_owned());
-        assert_eq!(Ipv6Addr(8, 9, 10, 11, 12, 13, 14, 15).to_str(), "8:9:a:b:c:d:e:f".to_owned());
+        assert!(a1.to_str() == "::ffff:192.0.2.128".to_strbuf() ||
+                a1.to_str() == "::FFFF:192.0.2.128".to_strbuf());
+        assert_eq!(Ipv6Addr(8, 9, 10, 11, 12, 13, 14, 15).to_str(), "8:9:a:b:c:d:e:f".to_strbuf());
     }
 }
index dec68b9d89e6d693f60b9a01321417ba545d4733..ac17bc1de13799b1c9da39122f50acc947bee69b 100644 (file)
@@ -434,7 +434,7 @@ mod test {
         let socket_addr = next_test_ip4();
         let ip_str = socket_addr.ip.to_str();
         let port = socket_addr.port;
-        let listener = TcpListener::bind(ip_str, port);
+        let listener = TcpListener::bind(ip_str.as_slice(), port);
         let mut acceptor = listener.listen();
 
         spawn(proc() {
@@ -452,7 +452,7 @@ mod test {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             let mut stream = TcpStream::connect("localhost", addr.port);
@@ -469,7 +469,7 @@ mod test {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             let mut stream = TcpStream::connect("127.0.0.1", addr.port);
@@ -486,7 +486,7 @@ mod test {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             let mut stream = TcpStream::connect("::1", addr.port);
@@ -503,10 +503,10 @@ mod test {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let mut stream = TcpStream::connect(ip_str, port);
+            let mut stream = TcpStream::connect(ip_str.as_slice(), port);
             stream.write([99]).unwrap();
         });
 
@@ -520,10 +520,10 @@ mod test {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let mut stream = TcpStream::connect(ip_str, port);
+            let mut stream = TcpStream::connect(ip_str.as_slice(), port);
             stream.write([99]).unwrap();
         });
 
@@ -537,10 +537,10 @@ mod test {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let _stream = TcpStream::connect(ip_str, port);
+            let _stream = TcpStream::connect(ip_str.as_slice(), port);
             // Close
         });
 
@@ -554,10 +554,10 @@ mod test {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let _stream = TcpStream::connect(ip_str, port);
+            let _stream = TcpStream::connect(ip_str.as_slice(), port);
             // Close
         });
 
@@ -571,10 +571,10 @@ mod test {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let _stream = TcpStream::connect(ip_str, port);
+            let _stream = TcpStream::connect(ip_str.as_slice(), port);
             // Close
         });
 
@@ -596,10 +596,10 @@ mod test {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let _stream = TcpStream::connect(ip_str, port);
+            let _stream = TcpStream::connect(ip_str.as_slice(), port);
             // Close
         });
 
@@ -621,10 +621,10 @@ mod test {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let _stream = TcpStream::connect(ip_str, port);
+            let _stream = TcpStream::connect(ip_str.as_slice(), port);
             // Close
         });
 
@@ -648,10 +648,10 @@ mod test {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let _stream = TcpStream::connect(ip_str, port);
+            let _stream = TcpStream::connect(ip_str.as_slice(), port);
             // Close
         });
 
@@ -676,11 +676,11 @@ mod test {
         let ip_str = addr.ip.to_str();
         let port = addr.port;
         let max = 10u;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             for _ in range(0, max) {
-                let mut stream = TcpStream::connect(ip_str, port);
+                let mut stream = TcpStream::connect(ip_str.as_slice(), port);
                 stream.write([99]).unwrap();
             }
         });
@@ -697,11 +697,11 @@ mod test {
         let ip_str = addr.ip.to_str();
         let port = addr.port;
         let max = 10u;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             for _ in range(0, max) {
-                let mut stream = TcpStream::connect(ip_str, port);
+                let mut stream = TcpStream::connect(ip_str.as_slice(), port);
                 stream.write([99]).unwrap();
             }
         });
@@ -718,7 +718,7 @@ mod test {
         let ip_str = addr.ip.to_str();
         let port = addr.port;
         static MAX: int = 10;
-        let acceptor = TcpListener::bind(ip_str, port).listen();
+        let acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             let mut acceptor = acceptor;
@@ -743,7 +743,7 @@ fn connect(i: int, addr: SocketAddr) {
 
             spawn(proc() {
                 debug!("connecting");
-                let mut stream = TcpStream::connect(ip_str, port);
+                let mut stream = TcpStream::connect(ip_str.as_slice(), port);
                 // Connect again before writing
                 connect(i + 1, addr);
                 debug!("writing");
@@ -757,7 +757,7 @@ fn connect(i: int, addr: SocketAddr) {
         let ip_str = addr.ip.to_str();
         let port = addr.port;
         static MAX: int = 10;
-        let acceptor = TcpListener::bind(ip_str, port).listen();
+        let acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             let mut acceptor = acceptor;
@@ -782,7 +782,7 @@ fn connect(i: int, addr: SocketAddr) {
 
             spawn(proc() {
                 debug!("connecting");
-                let mut stream = TcpStream::connect(ip_str, port);
+                let mut stream = TcpStream::connect(ip_str.as_slice(), port);
                 // Connect again before writing
                 connect(i + 1, addr);
                 debug!("writing");
@@ -796,7 +796,7 @@ fn connect(i: int, addr: SocketAddr) {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let acceptor = TcpListener::bind(ip_str, port).listen();
+        let acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             let mut acceptor = acceptor;
@@ -821,7 +821,7 @@ fn connect(i: int, addr: SocketAddr) {
 
             spawn(proc() {
                 debug!("connecting");
-                let mut stream = TcpStream::connect(ip_str, port);
+                let mut stream = TcpStream::connect(ip_str.as_slice(), port);
                 // Connect again before writing
                 connect(i + 1, addr);
                 debug!("writing");
@@ -835,7 +835,7 @@ fn connect(i: int, addr: SocketAddr) {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let acceptor = TcpListener::bind(ip_str, port).listen();
+        let acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
             let mut acceptor = acceptor;
@@ -860,7 +860,7 @@ fn connect(i: int, addr: SocketAddr) {
 
             spawn(proc() {
                 debug!("connecting");
-                let mut stream = TcpStream::connect(ip_str, port);
+                let mut stream = TcpStream::connect(ip_str.as_slice(), port);
                 // Connect again before writing
                 connect(i + 1, addr);
                 debug!("writing");
@@ -872,7 +872,7 @@ fn connect(i: int, addr: SocketAddr) {
     pub fn socket_name(addr: SocketAddr) {
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut listener = TcpListener::bind(ip_str, port).unwrap();
+        let mut listener = TcpListener::bind(ip_str.as_slice(), port).unwrap();
 
         // Make sure socket_name gives
         // us the socket we binded to.
@@ -884,13 +884,13 @@ pub fn socket_name(addr: SocketAddr) {
     pub fn peer_name(addr: SocketAddr) {
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let acceptor = TcpListener::bind(ip_str, port).listen();
+        let acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
         spawn(proc() {
             let mut acceptor = acceptor;
             acceptor.accept().unwrap();
         });
 
-        let stream = TcpStream::connect(ip_str, port);
+        let stream = TcpStream::connect(ip_str.as_slice(), port);
 
         assert!(stream.is_ok());
         let mut stream = stream.unwrap();
@@ -920,7 +920,7 @@ pub fn peer_name(addr: SocketAddr) {
         let (tx, rx) = channel();
         spawn(proc() {
             let ip_str = addr.ip.to_str();
-            let mut srv = TcpListener::bind(ip_str, port).listen().unwrap();
+            let mut srv = TcpListener::bind(ip_str.as_slice(), port).listen().unwrap();
             tx.send(());
             let mut cl = srv.accept().unwrap();
             cl.write([10]).unwrap();
@@ -931,7 +931,7 @@ pub fn peer_name(addr: SocketAddr) {
 
         rx.recv();
         let ip_str = addr.ip.to_str();
-        let mut c = TcpStream::connect(ip_str, port).unwrap();
+        let mut c = TcpStream::connect(ip_str.as_slice(), port).unwrap();
         let mut b = [0, ..10];
         assert_eq!(c.read(b), Ok(1));
         c.write([1]).unwrap();
@@ -942,9 +942,9 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let listener = TcpListener::bind(ip_str, port).unwrap().listen();
+        let listener = TcpListener::bind(ip_str.as_slice(), port).unwrap().listen();
         assert!(listener.is_ok());
-        match TcpListener::bind(ip_str, port).listen() {
+        match TcpListener::bind(ip_str.as_slice(), port).listen() {
             Ok(..) => fail!(),
             Err(e) => {
                 assert!(e.kind == ConnectionRefused || e.kind == OtherIoError);
@@ -960,14 +960,14 @@ pub fn peer_name(addr: SocketAddr) {
         spawn(proc() {
             let ip_str = addr.ip.to_str();
             rx.recv();
-            let _stream = TcpStream::connect(ip_str, port).unwrap();
+            let _stream = TcpStream::connect(ip_str.as_slice(), port).unwrap();
             // Close
             rx.recv();
         });
 
         {
             let ip_str = addr.ip.to_str();
-            let mut acceptor = TcpListener::bind(ip_str, port).listen();
+            let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
             tx.send(());
             {
                 let _stream = acceptor.accept().unwrap();
@@ -976,17 +976,17 @@ pub fn peer_name(addr: SocketAddr) {
             }
             // Close listener
         }
-        let _listener = TcpListener::bind(addr.ip.to_str(), port);
+        let _listener = TcpListener::bind(addr.ip.to_str().as_slice(), port);
     })
 
     iotest!(fn tcp_clone_smoke() {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let mut s = TcpStream::connect(ip_str, port);
+            let mut s = TcpStream::connect(ip_str.as_slice(), port);
             let mut buf = [0, 0];
             assert_eq!(s.read(buf), Ok(1));
             assert_eq!(buf[0], 1);
@@ -1014,12 +1014,12 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
         let (tx1, rx) = channel();
         let tx2 = tx1.clone();
 
         spawn(proc() {
-            let mut s = TcpStream::connect(ip_str, port);
+            let mut s = TcpStream::connect(ip_str.as_slice(), port);
             s.write([1]).unwrap();
             rx.recv();
             s.write([2]).unwrap();
@@ -1048,10 +1048,10 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut acceptor = TcpListener::bind(ip_str, port).listen();
+        let mut acceptor = TcpListener::bind(ip_str.as_slice(), port).listen();
 
         spawn(proc() {
-            let mut s = TcpStream::connect(ip_str, port);
+            let mut s = TcpStream::connect(ip_str.as_slice(), port);
             let mut buf = [0, 1];
             s.read(buf).unwrap();
             s.read(buf).unwrap();
@@ -1077,7 +1077,7 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let a = TcpListener::bind(ip_str, port).unwrap().listen();
+        let a = TcpListener::bind(ip_str.as_slice(), port).unwrap().listen();
         spawn(proc() {
             let mut a = a;
             let mut c = a.accept().unwrap();
@@ -1085,7 +1085,7 @@ pub fn peer_name(addr: SocketAddr) {
             c.write([1]).unwrap();
         });
 
-        let mut s = TcpStream::connect(ip_str, port).unwrap();
+        let mut s = TcpStream::connect(ip_str.as_slice(), port).unwrap();
         assert!(s.obj.close_write().is_ok());
         assert!(s.write([1]).is_err());
         assert_eq!(s.read_to_end(), Ok(vec!(1)));
@@ -1095,7 +1095,7 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut a = TcpListener::bind(ip_str, port).unwrap().listen().unwrap();
+        let mut a = TcpListener::bind(ip_str.as_slice(), port).unwrap().listen().unwrap();
 
         a.set_timeout(Some(10));
 
@@ -1114,7 +1114,8 @@ pub fn peer_name(addr: SocketAddr) {
         if !cfg!(target_os = "freebsd") {
             let (tx, rx) = channel();
             spawn(proc() {
-                tx.send(TcpStream::connect(addr.ip.to_str(), port).unwrap());
+                tx.send(TcpStream::connect(addr.ip.to_str().as_slice(),
+                                           port).unwrap());
             });
             let _l = rx.recv();
             for i in range(0, 1001) {
@@ -1131,7 +1132,8 @@ pub fn peer_name(addr: SocketAddr) {
         // Unset the timeout and make sure that this always blocks.
         a.set_timeout(None);
         spawn(proc() {
-            drop(TcpStream::connect(addr.ip.to_str(), port).unwrap());
+            drop(TcpStream::connect(addr.ip.to_str().as_slice(),
+                                    port).unwrap());
         });
         a.accept().unwrap();
     })
@@ -1140,7 +1142,7 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let a = TcpListener::bind(ip_str, port).listen().unwrap();
+        let a = TcpListener::bind(ip_str.as_slice(), port).listen().unwrap();
         let (_tx, rx) = channel::<()>();
         spawn(proc() {
             let mut a = a;
@@ -1149,7 +1151,7 @@ pub fn peer_name(addr: SocketAddr) {
         });
 
         let mut b = [0];
-        let mut s = TcpStream::connect(ip_str, port).unwrap();
+        let mut s = TcpStream::connect(ip_str.as_slice(), port).unwrap();
         let mut s2 = s.clone();
 
         // closing should prevent reads/writes
@@ -1178,7 +1180,7 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip4();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let a = TcpListener::bind(ip_str, port).listen().unwrap();
+        let a = TcpListener::bind(ip_str.as_slice(), port).listen().unwrap();
         let (_tx, rx) = channel::<()>();
         spawn(proc() {
             let mut a = a;
@@ -1186,7 +1188,7 @@ pub fn peer_name(addr: SocketAddr) {
             let _ = rx.recv_opt();
         });
 
-        let mut s = TcpStream::connect(ip_str, port).unwrap();
+        let mut s = TcpStream::connect(ip_str.as_slice(), port).unwrap();
         let s2 = s.clone();
         let (tx, rx) = channel();
         spawn(proc() {
@@ -1205,10 +1207,10 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut a = TcpListener::bind(ip_str, port).listen().unwrap();
+        let mut a = TcpListener::bind(ip_str.as_slice(), port).listen().unwrap();
         let (tx, rx) = channel::<()>();
         spawn(proc() {
-            let mut s = TcpStream::connect(ip_str, port).unwrap();
+            let mut s = TcpStream::connect(ip_str.as_slice(), port).unwrap();
             rx.recv();
             assert!(s.write([0]).is_ok());
             let _ = rx.recv_opt();
@@ -1239,10 +1241,10 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut a = TcpListener::bind(ip_str, port).listen().unwrap();
+        let mut a = TcpListener::bind(ip_str.as_slice(), port).listen().unwrap();
         let (tx, rx) = channel::<()>();
         spawn(proc() {
-            let mut s = TcpStream::connect(ip_str, port).unwrap();
+            let mut s = TcpStream::connect(ip_str.as_slice(), port).unwrap();
             rx.recv();
             let mut amt = 0;
             while amt < 100 * 128 * 1024 {
@@ -1269,10 +1271,10 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut a = TcpListener::bind(ip_str, port).listen().unwrap();
+        let mut a = TcpListener::bind(ip_str.as_slice(), port).listen().unwrap();
         let (tx, rx) = channel::<()>();
         spawn(proc() {
-            let mut s = TcpStream::connect(ip_str, port).unwrap();
+            let mut s = TcpStream::connect(ip_str.as_slice(), port).unwrap();
             rx.recv();
             assert!(s.write([0]).is_ok());
             let _ = rx.recv_opt();
@@ -1298,10 +1300,10 @@ pub fn peer_name(addr: SocketAddr) {
         let addr = next_test_ip6();
         let ip_str = addr.ip.to_str();
         let port = addr.port;
-        let mut a = TcpListener::bind(ip_str, port).listen().unwrap();
+        let mut a = TcpListener::bind(ip_str.as_slice(), port).listen().unwrap();
         let (tx, rx) = channel::<()>();
         spawn(proc() {
-            let mut s = TcpStream::connect(ip_str, port).unwrap();
+            let mut s = TcpStream::connect(ip_str.as_slice(), port).unwrap();
             rx.recv();
             assert_eq!(s.write([0]), Ok(()));
             let _ = rx.recv_opt();
index fc760e6fe4ca312cd874369a7ac17df517b2dc1a..7d84530282ff35d5a63bd5a46ce6483c8a2a9bbf 100644 (file)
@@ -583,11 +583,11 @@ mod tests {
         }
     })
 
-    pub fn read_all(input: &mut Reader) -> ~str {
+    pub fn read_all(input: &mut Reader) -> StrBuf {
         input.read_to_str().unwrap()
     }
 
-    pub fn run_output(cmd: Command) -> ~str {
+    pub fn run_output(cmd: Command) -> StrBuf {
         let p = cmd.spawn();
         assert!(p.is_ok());
         let mut p = p.unwrap();
@@ -601,7 +601,7 @@ pub fn run_output(cmd: Command) -> ~str {
     iotest!(fn stdout_works() {
         let mut cmd = Command::new("echo");
         cmd.arg("foobar").stdout(CreatePipe(false, true));
-        assert_eq!(run_output(cmd), "foobar\n".to_owned());
+        assert_eq!(run_output(cmd), "foobar\n".to_strbuf());
     })
 
     #[cfg(unix, not(target_os="android"))]
@@ -610,7 +610,7 @@ pub fn run_output(cmd: Command) -> ~str {
         cmd.arg("-c").arg("pwd")
            .cwd(&Path::new("/"))
            .stdout(CreatePipe(false, true));
-        assert_eq!(run_output(cmd), "/\n".to_owned());
+        assert_eq!(run_output(cmd), "/\n".to_strbuf());
     })
 
     #[cfg(unix, not(target_os="android"))]
@@ -624,7 +624,7 @@ pub fn run_output(cmd: Command) -> ~str {
         drop(p.stdin.take());
         let out = read_all(p.stdout.get_mut_ref() as &mut Reader);
         assert!(p.wait().unwrap().success());
-        assert_eq!(out, "foobar\n".to_owned());
+        assert_eq!(out, "foobar\n".to_strbuf());
     })
 
     #[cfg(not(target_os="android"))]
@@ -682,7 +682,7 @@ pub fn run_output(cmd: Command) -> ~str {
         let output_str = str::from_utf8(output.as_slice()).unwrap();
 
         assert!(status.success());
-        assert_eq!(output_str.trim().to_owned(), "hello".to_owned());
+        assert_eq!(output_str.trim().to_strbuf(), "hello".to_strbuf());
         // FIXME #7224
         if !running_on_valgrind() {
             assert_eq!(error, Vec::new());
@@ -719,7 +719,7 @@ pub fn run_output(cmd: Command) -> ~str {
         let output_str = str::from_utf8(output.as_slice()).unwrap();
 
         assert!(status.success());
-        assert_eq!(output_str.trim().to_owned(), "hello".to_owned());
+        assert_eq!(output_str.trim().to_strbuf(), "hello".to_strbuf());
         // FIXME #7224
         if !running_on_valgrind() {
             assert_eq!(error, Vec::new());
@@ -749,9 +749,9 @@ pub fn pwd_cmd() -> Command {
         let prog = pwd_cmd().spawn().unwrap();
 
         let output = str::from_utf8(prog.wait_with_output().unwrap()
-                                        .output.as_slice()).unwrap().to_owned();
+                                        .output.as_slice()).unwrap().to_strbuf();
         let parent_dir = os::getcwd();
-        let child_dir = Path::new(output.trim());
+        let child_dir = Path::new(output.as_slice().trim());
 
         let parent_stat = parent_dir.stat().unwrap();
         let child_stat = child_dir.stat().unwrap();
@@ -768,8 +768,8 @@ pub fn pwd_cmd() -> Command {
         let prog = pwd_cmd().cwd(&parent_dir).spawn().unwrap();
 
         let output = str::from_utf8(prog.wait_with_output().unwrap()
-                                        .output.as_slice()).unwrap().to_owned();
-        let child_dir = Path::new(output.trim());
+                                        .output.as_slice()).unwrap().to_strbuf();
+        let child_dir = Path::new(output.as_slice().trim().into_strbuf());
 
         let parent_stat = parent_dir.stat().unwrap();
         let child_stat = child_dir.stat().unwrap();
@@ -803,12 +803,14 @@ pub fn env_cmd() -> Command {
 
         let prog = env_cmd().spawn().unwrap();
         let output = str::from_utf8(prog.wait_with_output().unwrap()
-                                        .output.as_slice()).unwrap().to_owned();
+                                        .output.as_slice()).unwrap().to_strbuf();
 
         let r = os::env();
         for &(ref k, ref v) in r.iter() {
             // don't check windows magical empty-named variables
-            assert!(k.is_empty() || output.contains(format!("{}={}", *k, *v)));
+            assert!(k.is_empty() ||
+                    output.as_slice()
+                          .contains(format!("{}={}", *k, *v).as_slice()));
         }
     })
     #[cfg(target_os="android")]
@@ -819,14 +821,20 @@ pub fn env_cmd() -> Command {
         let mut prog = env_cmd().spawn().unwrap();
         let output = str::from_utf8(prog.wait_with_output()
                                         .unwrap().output.as_slice())
-                                   .unwrap().to_owned();
+                                   .unwrap().to_strbuf();
 
         let r = os::env();
         for &(ref k, ref v) in r.iter() {
             // don't check android RANDOM variables
-            if *k != "RANDOM".to_owned() {
-                assert!(output.contains(format!("{}={}", *k, *v)) ||
-                        output.contains(format!("{}=\'{}\'", *k, *v)));
+            if *k != "RANDOM".to_strbuf() {
+                assert!(output.as_slice()
+                              .contains(format!("{}={}",
+                                                *k,
+                                                *v).as_slice()) ||
+                        output.as_slice()
+                              .contains(format!("{}=\'{}\'",
+                                                *k,
+                                                *v).as_slice()));
             }
         }
     })
@@ -835,9 +843,9 @@ pub fn env_cmd() -> Command {
         let new_env = box [("RUN_TEST_NEW_ENV", "123")];
         let prog = env_cmd().env(new_env).spawn().unwrap();
         let result = prog.wait_with_output().unwrap();
-        let output = str::from_utf8_lossy(result.output.as_slice()).into_owned();
+        let output = str::from_utf8_lossy(result.output.as_slice()).into_strbuf();
 
-        assert!(output.contains("RUN_TEST_NEW_ENV=123"),
+        assert!(output.as_slice().contains("RUN_TEST_NEW_ENV=123"),
                 "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
     })
 
index 991f3992dd1bd4952d80fb49a1722ce2498b76b4..3a103651d635f6693e50033795d014ef98b35137 100644 (file)
@@ -409,7 +409,7 @@ mod tests {
             set_stdout(box w);
             println!("hello!");
         });
-        assert_eq!(r.read_to_str().unwrap(), "hello!\n".to_owned());
+        assert_eq!(r.read_to_str().unwrap(), "hello!\n".to_strbuf());
     })
 
     iotest!(fn capture_stderr() {
@@ -422,6 +422,6 @@ mod tests {
             fail!("my special message");
         });
         let s = r.read_to_str().unwrap();
-        assert!(s.contains("my special message"));
+        assert!(s.as_slice().contains("my special message"));
     })
 }
index b4fb95c8af7702769858038a2a4180a99d561df4..806df838c919e36d491b15913543d2539144382e 100644 (file)
@@ -42,10 +42,11 @@ pub fn new_in(tmpdir: &Path, suffix: &str) -> Option<TempDir> {
         static mut CNT: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
 
         for _ in range(0u, 1000) {
-            let filename = format!("rs-{}-{}-{}",
-                                   unsafe { libc::getpid() },
-                                   unsafe { CNT.fetch_add(1, atomics::SeqCst) },
-                                   suffix);
+            let filename =
+                format_strbuf!("rs-{}-{}-{}",
+                               unsafe { libc::getpid() },
+                               unsafe { CNT.fetch_add(1, atomics::SeqCst) },
+                               suffix);
             let p = tmpdir.join(filename);
             match fs::mkdir(&p, io::UserRWX) {
                 Err(..) => {}
index dd874fecc52a5d32de0a6f7982bbc3e73294a6ea..de8a6f4beb5ea3102bad955d034d578bbe409cb0 100644 (file)
@@ -67,14 +67,14 @@ pub fn next_test_unix() -> Path {
     // base port and pid are an attempt to be unique between multiple
     // test-runners of different configurations running on one
     // buildbot, the count is to be unique within this executable.
-    let string = format!("rust-test-unix-path-{}-{}-{}",
-                         base_port(),
-                         unsafe {libc::getpid()},
-                         unsafe {COUNT.fetch_add(1, Relaxed)});
+    let string = format_strbuf!("rust-test-unix-path-{}-{}-{}",
+                                base_port(),
+                                unsafe {libc::getpid()},
+                                unsafe {COUNT.fetch_add(1, Relaxed)});
     if cfg!(unix) {
         os::tmpdir().join(string)
     } else {
-        Path::new(r"\\.\pipe\" + string)
+        Path::new(format_strbuf!("{}{}", r"\\.\pipe\", string))
     }
 }
 
index a9ec9c1ddc5ac0ed5f5e819e909b5e24b6c6d52e..22ac397c702c32d7c1c947b7ad1ed11b3ba1fa84 100644 (file)
@@ -47,9 +47,9 @@
 //! for which the [`slice`](slice/index.html) module defines many
 //! methods.
 //!
-//! UTF-8 strings, `~str` and `&str`, are built-in types, and the
-//! standard library defines methods for them on a variety of traits
-//! in the [`str`](str/index.html) module. Rust strings are immutable;
+//! `&str`, a UTF-8 string, is a built-in type, and the standard library
+//! defines methods for it on a variety of traits in the
+//! [`str`](str/index.html) module. Rust strings are immutable;
 //! use the `StrBuf` type defined in [`strbuf`](strbuf/index.html)
 //! for a mutable string builder.
 //!
@@ -284,4 +284,5 @@ mod std {
 
     // The test runner requires std::slice::Vector, so re-export std::slice just for it.
     #[cfg(test)] pub use slice;
+    #[cfg(test)] pub use strbuf;
 }
index 1a971594837df31e91ab622dda3138ec8d00cafa..8798c035fcaf18036bad53f0d39e2e8f2762961c 100644 (file)
@@ -274,12 +274,12 @@ mod tests {
 
     #[test]
     fn test_tls_multitask() {
-        static my_key: Key<~str> = &Key;
-        my_key.replace(Some("parent data".to_owned()));
+        static my_key: Key<StrBuf> = &Key;
+        my_key.replace(Some("parent data".to_strbuf()));
         task::spawn(proc() {
             // TLS shouldn't carry over.
             assert!(my_key.get().is_none());
-            my_key.replace(Some("child data".to_owned()));
+            my_key.replace(Some("child data".to_strbuf()));
             assert!(my_key.get().get_ref().as_slice() == "child data");
             // should be cleaned up for us
         });
@@ -292,17 +292,17 @@ fn test_tls_multitask() {
 
     #[test]
     fn test_tls_overwrite() {
-        static my_key: Key<~str> = &Key;
-        my_key.replace(Some("first data".to_owned()));
-        my_key.replace(Some("next data".to_owned())); // Shouldn't leak.
+        static my_key: Key<StrBuf> = &Key;
+        my_key.replace(Some("first data".to_strbuf()));
+        my_key.replace(Some("next data".to_strbuf())); // Shouldn't leak.
         assert!(my_key.get().unwrap().as_slice() == "next data");
     }
 
     #[test]
     fn test_tls_pop() {
-        static my_key: Key<~str> = &Key;
-        my_key.replace(Some("weasel".to_owned()));
-        assert!(my_key.replace(None).unwrap() == "weasel".to_owned());
+        static my_key: Key<StrBuf> = &Key;
+        my_key.replace(Some("weasel".to_strbuf()));
+        assert!(my_key.replace(None).unwrap() == "weasel".to_strbuf());
         // Pop must remove the data from the map.
         assert!(my_key.replace(None).is_none());
     }
@@ -315,19 +315,19 @@ fn test_tls_crust_automorestack_memorial_bug() {
         // to get recorded as something within a rust stack segment. Then a
         // subsequent upcall (esp. for logging, think vsnprintf) would run on
         // a stack smaller than 1 MB.
-        static my_key: Key<~str> = &Key;
+        static my_key: Key<StrBuf> = &Key;
         task::spawn(proc() {
-            my_key.replace(Some("hax".to_owned()));
+            my_key.replace(Some("hax".to_strbuf()));
         });
     }
 
     #[test]
     fn test_tls_multiple_types() {
-        static str_key: Key<~str> = &Key;
+        static str_key: Key<StrBuf> = &Key;
         static box_key: Key<@()> = &Key;
         static int_key: Key<int> = &Key;
         task::spawn(proc() {
-            str_key.replace(Some("string data".to_owned()));
+            str_key.replace(Some("string data".to_strbuf()));
             box_key.replace(Some(@()));
             int_key.replace(Some(42));
         });
@@ -335,12 +335,12 @@ fn test_tls_multiple_types() {
 
     #[test]
     fn test_tls_overwrite_multiple_types() {
-        static str_key: Key<~str> = &Key;
+        static str_key: Key<StrBuf> = &Key;
         static box_key: Key<@()> = &Key;
         static int_key: Key<int> = &Key;
         task::spawn(proc() {
-            str_key.replace(Some("string data".to_owned()));
-            str_key.replace(Some("string data 2".to_owned()));
+            str_key.replace(Some("string data".to_strbuf()));
+            str_key.replace(Some("string data 2".to_strbuf()));
             box_key.replace(Some(@()));
             box_key.replace(Some(@()));
             int_key.replace(Some(42));
@@ -354,13 +354,13 @@ fn test_tls_overwrite_multiple_types() {
     #[test]
     #[should_fail]
     fn test_tls_cleanup_on_failure() {
-        static str_key: Key<~str> = &Key;
+        static str_key: Key<StrBuf> = &Key;
         static box_key: Key<@()> = &Key;
         static int_key: Key<int> = &Key;
-        str_key.replace(Some("parent data".to_owned()));
+        str_key.replace(Some("parent data".to_strbuf()));
         box_key.replace(Some(@()));
         task::spawn(proc() {
-            str_key.replace(Some("string data".to_owned()));
+            str_key.replace(Some("string data".to_strbuf()));
             box_key.replace(Some(@()));
             int_key.replace(Some(42));
             fail!();
index e9ea0df2a7b9e4f02b3706a9f6b849827bc75f51..66d93c230a57c1eb430f28aa24327899ce9a3f63 100644 (file)
@@ -20,6 +20,7 @@
 use libc::c_int;
 use num::strconv;
 use num;
+use strbuf::StrBuf;
 
 pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON, MIN_VALUE};
 pub use core::f32::{MIN_POS_VALUE, MAX_VALUE, MIN_EXP, MAX_EXP, MIN_10_EXP};
@@ -242,7 +243,7 @@ fn atanh(self) -> f32 {
 ///
 /// * num - The float value
 #[inline]
-pub fn to_str(num: f32) -> ~str {
+pub fn to_str(num: f32) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
     r
@@ -254,7 +255,7 @@ pub fn to_str(num: f32) -> ~str {
 ///
 /// * num - The float value
 #[inline]
-pub fn to_str_hex(num: f32) -> ~str {
+pub fn to_str_hex(num: f32) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 16u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
     r
@@ -268,7 +269,7 @@ pub fn to_str_hex(num: f32) -> ~str {
 /// * num - The float value
 /// * radix - The base to use
 #[inline]
-pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) {
+pub fn to_str_radix_special(num: f32, rdx: uint) -> (StrBuf, bool) {
     strconv::float_to_str_common(num, rdx, true,
                            strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false)
 }
@@ -281,7 +282,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) {
 /// * num - The float value
 /// * digits - The number of significant digits
 #[inline]
-pub fn to_str_exact(num: f32, dig: uint) -> ~str {
+pub fn to_str_exact(num: f32, dig: uint) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigExact(dig), strconv::ExpNone, false);
     r
@@ -295,7 +296,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> ~str {
 /// * num - The float value
 /// * digits - The number of significant digits
 #[inline]
-pub fn to_str_digits(num: f32, dig: uint) -> ~str {
+pub fn to_str_digits(num: f32, dig: uint) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigMax(dig), strconv::ExpNone, false);
     r
@@ -310,7 +311,7 @@ pub fn to_str_digits(num: f32, dig: uint) -> ~str {
 /// * digits - The number of digits after the decimal point
 /// * upper - Use `E` instead of `e` for the exponent sign
 #[inline]
-pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> ~str {
+pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigExact(dig), strconv::ExpDec, upper);
     r
@@ -325,7 +326,7 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> ~str {
 /// * digits - The number of digits after the decimal point
 /// * upper - Use `E` instead of `e` for the exponent sign
 #[inline]
-pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> ~str {
+pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigMax(dig), strconv::ExpDec, upper);
     r
@@ -345,7 +346,7 @@ impl num::ToStrRadix for f32 {
     /// possible misinterpretation of the result at higher bases. If those values
     /// are expected, use `to_str_radix_special()` instead.
     #[inline]
-    fn to_str_radix(&self, rdx: uint) -> ~str {
+    fn to_str_radix(&self, rdx: uint) -> StrBuf {
         let (r, special) = strconv::float_to_str_common(
             *self, rdx, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
         if special { fail!("number has a special value, \
index 869a275b1d4089b57eb983bc99b599b54dd3f17a..be4e4dc0d66f6013950837044779cc652dd93583 100644 (file)
@@ -19,6 +19,7 @@
 use libc::c_int;
 use num::strconv;
 use num;
+use strbuf::StrBuf;
 
 pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON, MIN_VALUE};
 pub use core::f64::{MIN_POS_VALUE, MAX_VALUE, MIN_EXP, MAX_EXP, MIN_10_EXP};
@@ -250,7 +251,7 @@ fn atanh(self) -> f64 {
 ///
 /// * num - The float value
 #[inline]
-pub fn to_str(num: f64) -> ~str {
+pub fn to_str(num: f64) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
     r
@@ -262,7 +263,7 @@ pub fn to_str(num: f64) -> ~str {
 ///
 /// * num - The float value
 #[inline]
-pub fn to_str_hex(num: f64) -> ~str {
+pub fn to_str_hex(num: f64) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 16u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
     r
@@ -276,7 +277,7 @@ pub fn to_str_hex(num: f64) -> ~str {
 /// * num - The float value
 /// * radix - The base to use
 #[inline]
-pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) {
+pub fn to_str_radix_special(num: f64, rdx: uint) -> (StrBuf, bool) {
     strconv::float_to_str_common(num, rdx, true,
                            strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false)
 }
@@ -289,7 +290,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) {
 /// * num - The float value
 /// * digits - The number of significant digits
 #[inline]
-pub fn to_str_exact(num: f64, dig: uint) -> ~str {
+pub fn to_str_exact(num: f64, dig: uint) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigExact(dig), strconv::ExpNone, false);
     r
@@ -303,7 +304,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> ~str {
 /// * num - The float value
 /// * digits - The number of significant digits
 #[inline]
-pub fn to_str_digits(num: f64, dig: uint) -> ~str {
+pub fn to_str_digits(num: f64, dig: uint) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigMax(dig), strconv::ExpNone, false);
     r
@@ -318,7 +319,7 @@ pub fn to_str_digits(num: f64, dig: uint) -> ~str {
 /// * digits - The number of digits after the decimal point
 /// * upper - Use `E` instead of `e` for the exponent sign
 #[inline]
-pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> ~str {
+pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigExact(dig), strconv::ExpDec, upper);
     r
@@ -333,7 +334,7 @@ pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> ~str {
 /// * digits - The number of digits after the decimal point
 /// * upper - Use `E` instead of `e` for the exponent sign
 #[inline]
-pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> ~str {
+pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> StrBuf {
     let (r, _) = strconv::float_to_str_common(
         num, 10u, true, strconv::SignNeg, strconv::DigMax(dig), strconv::ExpDec, upper);
     r
@@ -353,7 +354,7 @@ impl num::ToStrRadix for f64 {
     /// possible misinterpretation of the result at higher bases. If those values
     /// are expected, use `to_str_radix_special()` instead.
     #[inline]
-    fn to_str_radix(&self, rdx: uint) -> ~str {
+    fn to_str_radix(&self, rdx: uint) -> StrBuf {
         let (r, special) = strconv::float_to_str_common(
             *self, rdx, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
         if special { fail!("number has a special value, \
index 396037d0dbace10cb6d897ee0e80252462441f22..7d08c181e9e391e4959ae8caeea99424fb071285 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::i16::{BITS, BYTES, MIN, MAX};
 
index 5640e82d077dc3a95eb465d39aebb5d15300bb61..2504d3f576627b050b9a9628456a6499dae8e061 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::i32::{BITS, BYTES, MIN, MAX};
 
index 40245691e3456fc118f094e261433dc058572905..7fc6a091dfcf1c133a1363b049d76745795194f4 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::i64::{BITS, BYTES, MIN, MAX};
 
index 7ddddd893e211989cc76ccdb76cba11f28f13402..a39a6ced07742e1558633bf8d1bfe75b50c9e0d5 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::i8::{BITS, BYTES, MIN, MAX};
 
index dc4d80601b7db6a0116eab77f409f584347e4946..2a23a35be6d6a93a1a67e6ae67eed7fcc356535e 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::int::{BITS, BYTES, MIN, MAX};
 
index ddff42f68dba9fe870fb49fbfb9c89586d692eab..31a0edfbc389c8337730b684c35161c78061ffb0 100644 (file)
@@ -77,8 +77,8 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
 impl ToStrRadix for $T {
     /// Convert to a string in a given base.
     #[inline]
-    fn to_str_radix(&self, radix: uint) -> ~str {
-        format!("{}", ::fmt::radix(*self, radix as u8))
+    fn to_str_radix(&self, radix: uint) -> StrBuf {
+        format_strbuf!("{}", ::fmt::radix(*self, radix as u8))
     }
 }
 
@@ -136,39 +136,39 @@ fn test_parse_bytes() {
 
     #[test]
     fn test_to_str() {
-        assert_eq!((0 as $T).to_str_radix(10u), "0".to_owned());
-        assert_eq!((1 as $T).to_str_radix(10u), "1".to_owned());
-        assert_eq!((-1 as $T).to_str_radix(10u), "-1".to_owned());
-        assert_eq!((127 as $T).to_str_radix(16u), "7f".to_owned());
-        assert_eq!((100 as $T).to_str_radix(10u), "100".to_owned());
+        assert_eq!((0 as $T).to_str_radix(10u), "0".to_strbuf());
+        assert_eq!((1 as $T).to_str_radix(10u), "1".to_strbuf());
+        assert_eq!((-1 as $T).to_str_radix(10u), "-1".to_strbuf());
+        assert_eq!((127 as $T).to_str_radix(16u), "7f".to_strbuf());
+        assert_eq!((100 as $T).to_str_radix(10u), "100".to_strbuf());
 
     }
 
     #[test]
     fn test_int_to_str_overflow() {
         let mut i8_val: i8 = 127_i8;
-        assert_eq!(i8_val.to_str(), "127".to_owned());
+        assert_eq!(i8_val.to_str(), "127".to_strbuf());
 
         i8_val += 1 as i8;
-        assert_eq!(i8_val.to_str(), "-128".to_owned());
+        assert_eq!(i8_val.to_str(), "-128".to_strbuf());
 
         let mut i16_val: i16 = 32_767_i16;
-        assert_eq!(i16_val.to_str(), "32767".to_owned());
+        assert_eq!(i16_val.to_str(), "32767".to_strbuf());
 
         i16_val += 1 as i16;
-        assert_eq!(i16_val.to_str(), "-32768".to_owned());
+        assert_eq!(i16_val.to_str(), "-32768".to_strbuf());
 
         let mut i32_val: i32 = 2_147_483_647_i32;
-        assert_eq!(i32_val.to_str(), "2147483647".to_owned());
+        assert_eq!(i32_val.to_str(), "2147483647".to_strbuf());
 
         i32_val += 1 as i32;
-        assert_eq!(i32_val.to_str(), "-2147483648".to_owned());
+        assert_eq!(i32_val.to_str(), "-2147483648".to_strbuf());
 
         let mut i64_val: i64 = 9_223_372_036_854_775_807_i64;
-        assert_eq!(i64_val.to_str(), "9223372036854775807".to_owned());
+        assert_eq!(i64_val.to_str(), "9223372036854775807".to_strbuf());
 
         i64_val += 1 as i64;
-        assert_eq!(i64_val.to_str(), "-9223372036854775808".to_owned());
+        assert_eq!(i64_val.to_str(), "-9223372036854775808".to_strbuf());
     }
 
     #[test]
index 40167718236ef6798c7bebd0d0f76f93a63ed023..c1d6bbb492db88faaa08ddb42e06974dc585d67c 100644 (file)
@@ -15,7 +15,8 @@
 
 #![allow(missing_doc)]
 
-use option::{Option};
+use option::Option;
+use strbuf::StrBuf;
 
 #[cfg(test)] use fmt::Show;
 
@@ -111,7 +112,7 @@ pub trait FloatMath: Float {
 
 /// A generic trait for converting a value to a string with a radix (base)
 pub trait ToStrRadix {
-    fn to_str_radix(&self, radix: uint) -> ~str;
+    fn to_str_radix(&self, radix: uint) -> StrBuf;
 }
 
 /// A generic trait for converting a string with a radix (base) to a value
index e58872b8395a6c388cc974eb83aa007c2bd3de6e..795534dc283722feb234ae2d53412ffb89cc7815 100644 (file)
@@ -19,9 +19,9 @@
 use num;
 use ops::{Add, Sub, Mul, Div, Rem, Neg};
 use option::{None, Option, Some};
-use slice::{CloneableVector, ImmutableVector, MutableVector};
+use slice::{ImmutableVector, MutableVector};
 use std::cmp::{Ord, Eq};
-use str::{StrAllocating, StrSlice};
+use str::StrSlice;
 use strbuf::StrBuf;
 use vec::Vec;
 
@@ -496,10 +496,10 @@ pub fn float_to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Float+
                              Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
         num: T, radix: uint, negative_zero: bool,
         sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_capital: bool
-        ) -> (~str, bool) {
+        ) -> (StrBuf, bool) {
     let (bytes, special) = float_to_str_bytes_common(num, radix,
                                negative_zero, sign, digits, exp_format, exp_capital);
-    (StrBuf::from_utf8(bytes).unwrap().into_owned(), special)
+    (StrBuf::from_utf8(bytes).unwrap(), special)
 }
 
 // Some constants for from_str_bytes_common's input validation,
index 65ac46af5aa0c80bdbc780119f221a34f1ef142b..6d68af998909415efab953195579e6eb5e7af6cd 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::u16::{BITS, BYTES, MIN, MAX};
 
index d549e4d0d636253aee6d7398f4f940344d6b32be..130ca2c48557e84c01b1b2389c6a0b5089788f1a 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::u32::{BITS, BYTES, MIN, MAX};
 
index 3773e56f4d16df1f00d51025911947936fb8b9cf..559fcf6e7d16350f3112b2b23fa2861061e3c020 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::u64::{BITS, BYTES, MIN, MAX};
 
index 372e38d66521f1173e33e3e8e9e3ebb87db25839..f855c8c4951115c2675cc50cc0e87291bcb4689f 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::u8::{BITS, BYTES, MIN, MAX};
 
index c419276fa24518024d4494e495f70e34ead2c155..f651cf72ccaf102c4c898a05ea932480b417f4a7 100644 (file)
@@ -15,6 +15,7 @@
 use num::strconv;
 use option::Option;
 use slice::ImmutableVector;
+use strbuf::StrBuf;
 
 pub use core::uint::{BITS, BYTES, MIN, MAX};
 
index 7977c647606775f695f4a84480a8dce5dfe9df46..ba329065a6eaa628a6e8d155e6ff163aac2d3ce6 100644 (file)
@@ -78,8 +78,8 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
 impl ToStrRadix for $T {
     /// Convert to a string in a given base.
     #[inline]
-    fn to_str_radix(&self, radix: uint) -> ~str {
-        format!("{}", ::fmt::radix(*self, radix as u8))
+    fn to_str_radix(&self, radix: uint) -> StrBuf {
+        format_strbuf!("{}", ::fmt::radix(*self, radix as u8))
     }
 }
 
@@ -94,13 +94,13 @@ mod tests {
 
     #[test]
     pub fn test_to_str() {
-        assert_eq!((0 as $T).to_str_radix(10u), "0".to_owned());
-        assert_eq!((1 as $T).to_str_radix(10u), "1".to_owned());
-        assert_eq!((2 as $T).to_str_radix(10u), "2".to_owned());
-        assert_eq!((11 as $T).to_str_radix(10u), "11".to_owned());
-        assert_eq!((11 as $T).to_str_radix(16u), "b".to_owned());
-        assert_eq!((255 as $T).to_str_radix(16u), "ff".to_owned());
-        assert_eq!((0xff as $T).to_str_radix(10u), "255".to_owned());
+        assert_eq!((0 as $T).to_str_radix(10u), "0".to_strbuf());
+        assert_eq!((1 as $T).to_str_radix(10u), "1".to_strbuf());
+        assert_eq!((2 as $T).to_str_radix(10u), "2".to_strbuf());
+        assert_eq!((11 as $T).to_str_radix(10u), "11".to_strbuf());
+        assert_eq!((11 as $T).to_str_radix(16u), "b".to_strbuf());
+        assert_eq!((255 as $T).to_str_radix(16u), "ff".to_strbuf());
+        assert_eq!((0xff as $T).to_str_radix(10u), "255".to_strbuf());
     }
 
     #[test]
@@ -133,28 +133,28 @@ pub fn test_parse_bytes() {
     #[test]
     fn test_uint_to_str_overflow() {
         let mut u8_val: u8 = 255_u8;
-        assert_eq!(u8_val.to_str(), "255".to_owned());
+        assert_eq!(u8_val.to_str(), "255".to_strbuf());
 
         u8_val += 1 as u8;
-        assert_eq!(u8_val.to_str(), "0".to_owned());
+        assert_eq!(u8_val.to_str(), "0".to_strbuf());
 
         let mut u16_val: u16 = 65_535_u16;
-        assert_eq!(u16_val.to_str(), "65535".to_owned());
+        assert_eq!(u16_val.to_str(), "65535".to_strbuf());
 
         u16_val += 1 as u16;
-        assert_eq!(u16_val.to_str(), "0".to_owned());
+        assert_eq!(u16_val.to_str(), "0".to_strbuf());
 
         let mut u32_val: u32 = 4_294_967_295_u32;
-        assert_eq!(u32_val.to_str(), "4294967295".to_owned());
+        assert_eq!(u32_val.to_str(), "4294967295".to_strbuf());
 
         u32_val += 1 as u32;
-        assert_eq!(u32_val.to_str(), "0".to_owned());
+        assert_eq!(u32_val.to_str(), "0".to_strbuf());
 
         let mut u64_val: u64 = 18_446_744_073_709_551_615_u64;
-        assert_eq!(u64_val.to_str(), "18446744073709551615".to_owned());
+        assert_eq!(u64_val.to_str(), "18446744073709551615".to_strbuf());
 
         u64_val += 1 as u64;
-        assert_eq!(u64_val.to_str(), "0".to_owned());
+        assert_eq!(u64_val.to_str(), "0".to_strbuf());
     }
 
     #[test]
index a4705b78caab7419c9a53e3727c095a9dcfc2340..493dd86b2763a1a0605e158eee757ba1bd3a6e09 100644 (file)
 
 use clone::Clone;
 use container::Container;
-use libc;
+use fmt;
+use iter::Iterator;
 use libc::{c_void, c_int};
+use libc;
+use ops::Drop;
 use option::{Some, None, Option};
 use os;
-use ops::Drop;
-use result::{Err, Ok, Result};
+use path::{Path, GenericPath};
+use ptr::RawPtr;
 use ptr;
-use str;
+use result::{Err, Ok, Result};
+use slice::{Vector, ImmutableVector, MutableVector, OwnedVector};
 use str::{Str, StrSlice, StrAllocating};
-use fmt;
+use str;
+use strbuf::StrBuf;
 use sync::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
-use path::{Path, GenericPath};
-use iter::Iterator;
-use slice::{Vector, CloneableVector, ImmutableVector, MutableVector, OwnedVector};
-use ptr::RawPtr;
 use vec::Vec;
 
 #[cfg(unix)]
@@ -103,12 +104,13 @@ pub mod win32 {
     use option;
     use os::TMPBUF_SZ;
     use slice::{MutableVector, ImmutableVector};
+    use strbuf::StrBuf;
     use str::{StrSlice, StrAllocating};
     use str;
     use vec::Vec;
 
     pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD)
-        -> Option<~str> {
+        -> Option<StrBuf> {
 
         unsafe {
             let mut n = TMPBUF_SZ as DWORD;
@@ -174,20 +176,20 @@ fn with_env_lock<T>(f: || -> T) -> T {
 ///
 /// Invalid UTF-8 bytes are replaced with \uFFFD. See `str::from_utf8_lossy()`
 /// for details.
-pub fn env() -> Vec<(~str,~str)> {
+pub fn env() -> Vec<(StrBuf,StrBuf)> {
     env_as_bytes().move_iter().map(|(k,v)| {
-        let k = str::from_utf8_lossy(k).into_owned();
-        let v = str::from_utf8_lossy(v).into_owned();
+        let k = str::from_utf8_lossy(k.as_slice()).to_strbuf();
+        let v = str::from_utf8_lossy(v.as_slice()).to_strbuf();
         (k,v)
     }).collect()
 }
 
 /// Returns a vector of (variable, value) byte-vector pairs for all the
 /// environment variables of the current process.
-pub fn env_as_bytes() -> Vec<(~[u8],~[u8])> {
+pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
     unsafe {
         #[cfg(windows)]
-        unsafe fn get_env_pairs() -> Vec<~[u8]> {
+        unsafe fn get_env_pairs() -> Vec<Vec<u8>> {
             use slice::raw;
 
             use libc::funcs::extra::kernel32::{
@@ -227,7 +229,7 @@ unsafe fn get_env_pairs() -> Vec<~[u8]> {
             result
         }
         #[cfg(unix)]
-        unsafe fn get_env_pairs() -> Vec<~[u8]> {
+        unsafe fn get_env_pairs() -> Vec<Vec<u8>> {
             use c_str::CString;
 
             extern {
@@ -240,18 +242,19 @@ unsafe fn get_env_pairs() -> Vec<~[u8]> {
             }
             let mut result = Vec::new();
             ptr::array_each(environ, |e| {
-                let env_pair = CString::new(e, false).as_bytes_no_nul().to_owned();
+                let env_pair =
+                    Vec::from_slice(CString::new(e, false).as_bytes_no_nul());
                 result.push(env_pair);
             });
             result
         }
 
-        fn env_convert(input: Vec<~[u8]>) -> Vec<(~[u8], ~[u8])> {
+        fn env_convert(input: Vec<Vec<u8>>) -> Vec<(Vec<u8>, Vec<u8>)> {
             let mut pairs = Vec::new();
             for p in input.iter() {
-                let mut it = p.splitn(1, |b| *b == '=' as u8);
-                let key = it.next().unwrap().to_owned();
-                let val = it.next().unwrap_or(&[]).to_owned();
+                let mut it = p.as_slice().splitn(1, |b| *b == '=' as u8);
+                let key = Vec::from_slice(it.next().unwrap());
+                let val = Vec::from_slice(it.next().unwrap_or(&[]));
                 pairs.push((key, val));
             }
             pairs
@@ -273,8 +276,8 @@ fn env_convert(input: Vec<~[u8]>) -> Vec<(~[u8], ~[u8])> {
 /// # Failure
 ///
 /// Fails if `n` has any interior NULs.
-pub fn getenv(n: &str) -> Option<~str> {
-    getenv_as_bytes(n).map(|v| str::from_utf8_lossy(v).into_owned())
+pub fn getenv(n: &str) -> Option<StrBuf> {
+    getenv_as_bytes(n).map(|v| str::from_utf8_lossy(v.as_slice()).to_strbuf())
 }
 
 #[cfg(unix)]
@@ -284,7 +287,7 @@ pub fn getenv(n: &str) -> Option<~str> {
 /// # Failure
 ///
 /// Fails if `n` has any interior NULs.
-pub fn getenv_as_bytes(n: &str) -> Option<~[u8]> {
+pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {
     use c_str::CString;
 
     unsafe {
@@ -293,7 +296,8 @@ pub fn getenv_as_bytes(n: &str) -> Option<~[u8]> {
             if s.is_null() {
                 None
             } else {
-                Some(CString::new(s, false).as_bytes_no_nul().to_owned())
+                Some(Vec::from_slice(CString::new(s,
+                                                  false).as_bytes_no_nul()))
             }
         })
     }
@@ -302,7 +306,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<~[u8]> {
 #[cfg(windows)]
 /// Fetches the environment variable `n` from the current process, returning
 /// None if the variable isn't set.
-pub fn getenv(n: &str) -> Option<~str> {
+pub fn getenv(n: &str) -> Option<StrBuf> {
     unsafe {
         with_env_lock(|| {
             use os::win32::{as_utf16_p, fill_utf16_buf_and_decode};
@@ -318,7 +322,7 @@ pub fn getenv(n: &str) -> Option<~str> {
 #[cfg(windows)]
 /// Fetches the environment variable `n` byte vector from the current process,
 /// returning None if the variable isn't set.
-pub fn getenv_as_bytes(n: &str) -> Option<~[u8]> {
+pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {
     getenv(n).map(|s| s.into_bytes())
 }
 
@@ -432,8 +436,8 @@ pub fn pipe() -> Pipe {
 }
 
 /// Returns the proper dll filename for the given basename of a file.
-pub fn dll_filename(base: &str) -> ~str {
-    format!("{}{}{}", consts::DLL_PREFIX, base, consts::DLL_SUFFIX)
+pub fn dll_filename(base: &str) -> StrBuf {
+    format_strbuf!("{}{}{}", consts::DLL_PREFIX, base, consts::DLL_SUFFIX)
 }
 
 /// Optionally returns the filesystem path of the current executable which is
@@ -527,7 +531,7 @@ pub fn self_exe_path() -> Option<Path> {
  * Otherwise, homedir returns option::none.
  */
 pub fn homedir() -> Option<Path> {
-    // FIXME (#7188): getenv needs a ~[u8] variant
+    // FIXME (#7188): getenv needs a Vec<u8> variant
     return match getenv("HOME") {
         Some(ref p) if !p.is_empty() => Path::new_opt(p.as_slice()),
         _ => secondary()
@@ -688,11 +692,11 @@ pub fn errno() -> uint {
 }
 
 /// Return the string corresponding to an `errno()` value of `errnum`.
-pub fn error_string(errnum: uint) -> ~str {
+pub fn error_string(errnum: uint) -> StrBuf {
     return strerror(errnum);
 
     #[cfg(unix)]
-    fn strerror(errnum: uint) -> ~str {
+    fn strerror(errnum: uint) -> StrBuf {
         #[cfg(target_os = "macos")]
         #[cfg(target_os = "android")]
         #[cfg(target_os = "freebsd")]
@@ -732,12 +736,12 @@ fn __xpg_strerror_r(errnum: c_int,
                 fail!("strerror_r failure");
             }
 
-            str::raw::from_c_str(p as *c_char)
+            str::raw::from_c_str(p as *c_char).into_strbuf()
         }
     }
 
     #[cfg(windows)]
-    fn strerror(errnum: uint) -> ~str {
+    fn strerror(errnum: uint) -> StrBuf {
         use libc::types::os::arch::extra::DWORD;
         use libc::types::os::arch::extra::LPWSTR;
         use libc::types::os::arch::extra::LPVOID;
@@ -789,7 +793,7 @@ fn FormatMessageW(flags: DWORD,
 }
 
 /// Get a string representing the platform-dependent last error
-pub fn last_os_error() -> ~str {
+pub fn last_os_error() -> StrBuf {
     error_string(errno() as uint)
 }
 
@@ -816,11 +820,12 @@ pub fn get_exit_status() -> int {
 }
 
 #[cfg(target_os = "macos")]
-unsafe fn load_argc_and_argv(argc: int, argv: **c_char) -> Vec<~[u8]> {
+unsafe fn load_argc_and_argv(argc: int, argv: **c_char) -> Vec<Vec<u8>> {
     use c_str::CString;
 
     Vec::from_fn(argc as uint, |i| {
-        CString::new(*argv.offset(i as int), false).as_bytes_no_nul().to_owned()
+        Vec::from_slice(CString::new(*argv.offset(i as int),
+                                     false).as_bytes_no_nul())
     })
 }
 
@@ -830,7 +835,7 @@ unsafe fn load_argc_and_argv(argc: int, argv: **c_char) -> Vec<~[u8]> {
  * Returns a list of the command line arguments.
  */
 #[cfg(target_os = "macos")]
-fn real_args_as_bytes() -> Vec<~[u8]> {
+fn real_args_as_bytes() -> Vec<Vec<u8>> {
     unsafe {
         let (argc, argv) = (*_NSGetArgc() as int,
                             *_NSGetArgv() as **c_char);
@@ -841,7 +846,7 @@ fn real_args_as_bytes() -> Vec<~[u8]> {
 #[cfg(target_os = "linux")]
 #[cfg(target_os = "android")]
 #[cfg(target_os = "freebsd")]
-fn real_args_as_bytes() -> Vec<~[u8]> {
+fn real_args_as_bytes() -> Vec<Vec<u8>> {
     use rt;
 
     match rt::args::clone() {
@@ -851,12 +856,15 @@ fn real_args_as_bytes() -> Vec<~[u8]> {
 }
 
 #[cfg(not(windows))]
-fn real_args() -> Vec<~str> {
-    real_args_as_bytes().move_iter().map(|v| str::from_utf8_lossy(v).into_owned()).collect()
+fn real_args() -> Vec<StrBuf> {
+    real_args_as_bytes().move_iter()
+                        .map(|v| {
+                            str::from_utf8_lossy(v.as_slice()).into_strbuf()
+                        }).collect()
 }
 
 #[cfg(windows)]
-fn real_args() -> Vec<~str> {
+fn real_args() -> Vec<StrBuf> {
     use slice;
     use option::Expect;
 
@@ -886,7 +894,7 @@ fn real_args() -> Vec<~str> {
 }
 
 #[cfg(windows)]
-fn real_args_as_bytes() -> Vec<~[u8]> {
+fn real_args_as_bytes() -> Vec<Vec<u8>> {
     real_args().move_iter().map(|s| s.into_bytes()).collect()
 }
 
@@ -910,13 +918,20 @@ fn real_args_as_bytes() -> Vec<~[u8]> {
 ///
 /// The arguments are interpreted as utf-8, with invalid bytes replaced with \uFFFD.
 /// See `str::from_utf8_lossy` for details.
-pub fn args() -> Vec<~str> {
+#[cfg(not(test))]
+pub fn args() -> Vec<StrBuf> {
     real_args()
 }
 
+#[cfg(test)]
+#[allow(missing_doc)]
+pub fn args() -> ::realstd::vec::Vec<::realstd::strbuf::StrBuf> {
+    ::realstd::os::args()
+}
+
 /// Returns the arguments which this program was started with (normally passed
 /// via the command line) as byte vectors.
-pub fn args_as_bytes() -> Vec<~[u8]> {
+pub fn args_as_bytes() -> Vec<Vec<u8>> {
     real_args_as_bytes()
 }
 
@@ -1509,37 +1524,37 @@ pub fn test_args() {
         assert!(a.len() >= 1);
     }
 
-    fn make_rand_name() -> ~str {
+    fn make_rand_name() -> StrBuf {
         let mut rng = rand::task_rng();
         let n = format_strbuf!("TEST{}", rng.gen_ascii_str(10u).as_slice());
         assert!(getenv(n.as_slice()).is_none());
-        n.into_owned()
+        n
     }
 
     #[test]
     fn test_setenv() {
         let n = make_rand_name();
-        setenv(n, "VALUE");
-        assert_eq!(getenv(n), option::Some("VALUE".to_owned()));
+        setenv(n.as_slice(), "VALUE");
+        assert_eq!(getenv(n.as_slice()), option::Some("VALUE".to_strbuf()));
     }
 
     #[test]
     fn test_unsetenv() {
         let n = make_rand_name();
-        setenv(n, "VALUE");
-        unsetenv(n);
-        assert_eq!(getenv(n), option::None);
+        setenv(n.as_slice(), "VALUE");
+        unsetenv(n.as_slice());
+        assert_eq!(getenv(n.as_slice()), option::None);
     }
 
     #[test]
     #[ignore]
     fn test_setenv_overwrite() {
         let n = make_rand_name();
-        setenv(n, "1");
-        setenv(n, "2");
-        assert_eq!(getenv(n), option::Some("2".to_owned()));
-        setenv(n, "");
-        assert_eq!(getenv(n), option::Some("".to_owned()));
+        setenv(n.as_slice(), "1");
+        setenv(n.as_slice(), "2");
+        assert_eq!(getenv(n.as_slice()), option::Some("2".to_strbuf()));
+        setenv(n.as_slice(), "");
+        assert_eq!(getenv(n.as_slice()), option::Some("".to_strbuf()));
     }
 
     // Windows GetEnvironmentVariable requires some extra work to make sure
@@ -1547,16 +1562,16 @@ fn test_setenv_overwrite() {
     #[test]
     #[ignore]
     fn test_getenv_big() {
-        let mut s = "".to_owned();
+        let mut s = "".to_strbuf();
         let mut i = 0;
         while i < 100 {
-            s = s + "aaaaaaaaaa";
+            s.push_str("aaaaaaaaaa");
             i += 1;
         }
         let n = make_rand_name();
-        setenv(n, s);
+        setenv(n.as_slice(), s.as_slice());
         debug!("{}", s.clone());
-        assert_eq!(getenv(n), option::Some(s));
+        assert_eq!(getenv(n.as_slice()), option::Some(s));
     }
 
     #[test]
@@ -1589,7 +1604,7 @@ fn test_env_getenv() {
         for p in e.iter() {
             let (n, v) = (*p).clone();
             debug!("{:?}", n.clone());
-            let v2 = getenv(n);
+            let v2 = getenv(n.as_slice());
             // MingW seems to set some funky environment variables like
             // "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned
             // from env() but not visible from getenv().
@@ -1600,11 +1615,11 @@ fn test_env_getenv() {
     #[test]
     fn test_env_set_get_huge() {
         let n = make_rand_name();
-        let s = "x".repeat(10000);
-        setenv(n, s);
-        assert_eq!(getenv(n), Some(s));
-        unsetenv(n);
-        assert_eq!(getenv(n), None);
+        let s = "x".repeat(10000).to_strbuf();
+        setenv(n.as_slice(), s.as_slice());
+        assert_eq!(getenv(n.as_slice()), Some(s));
+        unsetenv(n.as_slice());
+        assert_eq!(getenv(n.as_slice()), None);
     }
 
     #[test]
@@ -1612,11 +1627,11 @@ fn test_env_setenv() {
         let n = make_rand_name();
 
         let mut e = env();
-        setenv(n, "VALUE");
-        assert!(!e.contains(&(n.clone(), "VALUE".to_owned())));
+        setenv(n.as_slice(), "VALUE");
+        assert!(!e.contains(&(n.clone(), "VALUE".to_strbuf())));
 
         e = env();
-        assert!(e.contains(&(n, "VALUE".to_owned())));
+        assert!(e.contains(&(n, "VALUE".to_strbuf())));
     }
 
     #[test]
@@ -1641,7 +1656,9 @@ fn homedir() {
         setenv("HOME", "");
         assert!(os::homedir().is_none());
 
-        for s in oldhome.iter() { setenv("HOME", *s) }
+        for s in oldhome.iter() {
+            setenv("HOME", s.as_slice())
+        }
     }
 
     #[test]
@@ -1668,8 +1685,12 @@ fn homedir() {
         setenv("USERPROFILE", "/home/PaloAlto");
         assert!(os::homedir() == Some(Path::new("/home/MountainView")));
 
-        for s in oldhome.iter() { setenv("HOME", *s) }
-        for s in olduserprofile.iter() { setenv("USERPROFILE", *s) }
+        for s in oldhome.iter() {
+            setenv("HOME", s.as_slice())
+        }
+        for s in olduserprofile.iter() {
+            setenv("USERPROFILE", s.as_slice())
+        }
     }
 
     #[test]
index 2960d55f337c731ea73ab334193feba9bac2ccbe..1bd099e5d244d1900c026fde28693c3dc9cf1b26 100644 (file)
@@ -519,28 +519,12 @@ fn container_as_str<'a>(&'a self) -> Option<&'a str> {
     fn is_str(_: Option<&'a str>) -> bool { true }
 }
 
-impl BytesContainer for ~str {
-    #[inline]
-    fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
-        self.as_bytes()
-    }
-    #[inline]
-    fn container_as_str<'a>(&'a self) -> Option<&'a str> {
-        Some(self.as_slice())
-    }
-    #[inline]
-    fn is_str(_: Option<~str>) -> bool { true }
-}
 impl BytesContainer for StrBuf {
     #[inline]
     fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
         self.as_bytes()
     }
     #[inline]
-    fn container_into_owned_bytes(self) -> Vec<u8> {
-        self.into_bytes()
-    }
-    #[inline]
     fn container_as_str<'a>(&'a self) -> Option<&'a str> {
         Some(self.as_slice())
     }
index 4f7132dc6e442238af1107a7abba4a7658239d48..8a939a928465904b8cdbcc6593046bd926cebc26 100644 (file)
@@ -781,7 +781,7 @@ macro_rules! t(
         t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e");
         t!(s: "a/b/c", ["d", "/e"], "/e");
         t!(s: "a/b/c", ["d", "/e", "f"], "/e/f");
-        t!(s: "a/b/c", ["d".to_owned(), "e".to_owned()], "a/b/c/d/e");
+        t!(s: "a/b/c", ["d".to_strbuf(), "e".to_strbuf()], "a/b/c/d/e");
         t!(v: b!("a/b/c"), [b!("d"), b!("e")], b!("a/b/c/d/e"));
         t!(v: b!("a/b/c"), [b!("d"), b!("/e"), b!("f")], b!("/e/f"));
         t!(v: b!("a/b/c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))], b!("a/b/c/d/e"));
@@ -886,7 +886,7 @@ macro_rules! t(
         t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e");
         t!(s: "a/b/c", ["..", "d"], "a/b/d");
         t!(s: "a/b/c", ["d", "/e", "f"], "/e/f");
-        t!(s: "a/b/c", ["d".to_owned(), "e".to_owned()], "a/b/c/d/e");
+        t!(s: "a/b/c", ["d".to_strbuf(), "e".to_strbuf()], "a/b/c/d/e");
         t!(v: b!("a/b/c"), [b!("d"), b!("e")], b!("a/b/c/d/e"));
         t!(v: b!("a/b/c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))], b!("a/b/c/d/e"));
     }
index 176788edcc46650720f705a303e5d5c7f19ec44b..1c671b30e80d95a0b65bfb05786cd9127a9ade63 100644 (file)
@@ -136,10 +136,17 @@ unsafe fn to_c_str_unchecked(&self) -> CString {
 }
 
 impl<S: Writer> ::hash::Hash<S> for Path {
+    #[cfg(not(test))]
     #[inline]
     fn hash(&self, state: &mut S) {
         self.repr.hash(state)
     }
+
+    #[cfg(test)]
+    #[inline]
+    fn hash(&self, _: &mut S) {
+        // No-op because the `hash` implementation will be wrong.
+    }
 }
 
 impl BytesContainer for Path {
@@ -589,7 +596,7 @@ fn comp_requires_verbatim(s: &str) -> bool {
                     }
                 }
             }
-            Some(Path::new(comps.connect("\\")))
+            Some(Path::new(comps.connect("\\").into_strbuf()))
         }
     }
 
@@ -754,7 +761,10 @@ fn normalize__(s: &str, prefix: Option<PathPrefix>) -> Option<StrBuf> {
                                 let mut s = StrBuf::from_str(s.slice_to(len));
                                 unsafe {
                                     let v = s.as_mut_vec();
-                                    *v.get_mut(0) = v.get(0).to_ascii().to_upper().to_byte();
+                                    *v.get_mut(0) = v.get(0)
+                                                     .to_ascii()
+                                                     .to_upper()
+                                                     .to_byte();
                                 }
                                 if is_abs {
                                     // normalize C:/ to C:\
@@ -913,7 +923,7 @@ pub fn make_non_verbatim(path: &Path) -> Option<Path> {
         }
         Some(VerbatimUNCPrefix(_,_)) => {
             // \\?\UNC\server\share
-            Path::new(format!(r"\\{}", repr.slice_from(7)))
+            Path::new(format_strbuf!(r"\\{}", repr.slice_from(7)))
         }
     };
     if new_path.prefix.is_none() {
@@ -1331,9 +1341,9 @@ fn test_not_utf8_fail() {
     #[test]
     fn test_display_str() {
         let path = Path::new("foo");
-        assert_eq!(path.display().to_str(), "foo".to_owned());
+        assert_eq!(path.display().to_str(), "foo".to_strbuf());
         let path = Path::new(b!("\\"));
-        assert_eq!(path.filename_display().to_str(), "".to_owned());
+        assert_eq!(path.filename_display().to_str(), "".to_strbuf());
 
         let path = Path::new("foo");
         let mo = path.display().as_maybe_owned();
@@ -1594,7 +1604,7 @@ macro_rules! t(
         t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e");
         t!(s: "a\\b\\c", ["d", "\\e"], "\\e");
         t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f");
-        t!(s: "a\\b\\c", ["d".to_owned(), "e".to_owned()], "a\\b\\c\\d\\e");
+        t!(s: "a\\b\\c", ["d".to_strbuf(), "e".to_strbuf()], "a\\b\\c\\d\\e");
         t!(v: b!("a\\b\\c"), [b!("d"), b!("e")], b!("a\\b\\c\\d\\e"));
         t!(v: b!("a\\b\\c"), [b!("d"), b!("\\e"), b!("f")], b!("\\e\\f"));
         t!(v: b!("a\\b\\c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))],
@@ -1735,7 +1745,7 @@ macro_rules! t(
         t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e");
         t!(s: "a\\b\\c", ["..", "d"], "a\\b\\d");
         t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f");
-        t!(s: "a\\b\\c", ["d".to_owned(), "e".to_owned()], "a\\b\\c\\d\\e");
+        t!(s: "a\\b\\c", ["d".to_strbuf(), "e".to_strbuf()], "a\\b\\c\\d\\e");
         t!(v: b!("a\\b\\c"), [b!("d"), b!("e")], b!("a\\b\\c\\d\\e"));
         t!(v: b!("a\\b\\c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))],
            b!("a\\b\\c\\d\\e"));
index 35f32d0872802d3e3b8ad11b869d08022c5ba4d2..8da906d85219a49ce32e833e1ace02629710ee99 100644 (file)
 
 #![allow(missing_doc)]
 
-use mem::transmute;
 use char;
 use container::Container;
+use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
 use io;
 use iter::Iterator;
+use mem::transmute;
 use option::{Some, None, Option};
 use ptr::RawPtr;
-use reflect;
+use raw;
 use reflect::{MovePtr, align};
+use reflect;
 use result::{Ok, Err};
-use str::StrSlice;
-use to_str::ToStr;
 use slice::Vector;
-use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
-use raw;
+use str::{Str, StrSlice};
+use strbuf::StrBuf;
+use to_str::ToStr;
 use vec::Vec;
 
 macro_rules! try( ($me:expr, $e:expr) => (
@@ -296,10 +297,7 @@ fn visit_estr_box(&mut self) -> bool {
     }
 
     fn visit_estr_uniq(&mut self) -> bool {
-        self.get::<~str>(|this, s| {
-            try!(this, this.writer.write(['~' as u8]));
-            this.write_escaped_slice(*s)
-        })
+        true
     }
 
     fn visit_estr_slice(&mut self) -> bool {
@@ -604,14 +602,14 @@ pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> {
     }
 }
 
-pub fn repr_to_str<T>(t: &T) -> ~str {
+pub fn repr_to_str<T>(t: &T) -> StrBuf {
     use str;
     use str::StrAllocating;
     use io;
 
     let mut result = io::MemWriter::new();
     write_repr(&mut result as &mut io::Writer, t).unwrap();
-    str::from_utf8(result.unwrap().as_slice()).unwrap().to_owned()
+    str::from_utf8(result.unwrap().as_slice()).unwrap().to_strbuf()
 }
 
 #[cfg(test)]
@@ -638,8 +636,6 @@ fn exact_test<T>(t: &T, e:&str) {
     exact_test(&false, "false");
     exact_test(&1.234, "1.234f64");
     exact_test(&("hello"), "\"hello\"");
-    // FIXME What do I do about this one?
-    exact_test(&("he\u10f3llo".to_owned()), "~\"he\\u10f3llo\"");
 
     exact_test(&(@10), "@10");
     exact_test(&(box 10), "box 10");
@@ -659,14 +655,6 @@ fn exact_test<T>(t: &T, e:&str) {
                "@repr::P{a: 10, b: 1.234f64}");
     exact_test(&(box P{a:10, b:1.234}),
                "box repr::P{a: 10, b: 1.234f64}");
-    exact_test(&(10u8, "hello".to_owned()),
-               "(10u8, ~\"hello\")");
-    exact_test(&(10u16, "hello".to_owned()),
-               "(10u16, ~\"hello\")");
-    exact_test(&(10u32, "hello".to_owned()),
-               "(10u32, ~\"hello\")");
-    exact_test(&(10u64, "hello".to_owned()),
-               "(10u64, ~\"hello\")");
 
     exact_test(&(&[1, 2]), "&[1, 2]");
     exact_test(&(&mut [1, 2]), "&mut [1, 2]");
index 95d0eabd336d86416c0923091642e6fb175fc6a1..cde20521c2f66bda09b1486bfa368ffa9f338da1 100644 (file)
@@ -37,8 +37,8 @@ pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) }
 #[cfg(test)]      pub unsafe fn cleanup() { realargs::cleanup() }
 
 /// Take the global arguments from global storage.
-#[cfg(not(test))] pub fn take() -> Option<Vec<~[u8]>> { imp::take() }
-#[cfg(test)]      pub fn take() -> Option<Vec<~[u8]>> {
+#[cfg(not(test))] pub fn take() -> Option<Vec<Vec<u8>>> { imp::take() }
+#[cfg(test)]      pub fn take() -> Option<Vec<Vec<u8>>> {
     match realargs::take() {
         realstd::option::Some(v) => Some(unsafe{ ::mem::transmute(v) }),
         realstd::option::None => None,
@@ -48,12 +48,16 @@ pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) }
 /// Give the global arguments to global storage.
 ///
 /// It is an error if the arguments already exist.
-#[cfg(not(test))] pub fn put(args: Vec<~[u8]>) { imp::put(args) }
-#[cfg(test)]      pub fn put(args: Vec<~[u8]>) { realargs::put(unsafe { ::mem::transmute(args) }) }
+#[cfg(not(test))] pub fn put(args: Vec<Vec<u8>>) { imp::put(args) }
+#[cfg(test)]      pub fn put(args: Vec<Vec<u8>>) {
+    realargs::put(unsafe {
+        ::mem::transmute(args)
+    })
+}
 
 /// Make a clone of the global arguments.
-#[cfg(not(test))] pub fn clone() -> Option<Vec<~[u8]>> { imp::clone() }
-#[cfg(test)]      pub fn clone() -> Option<Vec<~[u8]>> {
+#[cfg(not(test))] pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
+#[cfg(test)]      pub fn clone() -> Option<Vec<Vec<u8>>> {
     match realargs::clone() {
         realstd::option::Some(v) => Some(unsafe { ::mem::transmute(v) }),
         realstd::option::None => None,
@@ -88,15 +92,15 @@ pub unsafe fn cleanup() {
         lock.destroy();
     }
 
-    pub fn take() -> Option<Vec<~[u8]>> {
+    pub fn take() -> Option<Vec<Vec<u8>>> {
         with_lock(|| unsafe {
             let ptr = get_global_ptr();
             let val = mem::replace(&mut *ptr, None);
-            val.as_ref().map(|s: &Box<Vec<~[u8]>>| (**s).clone())
+            val.as_ref().map(|s: &Box<Vec<Vec<u8>>>| (**s).clone())
         })
     }
 
-    pub fn put(args: Vec<~[u8]>) {
+    pub fn put(args: Vec<Vec<u8>>) {
         with_lock(|| unsafe {
             let ptr = get_global_ptr();
             rtassert!((*ptr).is_none());
@@ -104,10 +108,10 @@ pub fn put(args: Vec<~[u8]>) {
         })
     }
 
-    pub fn clone() -> Option<Vec<~[u8]>> {
+    pub fn clone() -> Option<Vec<Vec<u8>>> {
         with_lock(|| unsafe {
             let ptr = get_global_ptr();
-            (*ptr).as_ref().map(|s: &Box<Vec<~[u8]>>| (**s).clone())
+            (*ptr).as_ref().map(|s: &Box<Vec<Vec<u8>>>| (**s).clone())
         })
     }
 
@@ -118,22 +122,21 @@ fn with_lock<T>(f: || -> T) -> T {
         }
     }
 
-    fn get_global_ptr() -> *mut Option<Box<Vec<~[u8]>>> {
+    fn get_global_ptr() -> *mut Option<Box<Vec<Vec<u8>>>> {
         unsafe { mem::transmute(&global_args_ptr) }
     }
 
     // Copied from `os`.
     #[cfg(not(test))]
-    unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> Vec<~[u8]> {
+    unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> Vec<Vec<u8>> {
         use c_str::CString;
         use ptr::RawPtr;
         use libc;
-        use slice::CloneableVector;
         use vec::Vec;
 
         Vec::from_fn(argc as uint, |i| {
             let cs = CString::new(*(argv as **libc::c_char).offset(i as int), false);
-            cs.as_bytes_no_nul().to_owned()
+            Vec::from_slice(cs.as_bytes_no_nul())
         })
     }
 
@@ -148,7 +151,10 @@ fn smoke_test() {
             // Preserve the actual global state.
             let saved_value = take();
 
-            let expected = vec![bytes!("happy").to_owned(), bytes!("today?").to_owned()];
+            let expected = vec![
+                Vec::from_slice(bytes!("happy")),
+                Vec::from_slice(bytes!("today?")),
+            ];
 
             put(expected.clone());
             assert!(clone() == Some(expected.clone()));
@@ -179,15 +185,15 @@ pub unsafe fn init(_argc: int, _argv: **u8) {
     pub fn cleanup() {
     }
 
-    pub fn take() -> Option<Vec<~[u8]>> {
+    pub fn take() -> Option<Vec<Vec<u8>>> {
         fail!()
     }
 
-    pub fn put(_args: Vec<~[u8]>) {
+    pub fn put(_args: Vec<Vec<u8>>) {
         fail!()
     }
 
-    pub fn clone() -> Option<Vec<~[u8]>> {
+    pub fn clone() -> Option<Vec<Vec<u8>>> {
         fail!()
     }
 }
index 708c42030ab7e1d6bcca6dd38f252cd7b8e22c7f..c9e5cae60e46c7aebc4f3916a9ef4963e88e5944 100644 (file)
@@ -13,6 +13,7 @@
 use from_str::from_str;
 use option::{Some, None, Expect};
 use os;
+use str::Str;
 
 // Note that these are all accessed without any synchronization.
 // They are expected to be initialized once then left alone.
 pub fn init() {
     unsafe {
         match os::getenv("RUST_MIN_STACK") {
-            Some(s) => match from_str(s) {
+            Some(s) => match from_str(s.as_slice()) {
                 Some(i) => MIN_STACK = i,
                 None => ()
             },
             None => ()
         }
         match os::getenv("RUST_MAX_CACHED_STACKS") {
-            Some(max) => MAX_CACHED_STACKS = from_str(max).expect("expected positive integer in \
-                                                                   RUST_MAX_CACHED_STACKS"),
+            Some(max) => {
+                MAX_CACHED_STACKS =
+                    from_str(max.as_slice()).expect("expected positive \
+                                                     integer in \
+                                                     RUST_MAX_CACHED_STACKS")
+            }
             None => ()
         }
         match os::getenv("RUST_DEBUG_BORROW") {
index 74675c85b96b30d2fbaa584e073cf21f614fc2e5..aef41de925ffafa259651b735adbf5092277fc19 100644 (file)
@@ -43,6 +43,7 @@ macro_rules! rtassert (
 
 macro_rules! rtabort (
     ($($arg:tt)*) => ( {
-        ::rt::util::abort(format!($($arg)*));
+        use str::Str;
+        ::rt::util::abort(format!($($arg)*).as_slice());
     } )
 )
index 8968747d9908e53e974f6119163b5e3884c8659f..749f44d1c9d2c0e37837a0d64527c86b0426f8bc 100644 (file)
@@ -420,11 +420,11 @@ fn local_heap() {
 
     #[test]
     fn tls() {
-        local_data_key!(key: @~str)
-        key.replace(Some(@"data".to_owned()));
+        local_data_key!(key: @StrBuf)
+        key.replace(Some(@"data".to_strbuf()));
         assert_eq!(key.get().unwrap().as_slice(), "data");
-        local_data_key!(key2: @~str)
-        key2.replace(Some(@"data".to_owned()));
+        local_data_key!(key2: @StrBuf)
+        key2.replace(Some(@"data".to_strbuf()));
         assert_eq!(key2.get().unwrap().as_slice(), "data");
     }
 
index af87a31b7bd81d1ae34305957d52f24bc9000a2a..8f2df8311969b924b2d6e28ae7e37d062d6cb77c 100644 (file)
@@ -71,6 +71,7 @@
 use rt::local::Local;
 use rt::task::Task;
 use str::Str;
+use strbuf::StrBuf;
 use task::TaskResult;
 
 use uw = rt::libunwind;
@@ -353,7 +354,7 @@ pub fn begin_unwind_fmt(msg: &fmt::Arguments, file: &'static str,
     // required with the current scheme, and (b) we don't handle
     // failure + OOM properly anyway (see comment in begin_unwind
     // below).
-    begin_unwind_inner(box fmt::format(msg), file, line)
+    begin_unwind_inner(box fmt::format_strbuf(msg), file, line)
 }
 
 /// This is the entry point of unwinding for fail!() and assert!().
@@ -388,7 +389,7 @@ fn begin_unwind_inner(msg: Box<Any:Send>,
     {
         let msg_s = match msg.as_ref::<&'static str>() {
             Some(s) => *s,
-            None => match msg.as_ref::<~str>() {
+            None => match msg.as_ref::<StrBuf>() {
                 Some(s) => s.as_slice(),
                 None => "Box<Any>",
             }
index c9e82bd16e5412c5535b9fd54ea2e9ae82665115..1ab9ac1b11edca81f18d34c48acc4d7b3d92c4bb 100644 (file)
@@ -18,7 +18,7 @@
 use option::{Some, None, Option};
 use os;
 use result::Ok;
-use str::StrSlice;
+use str::{Str, StrSlice};
 use unstable::running_on_valgrind;
 use slice::ImmutableVector;
 
@@ -55,7 +55,7 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool {
 pub fn default_sched_threads() -> uint {
     match os::getenv("RUST_THREADS") {
         Some(nstr) => {
-            let opt_n: Option<uint> = FromStr::from_str(nstr);
+            let opt_n: Option<uint> = FromStr::from_str(nstr.as_slice());
             match opt_n {
                 Some(n) if n > 0 => n,
                 _ => rtabort!("`RUST_THREADS` is `{}`, should be a positive integer", nstr)
@@ -145,6 +145,7 @@ pub fn abort(msg: &str) -> ! {
 memory and partly incapable of presentation to others.",
         _ => "You've met with a terrible fate, haven't you?"
     };
+    ::alloc::util::make_stdlib_link_work(); // see comments in liballoc
     rterrln!("{}", "");
     rterrln!("{}", quote);
     rterrln!("{}", "");
index 0838211b9a59f610764c09e370bc323b077f9798..ae1caa16d28adb61bacb0fcc149e6daacb5adc3f 100644 (file)
@@ -1853,16 +1853,18 @@ macro_rules! test_show_vec(
             })
         )
         let empty: ~[int] = box [];
-        test_show_vec!(empty, "[]".to_owned());
-        test_show_vec!(box [1], "[1]".to_owned());
-        test_show_vec!(box [1, 2, 3], "[1, 2, 3]".to_owned());
-        test_show_vec!(box [box [], box [1u], box [1u, 1u]], "[[], [1], [1, 1]]".to_owned());
+        test_show_vec!(empty, "[]".to_strbuf());
+        test_show_vec!(box [1], "[1]".to_strbuf());
+        test_show_vec!(box [1, 2, 3], "[1, 2, 3]".to_strbuf());
+        test_show_vec!(box [box [], box [1u], box [1u, 1u]],
+                       "[[], [1], [1, 1]]".to_strbuf());
 
         let empty_mut: &mut [int] = &mut[];
-        test_show_vec!(empty_mut, "[]".to_owned());
-        test_show_vec!(&mut[1], "[1]".to_owned());
-        test_show_vec!(&mut[1, 2, 3], "[1, 2, 3]".to_owned());
-        test_show_vec!(&mut[&mut[], &mut[1u], &mut[1u, 1u]], "[[], [1], [1, 1]]".to_owned());
+        test_show_vec!(empty_mut, "[]".to_strbuf());
+        test_show_vec!(&mut[1], "[1]".to_strbuf());
+        test_show_vec!(&mut[1, 2, 3], "[1, 2, 3]".to_strbuf());
+        test_show_vec!(&mut[&mut[], &mut[1u], &mut[1u, 1u]],
+                       "[[], [1], [1, 1]]".to_strbuf());
     }
 
     #[test]
index 617887e8af3ea9e5c61f53364e899b510c96710b..4ba711c46112f8e384b1953de6a3c8298d074f2f 100644 (file)
 Rust's string type is one of the core primitive types of the language. While
 represented by the name `str`, the name `str` is not actually a valid type in
 Rust. Each string must also be decorated with its ownership. This means that
-there are two common kinds of strings in Rust:
-
-* `~str` - This is an owned string. This type obeys all of the normal semantics
-           of the `Box<T>` types, meaning that it has one, and only one,
-           owner. This type cannot be implicitly copied, and is moved out of
-           when passed to other functions.
+there is one common kind of string in Rust:
 
 * `&str` - This is the borrowed string type. This type of string can only be
            created from the other kind of string. As the name "borrowed"
            implies, this type of string is owned elsewhere, and this string
            cannot be moved out of.
 
-As an example, here's a few different kinds of strings.
+As an example, here's the one kind of string.
 
 ```rust
 fn main() {
-    let owned_string = "I am an owned string".to_owned();
-    let borrowed_string1 = "This string is borrowed with the 'static lifetime";
-    let borrowed_string2: &str = owned_string;   // owned strings can be borrowed
+    let borrowed_string = "This string is borrowed with the 'static lifetime";
 }
 ```
 
-From the example above, you can see that Rust has 2 different kinds of string
-literals. The owned literals correspond to the owned string types, but the
-"borrowed literal" is actually more akin to C's concept of a static string.
+From the example above, you can see that Rust has 1 different kind of string
+literal. The "borrowed literal" is akin to C's concept of a static string.
 
-When a string is declared without a `~` sigil, then the string is allocated
-statically in the rodata of the executable/library. The string then has the
-type `&'static str` meaning that the string is valid for the `'static`
-lifetime, otherwise known as the lifetime of the entire program. As can be
-inferred from the type, these static strings are not mutable.
+String literals are allocated statically in the rodata of the
+executable/library. The string then has the type `&'static str` meaning that
+the string is valid for the `'static` lifetime, otherwise known as the
+lifetime of the entire program. As can be inferred from the type, these static
+strings are not mutable.
 
 # Mutability
 
@@ -67,10 +59,8 @@ fn main() {
 encoded UTF-8 sequences. Additionally, strings are not null-terminated
 and can contain null codepoints.
 
-The actual representation of strings have direct mappings to vectors:
-
-* `~str` is the same as `~[u8]`
-* `&str` is the same as `&[u8]`
+The actual representation of strings have direct mappings to vectors: `&str`
+is the same as `&[u8]`.
 
 */
 
@@ -81,13 +71,12 @@ fn main() {
 use container::Container;
 use default::Default;
 use fmt;
-use from_str::FromStr;
 use io::Writer;
 use iter::{Iterator, range, AdditiveIterator};
 use mem::transmute;
 use mem;
 use option::{None, Option, Some};
-use result::{Result, Ok, Err};
+use result::Result;
 use slice::Vector;
 use slice::{ImmutableVector, MutableVector, CloneableVector};
 use strbuf::StrBuf;
@@ -96,7 +85,7 @@ fn main() {
 pub use core::str::{from_utf8, CharEq, Chars, CharOffsets, RevChars};
 pub use core::str::{RevCharOffsets, Bytes, RevBytes, CharSplits, RevCharSplits};
 pub use core::str::{CharSplitsN, Words, AnyLines, MatchIndices, StrSplits};
-pub use core::str::{eq_slice, eq, is_utf8, is_utf16, UTF16Items};
+pub use core::str::{eq_slice, is_utf8, is_utf16, UTF16Items};
 pub use core::str::{UTF16Item, ScalarValue, LoneSurrogate, utf16_items};
 pub use core::str::{truncate_utf16_at_nul, utf8_char_width, CharRange};
 pub use core::str::{Str, StrSlice};
@@ -109,17 +98,8 @@ fn main() {
 ///
 /// Returns `Err` with the original vector if the vector contains invalid
 /// UTF-8.
-pub fn from_utf8_owned(vv: ~[u8]) -> Result<~str, ~[u8]> {
-    if is_utf8(vv) {
-        Ok(unsafe { raw::from_utf8_owned(vv) })
-    } else {
-        Err(vv)
-    }
-}
-
-impl FromStr for ~str {
-    #[inline]
-    fn from_str(s: &str) -> Option<~str> { Some(s.to_owned()) }
+pub fn from_utf8_owned(vv: Vec<u8>) -> Result<StrBuf, Vec<u8>> {
+    StrBuf::from_utf8(vv)
 }
 
 /// Convert a byte to a UTF-8 string
@@ -127,35 +107,37 @@ fn from_str(s: &str) -> Option<~str> { Some(s.to_owned()) }
 /// # Failure
 ///
 /// Fails if invalid UTF-8
-pub fn from_byte(b: u8) -> ~str {
+pub fn from_byte(b: u8) -> StrBuf {
     assert!(b < 128u8);
-    unsafe { ::mem::transmute(box [b]) }
+    StrBuf::from_char(1, b as char)
 }
 
 /// Convert a char to a string
-pub fn from_char(ch: char) -> ~str {
+pub fn from_char(ch: char) -> StrBuf {
     let mut buf = StrBuf::new();
     buf.push_char(ch);
-    buf.into_owned()
+    buf
 }
 
 /// Convert a vector of chars to a string
-pub fn from_chars(chs: &[char]) -> ~str {
+pub fn from_chars(chs: &[char]) -> StrBuf {
     chs.iter().map(|c| *c).collect()
 }
 
 /// Methods for vectors of strings
 pub trait StrVector {
     /// Concatenate a vector of strings.
-    fn concat(&self) -> ~str;
+    fn concat(&self) -> StrBuf;
 
     /// Concatenate a vector of strings, placing a given separator between each.
-    fn connect(&self, sep: &str) -> ~str;
+    fn connect(&self, sep: &str) -> StrBuf;
 }
 
 impl<'a, S: Str> StrVector for &'a [S] {
-    fn concat(&self) -> ~str {
-        if self.is_empty() { return "".to_owned(); }
+    fn concat(&self) -> StrBuf {
+        if self.is_empty() {
+            return StrBuf::new();
+        }
 
         // `len` calculation may overflow but push_str but will check boundaries
         let len = self.iter().map(|s| s.as_slice().len()).sum();
@@ -166,14 +148,18 @@ fn concat(&self) -> ~str {
             result.push_str(s.as_slice())
         }
 
-        result.into_owned()
+        result
     }
 
-    fn connect(&self, sep: &str) -> ~str {
-        if self.is_empty() { return "".to_owned(); }
+    fn connect(&self, sep: &str) -> StrBuf {
+        if self.is_empty() {
+            return StrBuf::new();
+        }
 
         // concat is faster
-        if sep.is_empty() { return self.concat(); }
+        if sep.is_empty() {
+            return self.concat();
+        }
 
         // this is wrong without the guarantee that `self` is non-empty
         // `len` calculation may overflow but push_str but will check boundaries
@@ -190,18 +176,18 @@ fn connect(&self, sep: &str) -> ~str {
             }
             result.push_str(s.as_slice());
         }
-        result.into_owned()
+        result
     }
 }
 
 impl<'a, S: Str> StrVector for Vec<S> {
     #[inline]
-    fn concat(&self) -> ~str {
+    fn concat(&self) -> StrBuf {
         self.as_slice().concat()
     }
 
     #[inline]
-    fn connect(&self, sep: &str) -> ~str {
+    fn connect(&self, sep: &str) -> StrBuf {
         self.as_slice().connect(sep)
     }
 }
@@ -317,7 +303,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 /// # Return value
 ///
 /// The original string with all occurrences of `from` replaced with `to`
-pub fn replace(s: &str, from: &str, to: &str) -> ~str {
+pub fn replace(s: &str, from: &str, to: &str) -> StrBuf {
     let mut result = StrBuf::new();
     let mut last_end = 0;
     for (start, end) in s.match_indices(from) {
@@ -326,7 +312,7 @@ pub fn replace(s: &str, from: &str, to: &str) -> ~str {
         last_end = end;
     }
     result.push_str(unsafe{raw::slice_bytes(s, last_end, s.len())});
-    result.into_owned()
+    result
 }
 
 /*
@@ -350,7 +336,7 @@ pub fn replace(s: &str, from: &str, to: &str) -> ~str {
 /// v[4] = 0xD800;
 /// assert_eq!(str::from_utf16(v), None);
 /// ```
-pub fn from_utf16(v: &[u16]) -> Option<~str> {
+pub fn from_utf16(v: &[u16]) -> Option<StrBuf> {
     let mut s = StrBuf::with_capacity(v.len() / 2);
     for c in utf16_items(v) {
         match c {
@@ -358,7 +344,7 @@ pub fn from_utf16(v: &[u16]) -> Option<~str> {
             LoneSurrogate(_) => return None
         }
     }
-    Some(s.into_owned())
+    Some(s)
 }
 
 /// Decode a UTF-16 encoded vector `v` into a string, replacing
@@ -376,7 +362,7 @@ pub fn from_utf16(v: &[u16]) -> Option<~str> {
 /// assert_eq!(str::from_utf16_lossy(v),
 ///            "𝄞mus\uFFFDic\uFFFD".to_owned());
 /// ```
-pub fn from_utf16_lossy(v: &[u16]) -> ~str {
+pub fn from_utf16_lossy(v: &[u16]) -> StrBuf {
     utf16_items(v).map(|c| c.to_char_lossy()).collect()
 }
 
@@ -523,14 +509,14 @@ macro_rules! error(() => ({
 Section: MaybeOwned
 */
 
-/// A MaybeOwned is a string that can hold either a ~str or a &str.
+/// A MaybeOwned is a string that can hold either a StrBuf or a &str.
 /// This can be useful as an optimization when an allocation is sometimes
 /// needed but not always.
 pub enum MaybeOwned<'a> {
     /// A borrowed string
     Slice(&'a str),
     /// An owned string
-    Owned(~str)
+    Owned(StrBuf)
 }
 
 /// SendStr is a specialization of `MaybeOwned` to be sendable
@@ -562,14 +548,11 @@ pub trait IntoMaybeOwned<'a> {
     fn into_maybe_owned(self) -> MaybeOwned<'a>;
 }
 
-impl<'a> IntoMaybeOwned<'a> for ~str {
-    #[inline]
-    fn into_maybe_owned(self) -> MaybeOwned<'a> { Owned(self) }
-}
-
 impl<'a> IntoMaybeOwned<'a> for StrBuf {
     #[inline]
-    fn into_maybe_owned(self) -> MaybeOwned<'a> { Owned(self.into_owned()) }
+    fn into_maybe_owned(self) -> MaybeOwned<'a> {
+        Owned(self)
+    }
 }
 
 impl<'a> IntoMaybeOwned<'a> for &'a str {
@@ -624,7 +607,7 @@ fn as_slice<'b>(&'b self) -> &'b str {
 
 impl<'a> StrAllocating for MaybeOwned<'a> {
     #[inline]
-    fn into_owned(self) -> ~str {
+    fn into_owned(self) -> StrBuf {
         match self {
             Slice(s) => s.to_owned(),
             Owned(s) => s
@@ -657,7 +640,7 @@ impl<'a, H: Writer> ::hash::Hash<H> for MaybeOwned<'a> {
     fn hash(&self, hasher: &mut H) {
         match *self {
             Slice(s) => s.hash(hasher),
-            Owned(ref s) => s.hash(hasher),
+            Owned(ref s) => s.as_slice().hash(hasher),
         }
     }
 }
@@ -674,58 +657,43 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 /// Unsafe operations
 pub mod raw {
+    use c_str::CString;
     use libc;
     use mem;
-    use ptr::RawPtr;
     use raw::Slice;
-    use slice::CloneableVector;
-    use str::{is_utf8, StrAllocating};
+    use strbuf::StrBuf;
+    use vec::Vec;
 
     pub use core::str::raw::{from_utf8, c_str_to_static_slice, slice_bytes};
     pub use core::str::raw::{slice_unchecked};
 
     /// Create a Rust string from a *u8 buffer of the given length
-    pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str {
-        let v = Slice { data: buf, len: len };
-        let bytes: &[u8] = ::mem::transmute(v);
-        assert!(is_utf8(bytes));
-        let s: &str = ::mem::transmute(bytes);
-        s.to_owned()
-    }
-
-    #[lang="strdup_uniq"]
-    #[cfg(not(test))]
-    #[inline]
-    unsafe fn strdup_uniq(ptr: *u8, len: uint) -> ~str {
-        from_buf_len(ptr, len)
+    pub unsafe fn from_buf_len(buf: *u8, len: uint) -> StrBuf {
+        let mut result = StrBuf::new();
+        result.push_bytes(mem::transmute(Slice {
+            data: buf,
+            len: len,
+        }));
+        result
     }
 
     /// Create a Rust string from a null-terminated C string
-    pub unsafe fn from_c_str(buf: *libc::c_char) -> ~str {
-        let mut curr = buf;
-        let mut i = 0;
-        while *curr != 0 {
-            i += 1;
-            curr = buf.offset(i);
-        }
-        from_buf_len(buf as *u8, i as uint)
+    pub unsafe fn from_c_str(c_string: *libc::c_char) -> StrBuf {
+        let mut buf = StrBuf::new();
+        buf.push_bytes(CString::new(c_string, false).as_bytes_no_nul());
+        buf
     }
 
     /// Converts an owned vector of bytes to a new owned string. This assumes
     /// that the utf-8-ness of the vector has already been validated
     #[inline]
-    pub unsafe fn from_utf8_owned(v: ~[u8]) -> ~str {
+    pub unsafe fn from_utf8_owned(v: Vec<u8>) -> StrBuf {
         mem::transmute(v)
     }
 
     /// Converts a byte to a string.
-    pub unsafe fn from_byte(u: u8) -> ~str { from_utf8_owned(box [u]) }
-
-    /// Access the str in its vector representation.
-    /// The caller must preserve the valid UTF-8 property when modifying.
-    #[inline]
-    pub unsafe fn as_owned_vec<'a>(s: &'a mut ~str) -> &'a mut ~[u8] {
-        mem::transmute(s)
+    pub unsafe fn from_byte(u: u8) -> StrBuf {
+        from_utf8_owned(vec![u])
     }
 
     /// Sets the length of a string
@@ -753,8 +721,8 @@ fn test_from_buf_len() {
 
 /// Any string that can be represented as a slice
 pub trait StrAllocating: Str {
-    /// Convert `self` into a ~str, not making a copy if possible.
-    fn into_owned(self) -> ~str;
+    /// Convert `self` into a `StrBuf`, not making a copy if possible.
+    fn into_owned(self) -> StrBuf;
 
     /// Convert `self` into a `StrBuf`.
     #[inline]
@@ -765,27 +733,27 @@ fn to_strbuf(&self) -> StrBuf {
     /// Convert `self` into a `StrBuf`, not making a copy if possible.
     #[inline]
     fn into_strbuf(self) -> StrBuf {
-        StrBuf::from_owned_str(self.into_owned())
+        self.into_owned()
     }
 
     /// Escape each char in `s` with `char::escape_default`.
-    fn escape_default(&self) -> ~str {
+    fn escape_default(&self) -> StrBuf {
         let me = self.as_slice();
         let mut out = StrBuf::with_capacity(me.len());
         for c in me.chars() {
             c.escape_default(|c| out.push_char(c));
         }
-        out.into_owned()
+        out
     }
 
     /// Escape each char in `s` with `char::escape_unicode`.
-    fn escape_unicode(&self) -> ~str {
+    fn escape_unicode(&self) -> StrBuf {
         let me = self.as_slice();
         let mut out = StrBuf::with_capacity(me.len());
         for c in me.chars() {
             c.escape_unicode(|c| out.push_char(c));
         }
-        out.into_owned()
+        out
     }
 
     /// Replace all occurrences of one string with another.
@@ -812,7 +780,7 @@ fn escape_unicode(&self) -> ~str {
     /// // not found, so no change.
     /// assert_eq!(s.replace("cookie monster", "little lamb"), s);
     /// ```
-    fn replace(&self, from: &str, to: &str) -> ~str {
+    fn replace(&self, from: &str, to: &str) -> StrBuf {
         let me = self.as_slice();
         let mut result = StrBuf::new();
         let mut last_end = 0;
@@ -822,16 +790,16 @@ fn replace(&self, from: &str, to: &str) -> ~str {
             last_end = end;
         }
         result.push_str(unsafe{raw::slice_bytes(me, last_end, me.len())});
-        result.into_owned()
+        result
     }
 
-    /// Copy a slice into a new owned str.
+    /// Copy a slice into a new `StrBuf`.
     #[inline]
-    fn to_owned(&self) -> ~str {
+    fn to_owned(&self) -> StrBuf {
         use slice::Vector;
 
         unsafe {
-            ::mem::transmute(self.as_slice().as_bytes().to_owned())
+            ::mem::transmute(Vec::from_slice(self.as_slice().as_bytes()))
         }
     }
 
@@ -848,13 +816,13 @@ fn to_utf16(&self) -> Vec<u16> {
     }
 
     /// Given a string, make a new string with repeated copies of it.
-    fn repeat(&self, nn: uint) -> ~str {
+    fn repeat(&self, nn: uint) -> StrBuf {
         let me = self.as_slice();
         let mut ret = StrBuf::with_capacity(nn * me.len());
         for _ in range(0, nn) {
             ret.push_str(me);
         }
-        ret.into_owned()
+        ret
     }
 
     /// Levenshtein Distance between two strings.
@@ -919,12 +887,9 @@ fn nfkd_chars<'a>(&'a self) -> Decompositions<'a> {
 
 impl<'a> StrAllocating for &'a str {
     #[inline]
-    fn into_owned(self) -> ~str { self.to_owned() }
-}
-
-impl<'a> StrAllocating for ~str {
-    #[inline]
-    fn into_owned(self) -> ~str { self }
+    fn into_owned(self) -> StrBuf {
+        self.to_owned()
+    }
 }
 
 /// Methods for owned strings
@@ -932,23 +897,23 @@ pub trait OwnedStr {
     /// Consumes the string, returning the underlying byte buffer.
     ///
     /// The buffer does not have a null terminator.
-    fn into_bytes(self) -> ~[u8];
+    fn into_bytes(self) -> Vec<u8>;
 
     /// Pushes the given string onto this string, returning the concatenation of the two strings.
-    fn append(self, rhs: &str) -> ~str;
+    fn append(self, rhs: &str) -> StrBuf;
 }
 
-impl OwnedStr for ~str {
+impl OwnedStr for StrBuf {
     #[inline]
-    fn into_bytes(self) -> ~[u8] {
+    fn into_bytes(self) -> Vec<u8> {
         unsafe { mem::transmute(self) }
     }
 
     #[inline]
-    fn append(self, rhs: &str) -> ~str {
+    fn append(self, rhs: &str) -> StrBuf {
         let mut new_str = StrBuf::from_owned_str(self);
         new_str.push_str(rhs);
-        new_str.into_owned()
+        new_str
     }
 }
 
@@ -960,13 +925,6 @@ mod tests {
     use str::*;
     use strbuf::StrBuf;
 
-    #[test]
-    fn test_eq() {
-        assert!((eq(&"".to_owned(), &"".to_owned())));
-        assert!((eq(&"foo".to_owned(), &"foo".to_owned())));
-        assert!((!eq(&"foo".to_owned(), &"bar".to_owned())));
-    }
-
     #[test]
     fn test_eq_slice() {
         assert!((eq_slice("foobar".slice(0, 3), "foo")));
@@ -1025,10 +983,10 @@ fn test_rfind() {
     #[test]
     fn test_collect() {
         let empty = "".to_owned();
-        let s: ~str = empty.chars().collect();
+        let s: StrBuf = empty.as_slice().chars().collect();
         assert_eq!(empty, s);
         let data = "ประเทศไทย中".to_owned();
-        let s: ~str = data.chars().collect();
+        let s: StrBuf = data.as_slice().chars().collect();
         assert_eq!(data, s);
     }
 
@@ -1050,23 +1008,24 @@ fn test_find_str() {
         assert_eq!(data.slice(2u, 6u).find_str("ab"), Some(3u - 2u));
         assert!(data.slice(2u, 4u).find_str("ab").is_none());
 
-        let mut data = "ประเทศไทย中华Việt Nam".to_owned();
-        data = data + data;
-        assert!(data.find_str("ไท华").is_none());
-        assert_eq!(data.slice(0u, 43u).find_str(""), Some(0u));
-        assert_eq!(data.slice(6u, 43u).find_str(""), Some(6u - 6u));
+        let string = "ประเทศไทย中华Việt Nam";
+        let mut data = string.to_strbuf();
+        data.push_str(string);
+        assert!(data.as_slice().find_str("ไท华").is_none());
+        assert_eq!(data.as_slice().slice(0u, 43u).find_str(""), Some(0u));
+        assert_eq!(data.as_slice().slice(6u, 43u).find_str(""), Some(6u - 6u));
 
-        assert_eq!(data.slice(0u, 43u).find_str("ประ"), Some( 0u));
-        assert_eq!(data.slice(0u, 43u).find_str("ทศไ"), Some(12u));
-        assert_eq!(data.slice(0u, 43u).find_str("ย中"), Some(24u));
-        assert_eq!(data.slice(0u, 43u).find_str("iệt"), Some(34u));
-        assert_eq!(data.slice(0u, 43u).find_str("Nam"), Some(40u));
+        assert_eq!(data.as_slice().slice(0u, 43u).find_str("ประ"), Some( 0u));
+        assert_eq!(data.as_slice().slice(0u, 43u).find_str("ทศไ"), Some(12u));
+        assert_eq!(data.as_slice().slice(0u, 43u).find_str("ย中"), Some(24u));
+        assert_eq!(data.as_slice().slice(0u, 43u).find_str("iệt"), Some(34u));
+        assert_eq!(data.as_slice().slice(0u, 43u).find_str("Nam"), Some(40u));
 
-        assert_eq!(data.slice(43u, 86u).find_str("ประ"), Some(43u - 43u));
-        assert_eq!(data.slice(43u, 86u).find_str("ทศไ"), Some(55u - 43u));
-        assert_eq!(data.slice(43u, 86u).find_str("ย中"), Some(67u - 43u));
-        assert_eq!(data.slice(43u, 86u).find_str("iệt"), Some(77u - 43u));
-        assert_eq!(data.slice(43u, 86u).find_str("Nam"), Some(83u - 43u));
+        assert_eq!(data.as_slice().slice(43u, 86u).find_str("ประ"), Some(43u - 43u));
+        assert_eq!(data.as_slice().slice(43u, 86u).find_str("ทศไ"), Some(55u - 43u));
+        assert_eq!(data.as_slice().slice(43u, 86u).find_str("ย中"), Some(67u - 43u));
+        assert_eq!(data.as_slice().slice(43u, 86u).find_str("iệt"), Some(77u - 43u));
+        assert_eq!(data.as_slice().slice(43u, 86u).find_str("Nam"), Some(83u - 43u));
     }
 
     #[test]
@@ -1084,25 +1043,25 @@ fn t(a: &str, b: &str, start: uint) {
 
     #[test]
     fn test_concat() {
-        fn t(v: &[~str], s: &str) {
-            assert_eq!(v.concat(), s.to_str());
+        fn t(v: &[StrBuf], s: &str) {
+            assert_eq!(v.concat(), s.to_str().into_owned());
         }
         t(["you".to_owned(), "know".to_owned(), "I'm".to_owned(),
           "no".to_owned(), "good".to_owned()], "youknowI'mnogood");
-        let v: &[~str] = [];
+        let v: &[StrBuf] = [];
         t(v, "");
         t(["hi".to_owned()], "hi");
     }
 
     #[test]
     fn test_connect() {
-        fn t(v: &[~str], sep: &str, s: &str) {
-            assert_eq!(v.connect(sep), s.to_str());
+        fn t(v: &[StrBuf], sep: &str, s: &str) {
+            assert_eq!(v.connect(sep), s.to_str().into_owned());
         }
         t(["you".to_owned(), "know".to_owned(), "I'm".to_owned(),
            "no".to_owned(), "good".to_owned()],
           " ", "you know I'm no good");
-        let v: &[~str] = [];
+        let v: &[StrBuf] = [];
         t(v, " ", "");
         t(["hi".to_owned()], " ", "hi");
     }
@@ -1110,7 +1069,7 @@ fn t(v: &[~str], sep: &str, s: &str) {
     #[test]
     fn test_concat_slices() {
         fn t(v: &[&str], s: &str) {
-            assert_eq!(v.concat(), s.to_str());
+            assert_eq!(v.concat(), s.to_str().into_owned());
         }
         t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
         let v: &[&str] = [];
@@ -1121,7 +1080,7 @@ fn t(v: &[&str], s: &str) {
     #[test]
     fn test_connect_slices() {
         fn t(v: &[&str], sep: &str, s: &str) {
-            assert_eq!(v.connect(sep), s.to_str());
+            assert_eq!(v.connect(sep), s.to_str().into_owned());
         }
         t(["you", "know", "I'm", "no", "good"],
           " ", "you know I'm no good");
@@ -1143,27 +1102,29 @@ fn test_unsafe_slice() {
         assert_eq!("ab", unsafe {raw::slice_bytes("abc", 0, 2)});
         assert_eq!("bc", unsafe {raw::slice_bytes("abc", 1, 3)});
         assert_eq!("", unsafe {raw::slice_bytes("abc", 1, 1)});
-        fn a_million_letter_a() -> ~str {
+        fn a_million_letter_a() -> StrBuf {
             let mut i = 0;
             let mut rs = StrBuf::new();
             while i < 100000 {
                 rs.push_str("aaaaaaaaaa");
                 i += 1;
             }
-            rs.into_owned()
+            rs
         }
-        fn half_a_million_letter_a() -> ~str {
+        fn half_a_million_letter_a() -> StrBuf {
             let mut i = 0;
             let mut rs = StrBuf::new();
             while i < 100000 {
                 rs.push_str("aaaaa");
                 i += 1;
             }
-            rs.into_owned()
+            rs
         }
         let letters = a_million_letter_a();
         assert!(half_a_million_letter_a() ==
-            unsafe {raw::slice_bytes(letters, 0u, 500000)}.to_owned());
+            unsafe {raw::slice_bytes(letters.as_slice(),
+                                     0u,
+                                     500000)}.to_owned());
     }
 
     #[test]
@@ -1208,41 +1169,41 @@ fn test_replace() {
 
     #[test]
     fn test_replace_2a() {
-        let data = "ประเทศไทย中华".to_owned();
-        let repl = "دولة الكويت".to_owned();
+        let data = "ประเทศไทย中华";
+        let repl = "دولة الكويت";
 
-        let a = "ประเ".to_owned();
-        let a2 = "دولة الكويتทศไทย中华".to_owned();
-        assert_eq!(data.replace(a, repl), a2);
+        let a = "ประเ";
+        let a2 = "دولة الكويتทศไทย中华";
+        assert_eq!(data.replace(a, repl).as_slice(), a2);
     }
 
     #[test]
     fn test_replace_2b() {
-        let data = "ประเทศไทย中华".to_owned();
-        let repl = "دولة الكويت".to_owned();
+        let data = "ประเทศไทย中华";
+        let repl = "دولة الكويت";
 
-        let b = "ะเ".to_owned();
-        let b2 = "ปรدولة الكويتทศไทย中华".to_owned();
-        assert_eq!(data.replace(b, repl), b2);
+        let b = "ะเ";
+        let b2 = "ปรدولة الكويتทศไทย中华";
+        assert_eq!(data.replace(b, repl).as_slice(), b2);
     }
 
     #[test]
     fn test_replace_2c() {
-        let data = "ประเทศไทย中华".to_owned();
-        let repl = "دولة الكويت".to_owned();
+        let data = "ประเทศไทย中华";
+        let repl = "دولة الكويت";
 
-        let c = "中华".to_owned();
-        let c2 = "ประเทศไทยدولة الكويت".to_owned();
-        assert_eq!(data.replace(c, repl), c2);
+        let c = "中华";
+        let c2 = "ประเทศไทยدولة الكويت";
+        assert_eq!(data.replace(c, repl).as_slice(), c2);
     }
 
     #[test]
     fn test_replace_2d() {
-        let data = "ประเทศไทย中华".to_owned();
-        let repl = "دولة الكويت".to_owned();
+        let data = "ประเทศไทย中华";
+        let repl = "دولة الكويت";
 
-        let d = "ไท华".to_owned();
-        assert_eq!(data.replace(d, repl), data);
+        let d = "ไท华";
+        assert_eq!(data.replace(d, repl).as_slice(), data);
     }
 
     #[test]
@@ -1258,27 +1219,27 @@ fn test_slice() {
         assert_eq!("", data.slice(3, 3));
         assert_eq!("华", data.slice(30, 33));
 
-        fn a_million_letter_X() -> ~str {
+        fn a_million_letter_X() -> StrBuf {
             let mut i = 0;
             let mut rs = StrBuf::new();
             while i < 100000 {
                 rs.push_str("华华华华华华华华华华");
                 i += 1;
             }
-            rs.into_owned()
+            rs
         }
-        fn half_a_million_letter_X() -> ~str {
+        fn half_a_million_letter_X() -> StrBuf {
             let mut i = 0;
             let mut rs = StrBuf::new();
             while i < 100000 {
                 rs.push_str("华华华华华");
                 i += 1;
             }
-            rs.into_owned()
+            rs
         }
         let letters = a_million_letter_X();
         assert!(half_a_million_letter_X() ==
-            letters.slice(0u, 3u * 500000u).to_owned());
+            letters.as_slice().slice(0u, 3u * 500000u).to_owned());
     }
 
     #[test]
@@ -1571,17 +1532,17 @@ fn test_subslice_offset_2() {
 
     #[test]
     fn vec_str_conversions() {
-        let s1: ~str = "All mimsy were the borogoves".to_owned();
+        let s1: StrBuf = "All mimsy were the borogoves".to_strbuf();
 
-        let v: ~[u8] = s1.as_bytes().to_owned();
-        let s2: ~str = from_utf8(v).unwrap().to_owned();
+        let v: Vec<u8> = Vec::from_slice(s1.as_bytes());
+        let s2: StrBuf = from_utf8(v.as_slice()).unwrap().to_strbuf();
         let mut i: uint = 0u;
         let n1: uint = s1.len();
         let n2: uint = v.len();
         assert_eq!(n1, n2);
         while i < n1 {
-            let a: u8 = s1[i];
-            let b: u8 = s2[i];
+            let a: u8 = s1.as_slice()[i];
+            let b: u8 = s2.as_slice()[i];
             debug!("{}", a);
             debug!("{}", b);
             assert_eq!(a, b);
@@ -1599,7 +1560,7 @@ fn test_contains() {
         assert!(!"abcde".contains("def"));
         assert!(!"".contains("a"));
 
-        let data = "ประเทศไทย中华Việt Nam".to_owned();
+        let data = "ประเทศไทย中华Việt Nam";
         assert!(data.contains("ประเ"));
         assert!(data.contains("ะเ"));
         assert!(data.contains("中华"));
@@ -1719,7 +1680,7 @@ fn test_truncate_utf16_at_nul() {
 
     #[test]
     fn test_char_at() {
-        let s = "ศไทย中华Việt Nam".to_owned();
+        let s = "ศไทย中华Việt Nam";
         let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
         let mut pos = 0;
         for ch in v.iter() {
@@ -1730,7 +1691,7 @@ fn test_char_at() {
 
     #[test]
     fn test_char_at_reverse() {
-        let s = "ศไทย中华Việt Nam".to_owned();
+        let s = "ศไทย中华Việt Nam";
         let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
         let mut pos = s.len();
         for ch in v.iter().rev() {
@@ -1775,7 +1736,7 @@ fn test_total_ord() {
 
     #[test]
     fn test_char_range_at() {
-        let data = "b¢€𤭢𤭢€¢b".to_owned();
+        let data = "b¢€𤭢𤭢€¢b";
         assert_eq!('b', data.char_range_at(0).ch);
         assert_eq!('¢', data.char_range_at(1).ch);
         assert_eq!('€', data.char_range_at(3).ch);
@@ -1791,29 +1752,10 @@ fn test_char_range_at_reverse_underflow() {
         assert_eq!("abc".char_range_at_reverse(0).next, 0);
     }
 
-    #[test]
-    fn test_add() {
-        #![allow(unnecessary_allocation)]
-        macro_rules! t (
-            ($s1:expr, $s2:expr, $e:expr) => { {
-                let s1 = $s1;
-                let s2 = $s2;
-                let e = $e;
-                assert_eq!(s1 + s2, e.to_owned());
-                assert_eq!(s1.to_owned() + s2, e.to_owned());
-            } }
-        );
-
-        t!("foo",  "bar", "foobar");
-        t!("foo", "bar".to_owned(), "foobar");
-        t!("ศไทย中",  "华Việt Nam", "ศไทย中华Việt Nam");
-        t!("ศไทย中", "华Việt Nam".to_owned(), "ศไทย中华Việt Nam");
-    }
-
     #[test]
     fn test_iterator() {
         use iter::*;
-        let s = "ศไทย中华Việt Nam".to_owned();
+        let s = "ศไทย中华Việt Nam";
         let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
 
         let mut pos = 0;
@@ -1829,7 +1771,7 @@ fn test_iterator() {
     #[test]
     fn test_rev_iterator() {
         use iter::*;
-        let s = "ศไทย中华Việt Nam".to_owned();
+        let s = "ศไทย中华Việt Nam";
         let v = box ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
 
         let mut pos = 0;
@@ -1852,7 +1794,7 @@ fn test_iterator_clone() {
 
     #[test]
     fn test_bytesator() {
-        let s = "ศไทย中华Việt Nam".to_owned();
+        let s = "ศไทย中华Việt Nam";
         let v = [
             224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
             184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
@@ -1868,7 +1810,7 @@ fn test_bytesator() {
 
     #[test]
     fn test_bytes_revator() {
-        let s = "ศไทย中华Việt Nam".to_owned();
+        let s = "ศไทย中华Việt Nam";
         let v = [
             224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
             184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
@@ -2025,30 +1967,30 @@ fn test_words() {
 
     #[test]
     fn test_nfd_chars() {
-        assert_eq!("abc".nfd_chars().collect::<~str>(), "abc".to_owned());
-        assert_eq!("\u1e0b\u01c4".nfd_chars().collect::<~str>(), "d\u0307\u01c4".to_owned());
-        assert_eq!("\u2026".nfd_chars().collect::<~str>(), "\u2026".to_owned());
-        assert_eq!("\u2126".nfd_chars().collect::<~str>(), "\u03a9".to_owned());
-        assert_eq!("\u1e0b\u0323".nfd_chars().collect::<~str>(), "d\u0323\u0307".to_owned());
-        assert_eq!("\u1e0d\u0307".nfd_chars().collect::<~str>(), "d\u0323\u0307".to_owned());
-        assert_eq!("a\u0301".nfd_chars().collect::<~str>(), "a\u0301".to_owned());
-        assert_eq!("\u0301a".nfd_chars().collect::<~str>(), "\u0301a".to_owned());
-        assert_eq!("\ud4db".nfd_chars().collect::<~str>(), "\u1111\u1171\u11b6".to_owned());
-        assert_eq!("\uac1c".nfd_chars().collect::<~str>(), "\u1100\u1162".to_owned());
+        assert_eq!("abc".nfd_chars().collect::<StrBuf>(), "abc".to_strbuf());
+        assert_eq!("\u1e0b\u01c4".nfd_chars().collect::<StrBuf>(), "d\u0307\u01c4".to_strbuf());
+        assert_eq!("\u2026".nfd_chars().collect::<StrBuf>(), "\u2026".to_strbuf());
+        assert_eq!("\u2126".nfd_chars().collect::<StrBuf>(), "\u03a9".to_strbuf());
+        assert_eq!("\u1e0b\u0323".nfd_chars().collect::<StrBuf>(), "d\u0323\u0307".to_strbuf());
+        assert_eq!("\u1e0d\u0307".nfd_chars().collect::<StrBuf>(), "d\u0323\u0307".to_strbuf());
+        assert_eq!("a\u0301".nfd_chars().collect::<StrBuf>(), "a\u0301".to_strbuf());
+        assert_eq!("\u0301a".nfd_chars().collect::<StrBuf>(), "\u0301a".to_strbuf());
+        assert_eq!("\ud4db".nfd_chars().collect::<StrBuf>(), "\u1111\u1171\u11b6".to_strbuf());
+        assert_eq!("\uac1c".nfd_chars().collect::<StrBuf>(), "\u1100\u1162".to_strbuf());
     }
 
     #[test]
     fn test_nfkd_chars() {
-        assert_eq!("abc".nfkd_chars().collect::<~str>(), "abc".to_owned());
-        assert_eq!("\u1e0b\u01c4".nfkd_chars().collect::<~str>(), "d\u0307DZ\u030c".to_owned());
-        assert_eq!("\u2026".nfkd_chars().collect::<~str>(), "...".to_owned());
-        assert_eq!("\u2126".nfkd_chars().collect::<~str>(), "\u03a9".to_owned());
-        assert_eq!("\u1e0b\u0323".nfkd_chars().collect::<~str>(), "d\u0323\u0307".to_owned());
-        assert_eq!("\u1e0d\u0307".nfkd_chars().collect::<~str>(), "d\u0323\u0307".to_owned());
-        assert_eq!("a\u0301".nfkd_chars().collect::<~str>(), "a\u0301".to_owned());
-        assert_eq!("\u0301a".nfkd_chars().collect::<~str>(), "\u0301a".to_owned());
-        assert_eq!("\ud4db".nfkd_chars().collect::<~str>(), "\u1111\u1171\u11b6".to_owned());
-        assert_eq!("\uac1c".nfkd_chars().collect::<~str>(), "\u1100\u1162".to_owned());
+        assert_eq!("abc".nfkd_chars().collect::<StrBuf>(), "abc".to_strbuf());
+        assert_eq!("\u1e0b\u01c4".nfkd_chars().collect::<StrBuf>(), "d\u0307DZ\u030c".to_strbuf());
+        assert_eq!("\u2026".nfkd_chars().collect::<StrBuf>(), "...".to_strbuf());
+        assert_eq!("\u2126".nfkd_chars().collect::<StrBuf>(), "\u03a9".to_strbuf());
+        assert_eq!("\u1e0b\u0323".nfkd_chars().collect::<StrBuf>(), "d\u0323\u0307".to_strbuf());
+        assert_eq!("\u1e0d\u0307".nfkd_chars().collect::<StrBuf>(), "d\u0323\u0307".to_strbuf());
+        assert_eq!("a\u0301".nfkd_chars().collect::<StrBuf>(), "a\u0301".to_strbuf());
+        assert_eq!("\u0301a".nfkd_chars().collect::<StrBuf>(), "\u0301a".to_strbuf());
+        assert_eq!("\ud4db".nfkd_chars().collect::<StrBuf>(), "\u1111\u1171\u11b6".to_strbuf());
+        assert_eq!("\uac1c".nfkd_chars().collect::<StrBuf>(), "\u1100\u1162".to_strbuf());
     }
 
     #[test]
@@ -2093,7 +2035,7 @@ fn t<S: Default + Str>() {
         }
 
         t::<&str>();
-        t::<~str>();
+        t::<StrBuf>();
     }
 
     #[test]
@@ -2122,14 +2064,15 @@ fn test_str_from_utf8() {
 
     #[test]
     fn test_str_from_utf8_owned() {
-        let xs = bytes!("hello").to_owned();
+        let xs = Vec::from_slice(bytes!("hello"));
         assert_eq!(from_utf8_owned(xs), Ok("hello".to_owned()));
 
-        let xs = bytes!("ศไทย中华Việt Nam").to_owned();
+        let xs = Vec::from_slice(bytes!("ศไทย中华Việt Nam"));
         assert_eq!(from_utf8_owned(xs), Ok("ศไทย中华Việt Nam".to_owned()));
 
-        let xs = bytes!("hello", 0xff).to_owned();
-        assert_eq!(from_utf8_owned(xs), Err(bytes!("hello", 0xff).to_owned()));
+        let xs = Vec::from_slice(bytes!("hello", 0xff));
+        assert_eq!(from_utf8_owned(xs),
+                   Err(Vec::from_slice(bytes!("hello", 0xff))));
     }
 
     #[test]
@@ -2167,8 +2110,8 @@ fn test_str_from_utf8_lossy() {
 
     #[test]
     fn test_from_str() {
-      let owned: Option<~str> = from_str("string");
-      assert_eq!(owned, Some("string".to_owned()));
+      let owned: Option<StrBuf> = from_str("string");
+      assert_eq!(owned, Some("string".to_strbuf()));
     }
 
     #[test]
@@ -2176,16 +2119,16 @@ fn test_maybe_owned_traits() {
         let s = Slice("abcde");
         assert_eq!(s.len(), 5);
         assert_eq!(s.as_slice(), "abcde");
-        assert_eq!(s.to_str(), "abcde".to_owned());
-        assert_eq!(format!("{}", s), "abcde".to_owned());
+        assert_eq!(s.to_str(), "abcde".to_strbuf());
+        assert_eq!(format_strbuf!("{}", s), "abcde".to_strbuf());
         assert!(s.lt(&Owned("bcdef".to_owned())));
         assert_eq!(Slice(""), Default::default());
 
         let o = Owned("abcde".to_owned());
         assert_eq!(o.len(), 5);
         assert_eq!(o.as_slice(), "abcde");
-        assert_eq!(o.to_str(), "abcde".to_owned());
-        assert_eq!(format!("{}", o), "abcde".to_owned());
+        assert_eq!(o.to_str(), "abcde".to_strbuf());
+        assert_eq!(format_strbuf!("{}", o), "abcde".to_strbuf());
         assert!(o.lt(&Slice("bcdef")));
         assert_eq!(Owned("".to_owned()), Default::default());
 
index de480ef1b7fb7ddb4a6d5923bd90c6af8a389aa0..dd462ff5ab58407856fc6dbc4be4642e9e04ca4d 100644 (file)
 
 use c_vec::CVec;
 use char::Char;
+use cmp::Equiv;
 use container::{Container, Mutable};
+use default::Default;
 use fmt;
+use from_str::FromStr;
 use io::Writer;
 use iter::{Extendable, FromIterator, Iterator, range};
 use mem;
@@ -21,8 +24,8 @@
 use ptr::RawPtr;
 use ptr;
 use result::{Result, Ok, Err};
-use slice::{OwnedVector, Vector, CloneableVector};
-use str::{CharRange, OwnedStr, Str, StrSlice, StrAllocating};
+use slice::Vector;
+use str::{CharRange, Str, StrSlice, StrAllocating};
 use str;
 use vec::Vec;
 
@@ -67,10 +70,8 @@ pub fn from_str(string: &str) -> StrBuf {
 
     /// Creates a new string buffer from the given owned string, taking care not to copy it.
     #[inline]
-    pub fn from_owned_str(string: ~str) -> StrBuf {
-        StrBuf {
-            vec: string.into_bytes().move_iter().collect(),
-        }
+    pub fn from_owned_str(string: StrBuf) -> StrBuf {
+        string
     }
 
     /// Returns the vector as a string buffer, if possible, taking care not to
@@ -191,6 +192,13 @@ pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
         self.vec.as_slice()
     }
 
+    /// Works with the underlying buffer as a mutable byte slice. Unsafe
+    /// because this can be used to violate the UTF-8 property.
+    #[inline]
+    pub unsafe fn as_mut_bytes<'a>(&'a mut self) -> &'a mut [u8] {
+        self.vec.as_mut_slice()
+    }
+
     /// Shorten a string to the specified length (which must be <= the current length)
     #[inline]
     pub fn truncate(&mut self, len: uint) {
@@ -314,14 +322,20 @@ fn as_slice<'a>(&'a self) -> &'a str {
 
 impl StrAllocating for StrBuf {
     #[inline]
-    fn into_owned(self) -> ~str {
-        unsafe {
-            mem::transmute(self.vec.as_slice().to_owned())
-        }
+    fn into_owned(self) -> StrBuf {
+        self
     }
 
     #[inline]
-    fn into_strbuf(self) -> StrBuf { self }
+    fn into_strbuf(self) -> StrBuf {
+        self
+    }
+}
+
+impl Default for StrBuf {
+    fn default() -> StrBuf {
+        StrBuf::new()
+    }
 }
 
 impl fmt::Show for StrBuf {
@@ -337,6 +351,20 @@ fn hash(&self, hasher: &mut H) {
     }
 }
 
+impl<'a, S: Str> Equiv<S> for StrBuf {
+    #[inline]
+    fn equiv(&self, other: &S) -> bool {
+        self.as_slice() == other.as_slice()
+    }
+}
+
+impl FromStr for StrBuf {
+    #[inline]
+    fn from_str(s: &str) -> Option<StrBuf> {
+        Some(s.to_strbuf())
+    }
+}
+
 #[cfg(test)]
 mod tests {
     extern crate test;
index 5c875b4a2ad088acd92035d2c85f498c12e982cd..314f659550d4112454ccd9361943ab45d183a8d9 100644 (file)
@@ -51,6 +51,7 @@
 #[cfg(test)] use owned::AnyOwnExt;
 #[cfg(test)] use result;
 #[cfg(test)] use str::StrAllocating;
+#[cfg(test)] use strbuf::StrBuf;
 
 /// Indicates the manner in which a task exited.
 ///
@@ -496,12 +497,12 @@ fn test_try_fail_message_static_str() {
 #[test]
 fn test_try_fail_message_owned_str() {
     match try(proc() {
-        fail!("owned string".to_owned());
+        fail!("owned string".to_strbuf());
     }) {
         Err(e) => {
-            type T = ~str;
+            type T = StrBuf;
             assert!(e.is::<T>());
-            assert_eq!(*e.move::<T>().unwrap(), "owned string".to_owned());
+            assert_eq!(*e.move::<T>().unwrap(), "owned string".to_strbuf());
         }
         Ok(()) => fail!()
     }
index 4132c8a5b5a3332c80d3ace6a07d834b7f8e0b96..fbc4227e726460b76b85c7d65fb74982d574345e 100644 (file)
 */
 
 use fmt;
+use strbuf::StrBuf;
 
 /// A generic trait for converting a value to a string
 pub trait ToStr {
     /// Converts the value of `self` to an owned string
-    fn to_str(&self) -> ~str;
+    fn to_str(&self) -> StrBuf;
 }
 
 /// Trait for converting a type to a string, consuming it in the process.
 pub trait IntoStr {
     /// Consume and convert to a string.
-    fn into_str(self) -> ~str;
+    fn into_str(self) -> StrBuf;
 }
 
 impl<T: fmt::Show> ToStr for T {
-    fn to_str(&self) -> ~str { format!("{}", *self) }
+    fn to_str(&self) -> StrBuf {
+        format_strbuf!("{}", *self)
+    }
 }
 
 #[cfg(test)]
@@ -39,23 +42,23 @@ mod tests {
 
     #[test]
     fn test_simple_types() {
-        assert_eq!(1i.to_str(), "1".to_owned());
-        assert_eq!((-1i).to_str(), "-1".to_owned());
-        assert_eq!(200u.to_str(), "200".to_owned());
-        assert_eq!(2u8.to_str(), "2".to_owned());
-        assert_eq!(true.to_str(), "true".to_owned());
-        assert_eq!(false.to_str(), "false".to_owned());
-        assert_eq!(().to_str(), "()".to_owned());
-        assert_eq!(("hi".to_owned()).to_str(), "hi".to_owned());
+        assert_eq!(1i.to_str(), "1".to_strbuf());
+        assert_eq!((-1i).to_str(), "-1".to_strbuf());
+        assert_eq!(200u.to_str(), "200".to_strbuf());
+        assert_eq!(2u8.to_str(), "2".to_strbuf());
+        assert_eq!(true.to_str(), "true".to_strbuf());
+        assert_eq!(false.to_str(), "false".to_strbuf());
+        assert_eq!(().to_str(), "()".to_strbuf());
+        assert_eq!(("hi".to_strbuf()).to_str(), "hi".to_strbuf());
     }
 
     #[test]
     fn test_vectors() {
         let x: ~[int] = box [];
-        assert_eq!(x.to_str(), "[]".to_owned());
-        assert_eq!((box [1]).to_str(), "[1]".to_owned());
-        assert_eq!((box [1, 2, 3]).to_str(), "[1, 2, 3]".to_owned());
+        assert_eq!(x.to_str(), "[]".to_strbuf());
+        assert_eq!((box [1]).to_str(), "[1]".to_strbuf());
+        assert_eq!((box [1, 2, 3]).to_str(), "[1, 2, 3]".to_strbuf());
         assert!((box [box [], box [1], box [1, 1]]).to_str() ==
-               "[[], [1], [1, 1]]".to_owned());
+               "[[], [1], [1, 1]]".to_strbuf());
     }
 }
index d50c63c583247f1d82ae2523d7a37ab8778ad356..8e85283ee55d34e0708e869ccac3796d35a44a76 100644 (file)
@@ -27,6 +27,7 @@
 use result::*;
 use slice::{Vector,ImmutableVector};
 use str;
+use strbuf::StrBuf;
 use vec::Vec;
 
 pub struct DynamicLibrary { handle: *u8}
@@ -56,7 +57,7 @@ impl DynamicLibrary {
     /// Lazily open a dynamic library. When passed None it gives a
     /// handle to the calling process
     pub fn open<T: ToCStr>(filename: Option<T>)
-                        -> Result<DynamicLibrary, ~str> {
+                        -> Result<DynamicLibrary, StrBuf> {
         unsafe {
             let mut filename = filename;
             let maybe_library = dl::check_for_errors_in(|| {
@@ -118,7 +119,9 @@ pub fn search_path() -> Vec<Path> {
         let mut ret = Vec::new();
         match os::getenv_as_bytes(DynamicLibrary::envvar()) {
             Some(env) => {
-                for portion in env.split(|a| *a == DynamicLibrary::separator()) {
+                for portion in
+                        env.as_slice()
+                           .split(|a| *a == DynamicLibrary::separator()) {
                     ret.push(Path::new(portion));
                 }
             }
@@ -128,7 +131,7 @@ pub fn search_path() -> Vec<Path> {
     }
 
     /// Access the value at the symbol of the dynamic library
-    pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<T, ~str> {
+    pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<T, StrBuf> {
         // This function should have a lifetime constraint of 'a on
         // T but that feature is still unimplemented
 
@@ -203,10 +206,12 @@ fn test_errors_do_not_crash() {
 pub mod dl {
     use prelude::*;
 
-    use c_str::ToCStr;
+    use c_str::{CString, ToCStr};
     use libc;
     use ptr;
-    use str;
+    use result::*;
+    use str::StrAllocating;
+    use strbuf::StrBuf;
 
     pub unsafe fn open_external<T: ToCStr>(filename: T) -> *u8 {
         filename.with_c_str(|raw_name| {
@@ -218,7 +223,7 @@ pub unsafe fn open_internal() -> *u8 {
         dlopen(ptr::null(), Lazy as libc::c_int) as *u8
     }
 
-    pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, ~str> {
+    pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, StrBuf> {
         use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
         static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
@@ -233,7 +238,9 @@ pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, ~str> {
             let ret = if ptr::null() == last_error {
                 Ok(result)
             } else {
-                Err(str::raw::from_c_str(last_error))
+                Err(CString::new(last_error, false).as_str()
+                                                   .unwrap()
+                                                   .to_strbuf())
             };
 
             ret
@@ -269,6 +276,7 @@ pub mod dl {
     use os;
     use ptr;
     use result::{Ok, Err, Result};
+    use strbuf::StrBuf;
     use str;
     use c_str::ToCStr;
 
@@ -287,7 +295,7 @@ pub unsafe fn open_internal() -> *u8 {
         handle as *u8
     }
 
-    pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, ~str> {
+    pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, StrBuf> {
         unsafe {
             SetLastError(0);
 
index 32883707615d535b839265a7f89df14942bcd999..1776b6fbe6ec690ae2cde10eff1f6162f1776726 100644 (file)
@@ -671,7 +671,7 @@ pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
     /// ```rust
     /// let v = vec!("a".to_owned(), "b".to_owned());
     /// for s in v.move_iter() {
-    ///     // s has type ~str, not &~str
+    ///     // s has type StrBuf, not &StrBuf
     ///     println!("{}", s);
     /// }
     /// ```
@@ -1849,9 +1849,9 @@ fn test_from_vec() {
         let b: ~[u8] = FromVec::from_vec(a);
         assert_eq!(b.as_slice(), &[]);
 
-        let a = vec!["one".to_owned(), "two".to_owned()];
-        let b: ~[~str] = FromVec::from_vec(a);
-        assert_eq!(b.as_slice(), &["one".to_owned(), "two".to_owned()]);
+        let a = vec!["one".to_strbuf(), "two".to_strbuf()];
+        let b: ~[StrBuf] = FromVec::from_vec(a);
+        assert_eq!(b.as_slice(), &["one".to_strbuf(), "two".to_strbuf()]);
 
         struct Foo {
             x: uint,
index 5a57c2d6cc62d684039becea2a631da5834e1551..bc660798240e9a633dc90e2063c99c980b8fc874 100644 (file)
@@ -396,7 +396,8 @@ pub fn require_unique_names(diagnostic: &SpanHandler, metas: &[@MetaItem]) {
 
         if !set.insert(name.clone()) {
             diagnostic.span_fatal(meta.span,
-                                  format!("duplicate meta item `{}`", name));
+                                  format!("duplicate meta item `{}`",
+                                          name).as_slice());
         }
     }
 }
index b7700cf396d48dba6d2e3266ea70bcac685d5e53..dc699bb985068e9768ad4e74c1ecd96f616b9390 100644 (file)
@@ -39,7 +39,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             Some(ref version) => version.as_slice(),
         };
         if self.path == self.name ||
-                self.path.as_slice().ends_with(format!("/{}", self.name)) {
+                self.path
+                    .as_slice()
+                    .ends_with(format!("/{}", self.name).as_slice()) {
             write!(f, "\\#{}", version)
         } else {
             write!(f, "\\#{}:{}", self.name, version)
@@ -52,12 +54,14 @@ fn from_str(s: &str) -> Option<CrateId> {
         let pieces: Vec<&str> = s.splitn('#', 1).collect();
         let path = pieces.get(0).to_owned();
 
-        if path.starts_with("/") || path.ends_with("/") ||
-            path.starts_with(".") || path.is_empty() {
+        if path.as_slice().starts_with("/") || path.as_slice().ends_with("/") ||
+            path.as_slice().starts_with(".") || path.is_empty() {
             return None;
         }
 
-        let path_pieces: Vec<&str> = path.rsplitn('/', 1).collect();
+        let path_pieces: Vec<&str> = path.as_slice()
+                                         .rsplitn('/', 1)
+                                         .collect();
         let inferred_name = *path_pieces.get(0);
 
         let (name, version) = if pieces.len() == 1 {
index 3eb6f40ba53c39250734040b1591ad9fe6b62b37..446a8f93753c327b403fe5149852daa8e4244c15 100644 (file)
@@ -106,7 +106,7 @@ pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
         fail!(ExplicitBug);
     }
     pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
-        self.span_bug(sp, "unimplemented ".to_owned() + msg);
+        self.span_bug(sp, format!("unimplemented {}", msg).as_slice());
     }
     pub fn handler<'a>(&'a self) -> &'a Handler {
         &self.handler
@@ -143,13 +143,13 @@ pub fn abort_if_errors(&self) {
         let s;
         match self.err_count.get() {
           0u => return,
-          1u => s = "aborting due to previous error".to_owned(),
+          1u => s = "aborting due to previous error".to_strbuf(),
           _  => {
             s = format!("aborting due to {} previous errors",
-                     self.err_count.get());
+                        self.err_count.get());
           }
         }
-        self.fatal(s);
+        self.fatal(s.as_slice());
     }
     pub fn warn(&self, msg: &str) {
         self.emit.borrow_mut().emit(None, msg, Warning);
@@ -162,7 +162,7 @@ pub fn bug(&self, msg: &str) -> ! {
         fail!(ExplicitBug);
     }
     pub fn unimpl(&self, msg: &str) -> ! {
-        self.bug("unimplemented ".to_owned() + msg);
+        self.bug(format!("unimplemented {}", msg).as_slice());
     }
     pub fn emit(&self,
                 cmsp: Option<(&codemap::CodeMap, Span)>,
@@ -267,9 +267,12 @@ fn print_diagnostic(dst: &mut EmitterWriter,
         try!(write!(&mut dst.dst, "{} ", topic));
     }
 
-    try!(print_maybe_styled(dst, format!("{}: ", lvl.to_str()),
+    try!(print_maybe_styled(dst,
+                            format!("{}: ", lvl.to_str()).as_slice(),
                             term::attr::ForegroundColor(lvl.color())));
-    try!(print_maybe_styled(dst, format!("{}\n", msg), term::attr::Bold));
+    try!(print_maybe_styled(dst,
+                            format!("{}\n", msg).as_slice(),
+                            term::attr::Bold));
     Ok(())
 }
 
@@ -431,7 +434,8 @@ fn highlight_lines(err: &mut EmitterWriter,
                 s.push_char('~');
             }
         }
-        try!(print_maybe_styled(err, s.into_owned() + "\n",
+        try!(print_maybe_styled(err,
+                                format!("{}\n", s).as_slice(),
                                 term::attr::ForegroundColor(lvl.color())));
     }
     Ok(())
@@ -476,7 +480,7 @@ fn custom_highlight_lines(w: &mut EmitterWriter,
     s.push_char('^');
     s.push_char('\n');
     print_maybe_styled(w,
-                       s.into_owned(),
+                       s.as_slice(),
                        term::attr::ForegroundColor(lvl.color()))
 }
 
@@ -495,7 +499,8 @@ fn print_macro_backtrace(w: &mut EmitterWriter,
         };
         try!(print_diagnostic(w, ss.as_slice(), Note,
                               format!("in expansion of {}{}{}", pre,
-                                      ei.callee.name, post)));
+                                      ei.callee.name,
+                                      post).as_slice()));
         let ss = cm.span_to_str(ei.call_site);
         try!(print_diagnostic(w, ss.as_slice(), Note, "expansion site"));
         try!(print_macro_backtrace(w, cm, ei.call_site));
index b9c8be290caac7bcd6047f164a30e096be0e9b95..822084df2f607915c405503bdeb3466388981b73 100644 (file)
@@ -107,7 +107,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                         (Some('+'), operand) => {
                             // Save a reference to the output
                             read_write_operands.push((outputs.len(), out));
-                            Some(token::intern_and_get_ident("=" + operand))
+                            Some(token::intern_and_get_ident(format!(
+                                        "={}",
+                                        operand).as_slice()))
                         }
                         _ => {
                             cx.span_err(span, "output operand constraint lacks '=' or '+'");
@@ -208,7 +210,8 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     // Append an input operand, with the form of ("0", expr)
     // that links to an output operand.
     for &(i, out) in read_write_operands.iter() {
-        inputs.push((token::intern_and_get_ident(i.to_str()), out));
+        inputs.push((token::intern_and_get_ident(i.to_str().as_slice()),
+                                                 out));
     }
 
     MacExpr::new(@ast::Expr {
@@ -216,7 +219,7 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
         node: ast::ExprInlineAsm(ast::InlineAsm {
             asm: token::intern_and_get_ident(asm.get()),
             asm_str_style: asm_str_style.unwrap(),
-            clobbers: token::intern_and_get_ident(cons),
+            clobbers: token::intern_and_get_ident(cons.as_slice()),
             inputs: inputs,
             outputs: outputs,
             volatile: volatile,
index 06b56bbe472a250e804a429ff29596d4371884d9..854f1d022198cf57a04d455e2a79b4902ed417a9 100644 (file)
@@ -533,7 +533,7 @@ pub fn check_zero_tts(cx: &ExtCtxt,
                       tts: &[ast::TokenTree],
                       name: &str) {
     if tts.len() != 0 {
-        cx.span_err(sp, format!("{} takes no arguments", name));
+        cx.span_err(sp, format!("{} takes no arguments", name).as_slice());
     }
 }
 
@@ -545,14 +545,17 @@ pub fn get_single_str_from_tts(cx: &ExtCtxt,
                                name: &str)
                                -> Option<StrBuf> {
     if tts.len() != 1 {
-        cx.span_err(sp, format!("{} takes 1 argument.", name));
+        cx.span_err(sp, format!("{} takes 1 argument.", name).as_slice());
     } else {
         match tts[0] {
             ast::TTTok(_, token::LIT_STR(ident))
             | ast::TTTok(_, token::LIT_STR_RAW(ident, _)) => {
                 return Some(token::get_ident(ident).get().to_strbuf())
             }
-            _ => cx.span_err(sp, format!("{} requires a string.", name)),
+            _ => {
+                cx.span_err(sp,
+                            format!("{} requires a string.", name).as_slice())
+            }
         }
     }
     None
index 7c6c9892002c9327f38b8d15fb7bf583e4b684cb..b2baff8d286ec9de8c365dbecda06ea393d29962 100644 (file)
@@ -38,14 +38,14 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
                         accumulator.push_char(c);
                     }
                     ast::LitInt(i, _) | ast::LitIntUnsuffixed(i) => {
-                        accumulator.push_str(format!("{}", i));
+                        accumulator.push_str(format!("{}", i).as_slice());
                     }
                     ast::LitUint(u, _) => {
-                        accumulator.push_str(format!("{}", u));
+                        accumulator.push_str(format!("{}", u).as_slice());
                     }
                     ast::LitNil => {}
                     ast::LitBool(b) => {
-                        accumulator.push_str(format!("{}", b));
+                        accumulator.push_str(format!("{}", b).as_slice());
                     }
                     ast::LitBinary(..) => {
                         cx.span_err(e.span, "cannot concatenate a binary literal");
@@ -59,5 +59,5 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
     }
     base::MacExpr::new(cx.expr_str(
             sp,
-            token::intern_and_get_ident(accumulator.into_owned())))
+            token::intern_and_get_ident(accumulator.as_slice())))
 }
index 0e168e7b33b707aca6fea668fab6af0d02befa29..24478358d7951241a3552176aeb8907383335ced 100644 (file)
@@ -42,7 +42,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
             }
         }
     }
-    let res = str_to_ident(res_str.into_owned());
+    let res = str_to_ident(res_str.as_slice());
 
     let e = @ast::Expr {
         id: ast::DUMMY_NODE_ID,
index b5b2667f892de94a065e7078d4d6d9858f75e0f6..d90c7f37213b7181773641fd62ca8d16a9ad657c 100644 (file)
@@ -25,12 +25,18 @@ pub fn expand_deriving_bound(cx: &mut ExtCtxt,
                 "Copy" => "Copy",
                 "Send" => "Send",
                 "Share" => "Share",
-                ref tname => cx.span_bug(span,
-                                         format!("expected built-in trait name but found {}",
-                                                 *tname))
+                ref tname => {
+                    cx.span_bug(span,
+                                format!("expected built-in trait name but \
+                                         found {}",
+                                        *tname).as_slice())
+                }
             }
         },
-        _ => return cx.span_err(span, "unexpected value in deriving, expected a trait")
+        _ => {
+            return cx.span_err(span, "unexpected value in deriving, expected \
+                                      a trait")
+        }
     };
 
     let trait_def = TraitDef {
index 510241588228ce105ba5e86abda2d487220db2ce..89c94891b3380875057fb3c6b575eb4397671cc3 100644 (file)
@@ -66,12 +66,17 @@ fn cs_clone(
             ctor_ident = variant.node.name;
             all_fields = af;
         },
-        EnumNonMatching(..) => cx.span_bug(trait_span,
-                                           format!("non-matching enum variants in `deriving({})`",
-                                                  name)),
-        StaticEnum(..) | StaticStruct(..) => cx.span_bug(trait_span,
-                                                         format!("static method in `deriving({})`",
-                                                                 name))
+        EnumNonMatching(..) => {
+            cx.span_bug(trait_span,
+                        format!("non-matching enum variants in \
+                                 `deriving({})`",
+                                name).as_slice())
+        }
+        StaticEnum(..) | StaticStruct(..) => {
+            cx.span_bug(trait_span,
+                        format!("static method in `deriving({})`",
+                                name).as_slice())
+        }
     }
 
     if all_fields.len() >= 1 && all_fields.get(0).name.is_none() {
@@ -83,9 +88,12 @@ fn cs_clone(
         let fields = all_fields.iter().map(|field| {
             let ident = match field.name {
                 Some(i) => i,
-                None => cx.span_bug(trait_span,
-                                    format!("unnamed field in normal struct in `deriving({})`",
-                                            name))
+                None => {
+                    cx.span_bug(trait_span,
+                                format!("unnamed field in normal struct in \
+                                         `deriving({})`",
+                                        name).as_slice())
+                }
             };
             cx.field_imm(field.span, ident, subcall(field))
         }).collect::<Vec<_>>();
index 2447535f1f3d88fbd5de91c4f98321652a223d09..172ae8dca6279017677cfc078cdf5cc50cdbad45 100644 (file)
@@ -168,7 +168,7 @@ fn decode_static_fields(cx: &mut ExtCtxt,
                 let fields = fields.iter().enumerate().map(|(i, &span)| {
                     getarg(cx, span,
                            token::intern_and_get_ident(format!("_field{}",
-                                                               i)),
+                                                               i).as_slice()),
                            i)
                 }).collect();
 
index 75b051b2f1086b109f60960feb797d01905d0142..b8a3eea0014a0717536a1956afc6bccb93144089 100644 (file)
@@ -154,7 +154,8 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
                 let name = match name {
                     Some(id) => token::get_ident(id),
                     None => {
-                        token::intern_and_get_ident(format!("_field{}", i))
+                        token::intern_and_get_ident(format!("_field{}",
+                                                            i).as_slice())
                     }
                 };
                 let enc = cx.expr_method_call(span, self_, encode, vec!(blkencoder));
index 6df4da89402199b3f50864a2a12b2faa21ca93ba..0875daddc0f9fb3e0855bc475de3c75811272816 100644 (file)
@@ -574,7 +574,7 @@ fn split_self_nonself_args(&self,
 
         for (i, ty) in self.args.iter().enumerate() {
             let ast_ty = ty.to_ty(cx, trait_.span, type_ident, generics);
-            let ident = cx.ident_of(format!("__arg_{}", i));
+            let ident = cx.ident_of(format!("__arg_{}", i).as_slice());
             arg_tys.push((ident, ast_ty));
 
             let arg_expr = cx.expr_ident(trait_.span, ident);
@@ -674,9 +674,13 @@ fn expand_struct_method_body(&self,
                                  // [fields of next Self arg], [etc]]
         let mut patterns = Vec::new();
         for i in range(0u, self_args.len()) {
-            let (pat, ident_expr) = trait_.create_struct_pattern(cx, type_ident, struct_def,
-                                                                 format!("__self_{}", i),
-                                                                 ast::MutImmutable);
+            let (pat, ident_expr) =
+                trait_.create_struct_pattern(cx,
+                                             type_ident,
+                                             struct_def,
+                                             format!("__self_{}",
+                                                     i).as_slice(),
+                                             ast::MutImmutable);
             patterns.push(pat);
             raw_fields.push(ident_expr);
         }
@@ -875,7 +879,7 @@ fn build_enum_match(&self,
 
         } else {  // there are still matches to create
             let current_match_str = if match_count == 0 {
-                "__self".to_owned()
+                "__self".to_strbuf()
             } else {
                 format!("__arg_{}", match_count)
             };
@@ -895,10 +899,11 @@ fn build_enum_match(&self,
 
                 // matching-variant match
                 let variant = *enum_def.variants.get(index);
-                let (pattern, idents) = trait_.create_enum_variant_pattern(cx,
-                                                                           variant,
-                                                                           current_match_str,
-                                                                           ast::MutImmutable);
+                let (pattern, idents) = trait_.create_enum_variant_pattern(
+                    cx,
+                    variant,
+                    current_match_str.as_slice(),
+                    ast::MutImmutable);
 
                 matches_so_far.push((index, variant, idents));
                 let arm_expr = self.build_enum_match(cx,
@@ -926,10 +931,12 @@ fn build_enum_match(&self,
             } else {
                 // create an arm matching on each variant
                 for (index, &variant) in enum_def.variants.iter().enumerate() {
-                    let (pattern, idents) = trait_.create_enum_variant_pattern(cx,
-                                                                               variant,
-                                                                               current_match_str,
-                                                                               ast::MutImmutable);
+                    let (pattern, idents) =
+                        trait_.create_enum_variant_pattern(
+                            cx,
+                            variant,
+                            current_match_str.as_slice(),
+                            ast::MutImmutable);
 
                     matches_so_far.push((index, variant, idents));
                     let new_matching =
@@ -1081,7 +1088,11 @@ fn create_struct_pattern(&self,
                     cx.span_bug(sp, "a struct with named and unnamed fields in `deriving`");
                 }
             };
-            let path = cx.path_ident(sp, cx.ident_of(format!("{}_{}", prefix, i)));
+            let path =
+                cx.path_ident(sp,
+                              cx.ident_of(format!("{}_{}",
+                                                  prefix,
+                                                  i).as_slice()));
             paths.push(path.clone());
             let val = cx.expr(
                 sp, ast::ExprParen(
@@ -1127,7 +1138,11 @@ fn create_enum_variant_pattern(&self,
                 let mut ident_expr = Vec::new();
                 for (i, va) in variant_args.iter().enumerate() {
                     let sp = self.set_expn_info(cx, va.ty.span);
-                    let path = cx.path_ident(sp, cx.ident_of(format!("{}_{}", prefix, i)));
+                    let path =
+                        cx.path_ident(sp,
+                                      cx.ident_of(format!("{}_{}",
+                                                          prefix,
+                                                          i).as_slice()));
 
                     paths.push(path.clone());
                     let val = cx.expr(
index 1187e83308b846396dc6548fa06070ae904bf1b1..aeff36a49e60e70b0b66fa4c07a0e6b1aa62618b 100644 (file)
@@ -96,8 +96,10 @@ macro_rules! expand(($func:path) => ($func(cx, titem.span,
                             "Copy" => expand!(bounds::expand_deriving_bound),
 
                             ref tname => {
-                                cx.span_err(titem.span, format!("unknown \
-                                    `deriving` trait: `{}`", *tname));
+                                cx.span_err(titem.span,
+                                            format!("unknown `deriving` \
+                                                     trait: `{}`",
+                                                    *tname).as_slice());
                             }
                         };
                     }
index 8dbfbc53cecf73b4bbdfd86598b74207dd798adc..d1a4d2f3ee3b6c594477768b9832fd40b0ef92bb 100644 (file)
@@ -53,7 +53,7 @@ pub fn expand_option_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                                    cx.ident_of("Some")),
                               vec!(cx.expr_str(sp,
                                                token::intern_and_get_ident(
-                                          s))))
+                                          s.as_slice()))))
       }
     };
     MacExpr::new(e)
@@ -80,7 +80,7 @@ pub fn expand_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
         1 => {
             token::intern_and_get_ident(format!("environment variable `{}` \
                                                  not defined",
-                                                var))
+                                                var).as_slice())
         }
         2 => {
             match expr_to_str(cx, *exprs.get(1), "expected string literal") {
@@ -99,7 +99,7 @@ pub fn expand_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
             cx.span_err(sp, msg.get());
             cx.expr_uint(sp, 0)
         }
-        Some(s) => cx.expr_str(sp, token::intern_and_get_ident(s))
+        Some(s) => cx.expr_str(sp, token::intern_and_get_ident(s.as_slice()))
     };
     MacExpr::new(e)
 }
index e3b1037ccc06e4e6ac4700fb84d5912e17d5c951..989d0a463c387a653ac884152bd2890062e0f8d7 100644 (file)
@@ -47,10 +47,9 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr {
                 // Token-tree macros:
                 MacInvocTT(ref pth, ref tts, _) => {
                     if pth.segments.len() > 1u {
-                        fld.cx.span_err(
-                            pth.span,
-                            format!("expected macro name without module \
-                                  separators"));
+                        fld.cx.span_err(pth.span,
+                                        "expected macro name without module \
+                                         separators");
                         // let compilation continue
                         return DummyResult::raw_expr(e.span);
                     }
@@ -62,7 +61,7 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr {
                             fld.cx.span_err(
                                 pth.span,
                                 format!("macro undefined: '{}'",
-                                        extnamestr.get()));
+                                        extnamestr.get()).as_slice());
 
                             // let compilation continue
                             return DummyResult::raw_expr(e.span);
@@ -93,11 +92,10 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr {
                                 None => {
                                     fld.cx.span_err(
                                         pth.span,
-                                        format!(
-                                            "non-expr macro in expr pos: {}",
-                                            extnamestr.get()
-                                        )
-                                    );
+                                        format!("non-expr macro in expr pos: \
+                                                 {}",
+                                                extnamestr.get().as_slice()
+                                        ).as_slice());
                                     return DummyResult::raw_expr(e.span);
                                 }
                             };
@@ -109,8 +107,7 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr {
                             fld.cx.span_err(
                                 pth.span,
                                 format!("'{}' is not a tt-style macro",
-                                        extnamestr.get())
-                            );
+                                        extnamestr.get()).as_slice());
                             return DummyResult::raw_expr(e.span);
                         }
                     };
@@ -384,18 +381,19 @@ pub fn expand_item_mac(it: @ast::Item, fld: &mut MacroExpander)
         None => {
             fld.cx.span_err(pth.span,
                             format!("macro undefined: '{}!'",
-                                    extnamestr));
+                                    extnamestr).as_slice());
             // let compilation continue
             return SmallVector::zero();
         }
 
         Some(&NormalTT(ref expander, span)) => {
             if it.ident.name != parse::token::special_idents::invalid.name {
-                fld.cx.span_err(pth.span,
-                                format!("macro {}! expects no ident argument, \
-                                        given '{}'",
-                                        extnamestr,
-                                        token::get_ident(it.ident)));
+                fld.cx
+                   .span_err(pth.span,
+                             format!("macro {}! expects no ident argument, \
+                                      given '{}'",
+                                     extnamestr,
+                                     token::get_ident(it.ident)).as_slice());
                 return SmallVector::zero();
             }
             fld.cx.bt_push(ExpnInfo {
@@ -414,7 +412,7 @@ pub fn expand_item_mac(it: @ast::Item, fld: &mut MacroExpander)
             if it.ident.name == parse::token::special_idents::invalid.name {
                 fld.cx.span_err(pth.span,
                                 format!("macro {}! expects an ident argument",
-                                        extnamestr.get()));
+                                        extnamestr.get()).as_slice());
                 return SmallVector::zero();
             }
             fld.cx.bt_push(ExpnInfo {
@@ -432,7 +430,7 @@ pub fn expand_item_mac(it: @ast::Item, fld: &mut MacroExpander)
         _ => {
             fld.cx.span_err(it.span,
                             format!("{}! is not legal in item position",
-                                    extnamestr.get()));
+                                    extnamestr.get()).as_slice());
             return SmallVector::zero();
         }
     };
@@ -459,7 +457,7 @@ pub fn expand_item_mac(it: @ast::Item, fld: &mut MacroExpander)
                 None => {
                     fld.cx.span_err(pth.span,
                                     format!("expr macro in item position: {}",
-                                            extnamestr.get()));
+                                            extnamestr.get()).as_slice());
                     return SmallVector::zero();
                 }
             }
@@ -532,7 +530,7 @@ fn load_extern_macros(krate: &ast::ViewItem, fld: &mut MacroExpander) {
         // this is fatal: there are almost certainly macros we need
         // inside this crate, so continue would spew "macro undefined"
         // errors
-        Err(err) => fld.cx.span_fatal(krate.span, err)
+        Err(err) => fld.cx.span_fatal(krate.span, err.as_slice())
     };
 
     unsafe {
@@ -540,7 +538,7 @@ fn load_extern_macros(krate: &ast::ViewItem, fld: &mut MacroExpander) {
             match lib.symbol(registrar.as_slice()) {
                 Ok(registrar) => registrar,
                 // again fatal if we can't register macros
-                Err(err) => fld.cx.span_fatal(krate.span, err)
+                Err(err) => fld.cx.span_fatal(krate.span, err.as_slice())
             };
         registrar(|name, extension| {
             let extension = match extension {
@@ -581,7 +579,9 @@ pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<@Stmt> {
     let extnamestr = token::get_ident(extname);
     let marked_after = match fld.extsbox.find(&extname.name) {
         None => {
-            fld.cx.span_err(pth.span, format!("macro undefined: '{}'", extnamestr));
+            fld.cx.span_err(pth.span,
+                            format!("macro undefined: '{}'",
+                                    extnamestr).as_slice());
             return SmallVector::zero();
         }
 
@@ -609,7 +609,7 @@ pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<@Stmt> {
                 None => {
                     fld.cx.span_err(pth.span,
                                     format!("non-stmt macro in stmt pos: {}",
-                                            extnamestr));
+                                            extnamestr).as_slice());
                     return SmallVector::zero();
                 }
             };
@@ -619,7 +619,7 @@ pub fn expand_stmt(s: &Stmt, fld: &mut MacroExpander) -> SmallVector<@Stmt> {
 
         _ => {
             fld.cx.span_err(pth.span, format!("'{}' is not a tt-style macro",
-                                              extnamestr));
+                                              extnamestr).as_slice());
             return SmallVector::zero();
         }
     };
index 01124fdfa54df5d1941cae0e6e15c5a0fa40d426..ad4b798cfe5b85c66d505a16b2a8500131d09054 100644 (file)
@@ -130,7 +130,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool,
                 _ => {
                     ecx.span_err(p.span,
                                  format!("expected ident for named argument, but found `{}`",
-                                         p.this_token_to_str()));
+                                         p.this_token_to_str()).as_slice());
                     return (invocation, None);
                 }
             };
@@ -141,7 +141,9 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool,
             match names.find_equiv(&name) {
                 None => {}
                 Some(prev) => {
-                    ecx.span_err(e.span, format!("duplicate argument named `{}`", name));
+                    ecx.span_err(e.span,
+                                 format!("duplicate argument named `{}`",
+                                         name).as_slice());
                     ecx.parse_sess.span_diagnostic.span_note(prev.span, "previously here");
                     continue
                 }
@@ -246,13 +248,15 @@ fn verify_method(&mut self, pos: Position, m: &parse::Method) {
                         match arm.selector {
                             parse::Keyword(name) => {
                                 self.ecx.span_err(self.fmtsp,
-                                                  format!("duplicate selector \
-                                                           `{}`", name));
+                                                  format!("duplicate \
+                                                           selector `{}`",
+                                                          name).as_slice());
                             }
                             parse::Literal(idx) => {
                                 self.ecx.span_err(self.fmtsp,
-                                                  format!("duplicate selector \
-                                                           `={}`", idx));
+                                                  format!("duplicate \
+                                                           selector `={}`",
+                                                          idx).as_slice());
                             }
                         }
                     }
@@ -267,7 +271,7 @@ fn verify_method(&mut self, pos: Position, m: &parse::Method) {
                     if !seen_cases.insert(arm.selector) {
                         self.ecx.span_err(self.fmtsp,
                                           format!("duplicate selector `{}`",
-                                               arm.selector));
+                                                  arm.selector).as_slice());
                     } else if arm.selector == "" {
                         self.ecx.span_err(self.fmtsp,
                                           "empty selector in `select`");
@@ -286,7 +290,7 @@ fn verify_arg_type(&mut self, arg: Position, ty: ArgumentType) {
                 if self.args.len() <= arg {
                     let msg = format!("invalid reference to argument `{}` (there \
                                     are {} arguments)", arg, self.args.len());
-                    self.ecx.span_err(self.fmtsp, msg);
+                    self.ecx.span_err(self.fmtsp, msg.as_slice());
                     return;
                 }
                 {
@@ -306,7 +310,7 @@ fn verify_arg_type(&mut self, arg: Position, ty: ArgumentType) {
                     Some(e) => e.span,
                     None => {
                         let msg = format!("there is no argument named `{}`", name);
-                        self.ecx.span_err(self.fmtsp, msg);
+                        self.ecx.span_err(self.fmtsp, msg.as_slice());
                         return;
                     }
                 };
@@ -349,19 +353,19 @@ fn verify_same(&self,
                                   format!("argument redeclared with type `{}` when \
                                            it was previously `{}`",
                                           *ty,
-                                          *cur));
+                                          *cur).as_slice());
             }
             (&Known(ref cur), _) => {
                 self.ecx.span_err(sp,
                                   format!("argument used to format with `{}` was \
                                            attempted to not be used for formatting",
-                                           *cur));
+                                           *cur).as_slice());
             }
             (_, &Known(ref ty)) => {
                 self.ecx.span_err(sp,
                                   format!("argument previously used as a format \
                                            argument attempted to be used as `{}`",
-                                           *ty));
+                                           *ty).as_slice());
             }
             (_, _) => {
                 self.ecx.span_err(sp, "argument declared with multiple formats");
@@ -480,7 +484,7 @@ fn trans_method(&mut self, method: &parse::Method) -> @ast::Expr {
                             }).collect();
                         let (lr, selarg) = match arm.selector {
                             parse::Keyword(t) => {
-                                let p = self.rtpath(t.to_str());
+                                let p = self.rtpath(t.to_str().as_slice());
                                 let p = self.ecx.path_global(sp, p);
                                 (self.rtpath("Keyword"), self.ecx.expr_path(p))
                             }
@@ -516,7 +520,8 @@ fn trans_method(&mut self, method: &parse::Method) -> @ast::Expr {
                     ), None);
         let st = ast::ItemStatic(ty, ast::MutImmutable, method);
         let static_name = self.ecx.ident_of(format!("__STATIC_METHOD_{}",
-                                                    self.method_statics.len()));
+                                                    self.method_statics
+                                                        .len()).as_slice());
         let item = self.ecx.item(sp, static_name, self.static_attrs(), st);
         self.method_statics.push(item);
         self.ecx.expr_ident(sp, static_name)
@@ -662,7 +667,7 @@ fn to_expr(&self, invocation: Invocation) -> @ast::Expr {
                 continue // error already generated
             }
 
-            let name = self.ecx.ident_of(format!("__arg{}", i));
+            let name = self.ecx.ident_of(format!("__arg{}", i).as_slice());
             pats.push(self.ecx.pat_ident(e.span, name));
             heads.push(self.ecx.expr_addr_of(e.span, e));
             locals.push(self.format_arg(e.span, Exact(i),
@@ -674,7 +679,8 @@ fn to_expr(&self, invocation: Invocation) -> @ast::Expr {
                 Some(..) | None => continue
             };
 
-            let lname = self.ecx.ident_of(format!("__arg{}", *name));
+            let lname = self.ecx.ident_of(format!("__arg{}",
+                                                  *name).as_slice());
             pats.push(self.ecx.pat_ident(e.span, lname));
             heads.push(self.ecx.expr_addr_of(e.span, e));
             *names.get_mut(*self.name_positions.get(name)) =
@@ -786,8 +792,10 @@ fn format_arg(&self, sp: Span, argno: Position, arg: @ast::Expr)
                     "x" => "secret_lower_hex",
                     "X" => "secret_upper_hex",
                     _ => {
-                        self.ecx.span_err(sp, format!("unknown format trait `{}`",
-                                                      *tyname));
+                        self.ecx
+                            .span_err(sp,
+                                      format!("unknown format trait `{}`",
+                                              *tyname).as_slice());
                         "dummy"
                     }
                 }
index b3eec136c7d696e87ceca81f992e772408fd339e..bb3a88f44e4bbe07f340a87260f880cab899f312 100644 (file)
@@ -436,7 +436,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
                 ast::TyI32 => "TyI32".to_owned(),
                 ast::TyI64 => "TyI64".to_owned()
             };
-            let e_ity = cx.expr_ident(sp, id_ext(s_ity));
+            let e_ity = cx.expr_ident(sp, id_ext(s_ity.as_slice()));
 
             let e_i64 = cx.expr_lit(sp, ast::LitInt(i, ast::TyI64));
 
@@ -453,7 +453,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
                 ast::TyU32 => "TyU32".to_owned(),
                 ast::TyU64 => "TyU64".to_owned()
             };
-            let e_uty = cx.expr_ident(sp, id_ext(s_uty));
+            let e_uty = cx.expr_ident(sp, id_ext(s_uty.as_slice()));
 
             let e_u64 = cx.expr_lit(sp, ast::LitUint(u, ast::TyU64));
 
@@ -476,7 +476,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
                 ast::TyF64 => "TyF64".to_owned(),
                 ast::TyF128 => "TyF128".to_owned()
             };
-            let e_fty = cx.expr_ident(sp, id_ext(s_fty));
+            let e_fty = cx.expr_ident(sp, id_ext(s_fty.as_slice()));
 
             let e_fident = mk_ident(cx, sp, fident);
 
index 6bc08741c079a5c4a4c64e7c388b8fa51fc918c1..452719d2dd8819915dd4d5c634fc45c05b08f19d 100644 (file)
@@ -76,7 +76,9 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                    .map(|x| token::get_ident(*x).get().to_strbuf())
                    .collect::<Vec<StrBuf>>()
                    .connect("::");
-    base::MacExpr::new(cx.expr_str(sp, token::intern_and_get_ident(string)))
+    base::MacExpr::new(cx.expr_str(
+            sp,
+            token::intern_and_get_ident(string.as_slice())))
 }
 
 // include! : parse the given file as an expr
@@ -111,7 +113,10 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     let file = res_rel_file(cx, sp, &Path::new(file));
     let bytes = match File::open(&file).read_to_end() {
         Err(e) => {
-            cx.span_err(sp, format!("couldn't read {}: {}", file.display(), e));
+            cx.span_err(sp,
+                        format!("couldn't read {}: {}",
+                                file.display(),
+                                e).as_slice());
             return DummyResult::expr(sp);
         }
         Ok(bytes) => bytes,
@@ -127,7 +132,9 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
             base::MacExpr::new(cx.expr_str(sp, interned))
         }
         None => {
-            cx.span_err(sp, format!("{} wasn't a utf-8 file", file.display()));
+            cx.span_err(sp,
+                        format!("{} wasn't a utf-8 file",
+                                file.display()).as_slice());
             return DummyResult::expr(sp);
         }
     }
@@ -142,7 +149,10 @@ pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     let file = res_rel_file(cx, sp, &Path::new(file));
     match File::open(&file).read_to_end() {
         Err(e) => {
-            cx.span_err(sp, format!("couldn't read {}: {}", file.display(), e));
+            cx.span_err(sp,
+                        format!("couldn't read {}: {}",
+                                file.display(),
+                                e).as_slice());
             return DummyResult::expr(sp);
         }
         Ok(bytes) => {
index 89e8d48425f6cc6ebfbd88c0120acff487c3b2de..ce1c7da585f6e543d8dc29faef555d5bb1a887f5 100644 (file)
@@ -188,7 +188,9 @@ fn n_rec(p_s: &ParseSess, m: &Matcher, res: &[Rc<NamedMatch>],
             if ret_val.contains_key(&bind_name) {
                 let string = token::get_ident(bind_name);
                 p_s.span_diagnostic
-                   .span_fatal(span, "duplicated bind name: " + string.get())
+                   .span_fatal(span,
+                               format!("duplicated bind name: {}",
+                                       string.get()).as_slice())
             }
             ret_val.insert(bind_name, res[idx].clone());
           }
@@ -455,6 +457,9 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
         res
       }
       "matchers" => token::NtMatchers(p.parse_matchers()),
-      _ => p.fatal("unsupported builtin nonterminal parser: ".to_owned() + name)
+      _ => {
+          p.fatal(format!("unsupported builtin nonterminal parser: {}",
+                          name).as_slice())
+      }
     }
 }
index 7ff690582d6800f0030c9b048a20b755736152e8..f234b0c234d16ecb8c2cd6ec53a9aa8716916244 100644 (file)
@@ -52,7 +52,7 @@ fn ensure_complete_parse(&self, allow_semi: bool) {
                                following",
                               token_str);
             let span = parser.span;
-            parser.span_err(span, msg);
+            parser.span_err(span, msg.as_slice());
         }
     }
 }
index 1f264e73d4aa3eb3934b2dcb54d2131c52bbb837..6d799eeae6c75bc2c8dfadb6b3cf55b834c81b91 100644 (file)
@@ -89,9 +89,10 @@ fn lookup_cur_matched(r: &TtReader, name: Ident) -> Rc<NamedMatch> {
     match matched_opt {
         Some(s) => lookup_cur_matched_by_matched(r, s),
         None => {
-            r.sp_diag.span_fatal(r.cur_span,
-                                 format!("unknown macro variable `{}`",
-                                         token::get_ident(name)));
+            r.sp_diag
+             .span_fatal(r.cur_span,
+                         format!("unknown macro variable `{}`",
+                                 token::get_ident(name)).as_slice());
         }
     }
 }
@@ -269,7 +270,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
                         r.sp_diag.span_fatal(
                             r.cur_span, /* blame the macro writer */
                             format!("variable '{}' is still repeating at this depth",
-                                    token::get_ident(ident)));
+                                    token::get_ident(ident)).as_slice());
                     }
                 }
             }
index 80ee459a62d6fea0b9e0ea7618c28554f9ad5119..6f17412fa6385733eff5e9277a286209bc676aaa 100644 (file)
@@ -88,7 +88,7 @@ fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute {
             _ => {
                 let token_str = self.this_token_to_str();
                 self.fatal(format!("expected `\\#` but found `{}`",
-                                   token_str));
+                                   token_str).as_slice());
             }
         };
 
index c78d2aaf3a7e891567519b443054d9c1b6fa0619..5a7a816dbb3e01ce91626929277f9f128f62e2b9 100644 (file)
@@ -589,13 +589,13 @@ enum Result { Signed(ast::IntTy), Unsigned(ast::UintTy) }
             bump(rdr);
             bump(rdr);
             check_float_base(rdr, start_bpos, rdr.last_pos, base);
-            return token::LIT_FLOAT(str_to_ident(num_str.into_owned()),
+            return token::LIT_FLOAT(str_to_ident(num_str.as_slice()),
                                     ast::TyF32);
         } else if c == '6' && n == '4' {
             bump(rdr);
             bump(rdr);
             check_float_base(rdr, start_bpos, rdr.last_pos, base);
-            return token::LIT_FLOAT(str_to_ident(num_str.into_owned()),
+            return token::LIT_FLOAT(str_to_ident(num_str.as_slice()),
                                     ast::TyF64);
             /* FIXME (#2252): if this is out of range for either a
             32-bit or 64-bit float, it won't be noticed till the
@@ -612,8 +612,7 @@ enum Result { Signed(ast::IntTy), Unsigned(ast::UintTy) }
     }
     if is_float {
         check_float_base(rdr, start_bpos, rdr.last_pos, base);
-        return token::LIT_FLOAT_UNSUFFIXED(str_to_ident(
-                num_str.into_owned()));
+        return token::LIT_FLOAT_UNSUFFIXED(str_to_ident(num_str.as_slice()));
     } else {
         if num_str.len() == 0u {
             fatal_span(rdr, start_bpos, rdr.last_pos,
index 8e139b049c590f26cd2a6eeda0f3cbcea7aa1e3e..31a67ff92f5c0fe6664a6558683089dbe363400e 100644 (file)
@@ -224,7 +224,9 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
     let bytes = match File::open(path).read_to_end() {
         Ok(bytes) => bytes,
         Err(e) => {
-            err(format!("couldn't read {}: {}", path.display(), e));
+            err(format!("couldn't read {}: {}",
+                        path.display(),
+                        e).as_slice());
             unreachable!()
         }
     };
@@ -233,7 +235,9 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
             return string_to_filemap(sess, s.to_strbuf(),
                                      path.as_str().unwrap().to_strbuf())
         }
-        None => err(format!("{} is not UTF-8 encoded", path.display())),
+        None => {
+            err(format!("{} is not UTF-8 encoded", path.display()).as_slice())
+        }
     }
     unreachable!()
 }
index b6aa47128e630991140f31745c58a02654de3766..394b68d4a72e7f4a57dc2ee83b3065f121c7929a 100644 (file)
@@ -158,10 +158,14 @@ fn report(&mut self,
               kind: ObsoleteSyntax,
               kind_str: &str,
               desc: &str) {
-        self.span_err(sp, format!("obsolete syntax: {}", kind_str));
+        self.span_err(sp,
+                      format!("obsolete syntax: {}", kind_str).as_slice());
 
         if !self.obsolete_set.contains(&kind) {
-            self.sess.span_diagnostic.handler().note(format!("{}", desc));
+            self.sess
+                .span_diagnostic
+                .handler()
+                .note(format!("{}", desc).as_slice());
             self.obsolete_set.insert(kind);
         }
     }
index 5829f63b2c531bff38cb09db77b1e15f38547dba..4897fed692812ed3ae7ab358912c58b1ce7db76b 100644 (file)
@@ -371,12 +371,12 @@ pub fn this_token_to_str(&mut self) -> StrBuf {
     pub fn unexpected_last(&mut self, t: &token::Token) -> ! {
         let token_str = Parser::token_to_str(t);
         self.span_fatal(self.last_span, format!("unexpected token: `{}`",
-                                                token_str));
+                                                token_str).as_slice());
     }
 
     pub fn unexpected(&mut self) -> ! {
         let this_token = self.this_token_to_str();
-        self.fatal(format!("unexpected token: `{}`", this_token));
+        self.fatal(format!("unexpected token: `{}`", this_token).as_slice());
     }
 
     // expect and consume the token t. Signal an error if
@@ -389,7 +389,7 @@ pub fn expect(&mut self, t: &token::Token) {
             let this_token_str = self.this_token_to_str();
             self.fatal(format!("expected `{}` but found `{}`",
                                token_str,
-                               this_token_str))
+                               this_token_str).as_slice())
         }
     }
 
@@ -420,11 +420,15 @@ fn tokens_to_str(tokens: &[token::Token]) -> StrBuf {
             let expect = tokens_to_str(expected.as_slice());
             let actual = self.this_token_to_str();
             self.fatal(
-                if expected.len() != 1 {
-                    format!("expected one of `{}` but found `{}`", expect, actual)
+                (if expected.len() != 1 {
+                    (format!("expected one of `{}` but found `{}`",
+                             expect,
+                             actual))
                 } else {
-                    format!("expected `{}` but found `{}`", expect, actual)
-                }
+                    (format!("expected `{}` but found `{}`",
+                             expect,
+                             actual))
+                }).as_slice()
             )
         }
     }
@@ -501,7 +505,8 @@ pub fn parse_ident(&mut self) -> ast::Ident {
             }
             _ => {
                 let token_str = self.this_token_to_str();
-                self.fatal(format!( "expected ident, found `{}`", token_str))
+                self.fatal((format!("expected ident, found `{}`",
+                                    token_str)).as_slice())
             }
         }
     }
@@ -545,7 +550,7 @@ pub fn expect_keyword(&mut self, kw: keywords::Keyword) {
             let id_interned_str = token::get_ident(kw.to_ident());
             let token_str = self.this_token_to_str();
             self.fatal(format!("expected `{}`, found `{}`",
-                               id_interned_str, token_str))
+                               id_interned_str, token_str).as_slice())
         }
     }
 
@@ -554,7 +559,8 @@ pub fn check_strict_keywords(&mut self) {
         if token::is_strict_keyword(&self.token) {
             let token_str = self.this_token_to_str();
             self.span_err(self.span,
-                          format!("found `{}` in ident position", token_str));
+                          format!("found `{}` in ident position",
+                                  token_str).as_slice());
         }
     }
 
@@ -562,7 +568,8 @@ pub fn check_strict_keywords(&mut self) {
     pub fn check_reserved_keywords(&mut self) {
         if token::is_reserved_keyword(&self.token) {
             let token_str = self.this_token_to_str();
-            self.fatal(format!("`{}` is a reserved keyword", token_str))
+            self.fatal(format!("`{}` is a reserved keyword",
+                               token_str).as_slice())
         }
     }
 
@@ -581,7 +588,7 @@ fn expect_and(&mut self) {
                     Parser::token_to_str(&token::BINOP(token::AND));
                 self.fatal(format!("expected `{}`, found `{}`",
                                    found_token,
-                                   token_str))
+                                   token_str).as_slice())
             }
         }
     }
@@ -600,7 +607,8 @@ fn expect_or(&mut self) {
                 let token_str =
                     Parser::token_to_str(&token::BINOP(token::OR));
                 self.fatal(format!("expected `{}`, found `{}`",
-                                   token_str, found_token))
+                                   token_str,
+                                   found_token).as_slice())
             }
         }
     }
@@ -650,7 +658,8 @@ fn expect_lt(&mut self) {
             let found_token = self.this_token_to_str();
             let token_str = Parser::token_to_str(&token::LT);
             self.fatal(format!("expected `{}`, found `{}`",
-                               token_str, found_token))
+                               token_str,
+                               found_token).as_slice())
         }
     }
 
@@ -690,7 +699,7 @@ pub fn expect_gt(&mut self) {
                 let this_token_str = self.this_token_to_str();
                 self.fatal(format!("expected `{}`, found `{}`",
                                    gt_str,
-                                   this_token_str))
+                                   this_token_str).as_slice())
             }
         }
     }
@@ -1186,8 +1195,8 @@ pub fn parse_trait_methods(&mut self) -> Vec<TraitMethod> {
 
               _ => {
                   let token_str = p.this_token_to_str();
-                  p.fatal(format!("expected `;` or `\\{` but found `{}`",
-                                  token_str))
+                  p.fatal((format!("expected `;` or `\\{` but found `{}`",
+                                   token_str)).as_slice())
               }
             }
         })
@@ -1359,7 +1368,7 @@ pub fn parse_ty(&mut self, _: bool) -> P<Ty> {
             TyInfer
         } else {
             let msg = format!("expected type, found token {:?}", self.token);
-            self.fatal(msg);
+            self.fatal(msg.as_slice());
         };
 
         let sp = mk_sp(lo, self.last_span.hi);
@@ -1631,7 +1640,7 @@ pub fn parse_lifetime(&mut self) -> ast::Lifetime {
                 };
             }
             _ => {
-                self.fatal(format!("expected a lifetime name"));
+                self.fatal(format!("expected a lifetime name").as_slice());
             }
         }
     }
@@ -1667,7 +1676,7 @@ pub fn parse_lifetimes(&mut self) -> Vec<ast::Lifetime> {
                     let msg = format!("expected `,` or `>` after lifetime \
                                       name, got: {:?}",
                                       self.token);
-                    self.fatal(msg);
+                    self.fatal(msg.as_slice());
                 }
             }
         }
@@ -2122,7 +2131,7 @@ fn parse_non_delim_tt_tok(p: &mut Parser) -> TokenTree {
                   };
                   let token_str = p.this_token_to_str();
                   p.fatal(format!("incorrect close delimiter: `{}`",
-                                  token_str))
+                                  token_str).as_slice())
               },
               /* we ought to allow different depths of unquotation */
               token::DOLLAR if p.quote_depth > 0u => {
@@ -2773,7 +2782,7 @@ fn parse_pat_fields(&mut self) -> (Vec<ast::FieldPat> , bool) {
                 if self.token != token::RBRACE {
                     let token_str = self.this_token_to_str();
                     self.fatal(format!("expected `\\}`, found `{}`",
-                                       token_str))
+                                       token_str).as_slice())
                 }
                 etc = true;
                 break;
@@ -2793,7 +2802,8 @@ fn parse_pat_fields(&mut self) -> (Vec<ast::FieldPat> , bool) {
                 match bind_type {
                     BindByRef(..) | BindByValue(MutMutable) => {
                         let token_str = self.this_token_to_str();
-                        self.fatal(format!("unexpected `{}`", token_str))
+                        self.fatal(format!("unexpected `{}`",
+                                           token_str).as_slice())
                     }
                     _ => {}
                 }
@@ -3202,7 +3212,8 @@ fn check_expected_item(p: &mut Parser, found_attrs: bool) {
                     };
                     let tok_str = self.this_token_to_str();
                     self.fatal(format!("expected {}`(` or `\\{`, but found `{}`",
-                                       ident_str, tok_str))
+                                       ident_str,
+                                       tok_str).as_slice())
                 }
             };
 
@@ -3606,7 +3617,8 @@ fn is_self_ident(&mut self) -> bool {
     fn expect_self_ident(&mut self) {
         if !self.is_self_ident() {
             let token_str = self.this_token_to_str();
-            self.fatal(format!("expected `self` but found `{}`", token_str))
+            self.fatal(format!("expected `self` but found `{}`",
+                               token_str).as_slice())
         }
         self.bump();
     }
@@ -3738,7 +3750,7 @@ fn maybe_parse_borrowed_explicit_self(this: &mut Parser)
                 _ => {
                     let token_str = self.this_token_to_str();
                     self.fatal(format!("expected `,` or `)`, found `{}`",
-                                       token_str))
+                                       token_str).as_slice())
                 }
             }
         } else {
@@ -4005,8 +4017,9 @@ fn parse_item_struct(&mut self, is_virtual: bool) -> ItemInfo {
                 fields.push(self.parse_struct_decl_field());
             }
             if fields.len() == 0 {
-                self.fatal(format!("unit-like struct definition should be written as `struct {};`",
-                                   token::get_ident(class_name)));
+                self.fatal(format!("unit-like struct definition should be \
+                                    written as `struct {};`",
+                                   token::get_ident(class_name)).as_slice());
             }
             self.bump();
         } else if self.token == token::LPAREN {
@@ -4036,7 +4049,7 @@ fn parse_item_struct(&mut self, is_virtual: bool) -> ItemInfo {
             let token_str = self.this_token_to_str();
             self.fatal(format!("expected `\\{`, `(`, or `;` after struct \
                                 name but found `{}`",
-                               token_str))
+                               token_str).as_slice())
         }
 
         let _ = ast::DUMMY_NODE_ID;  // FIXME: Workaround for crazy bug.
@@ -4066,7 +4079,7 @@ pub fn parse_single_struct_field(&mut self,
                 let token_str = self.this_token_to_str();
                 self.span_fatal(self.span,
                                 format!("expected `,`, or `\\}` but found `{}`",
-                                        token_str))
+                                        token_str).as_slice())
             }
         }
         a_var
@@ -4147,7 +4160,7 @@ fn parse_mod_items(&mut self,
               _ => {
                   let token_str = self.this_token_to_str();
                   self.fatal(format!("expected item but found `{}`",
-                                     token_str))
+                                     token_str).as_slice())
               }
             }
         }
@@ -4229,8 +4242,8 @@ fn eval_src_mod(&mut self,
             Some(d) => (dir_path.join(d), true),
             None => {
                 let mod_name = mod_string.get().to_owned();
-                let default_path_str = mod_name + ".rs";
-                let secondary_path_str = mod_name + "/mod.rs";
+                let default_path_str = format!("{}.rs", mod_name);
+                let secondary_path_str = format!("{}/mod.rs", mod_name);
                 let default_path = dir_path.join(default_path_str.as_slice());
                 let secondary_path = dir_path.join(secondary_path_str.as_slice());
                 let default_exists = default_path.exists();
@@ -4246,12 +4259,14 @@ fn eval_src_mod(&mut self,
                     self.span_note(id_sp,
                                    format!("maybe move this module `{0}` \
                                             to its own directory via \
-                                            `{0}/mod.rs`", this_module));
+                                            `{0}/mod.rs`",
+                                           this_module).as_slice());
                     if default_exists || secondary_exists {
                         self.span_note(id_sp,
                                        format!("... or maybe `use` the module \
                                                 `{}` instead of possibly \
-                                                redeclaring it", mod_name));
+                                                redeclaring it",
+                                               mod_name).as_slice());
                     }
                     self.abort_if_errors();
                 }
@@ -4260,12 +4275,19 @@ fn eval_src_mod(&mut self,
                     (true, false) => (default_path, false),
                     (false, true) => (secondary_path, true),
                     (false, false) => {
-                        self.span_fatal(id_sp, format!("file not found for module `{}`", mod_name));
+                        self.span_fatal(id_sp,
+                                        format!("file not found for module \
+                                                 `{}`",
+                                                 mod_name).as_slice());
                     }
                     (true, true) => {
-                        self.span_fatal(id_sp,
-                                        format!("file for module `{}` found at both {} and {}",
-                                             mod_name, default_path_str, secondary_path_str));
+                        self.span_fatal(
+                            id_sp,
+                            format!("file for module `{}` found at both {} \
+                                     and {}",
+                                    mod_name,
+                                    default_path_str,
+                                    secondary_path_str).as_slice());
                     }
                 }
             }
@@ -4290,7 +4312,7 @@ fn eval_src_mod_from_path(&mut self,
                     err.push_str(" -> ");
                 }
                 err.push_str(path.display().as_maybe_owned().as_slice());
-                self.span_fatal(id_sp, err.into_owned());
+                self.span_fatal(id_sp, err.as_slice());
             }
             None => ()
         }
@@ -4348,12 +4370,14 @@ fn parse_item_foreign_static(&mut self, vis: ast::Visibility,
         let ty = self.parse_ty(false);
         let hi = self.span.hi;
         self.expect(&token::SEMI);
-        @ast::ForeignItem { ident: ident,
-                            attrs: attrs,
-                            node: ForeignItemStatic(ty, mutbl),
-                            id: ast::DUMMY_NODE_ID,
-                            span: mk_sp(lo, hi),
-                            vis: vis }
+        @ast::ForeignItem {
+            ident: ident,
+            attrs: attrs,
+            node: ForeignItemStatic(ty, mutbl),
+            id: ast::DUMMY_NODE_ID,
+            span: mk_sp(lo, hi),
+            vis: vis,
+        }
     }
 
     // parse safe/unsafe and fn
@@ -4418,8 +4442,9 @@ fn parse_item_extern_crate(&mut self,
             _ => {
                 let token_str = self.this_token_to_str();
                 self.span_fatal(self.span,
-                                format!("expected extern crate name but found `{}`",
-                                        token_str));
+                                format!("expected extern crate name but \
+                                         found `{}`",
+                                        token_str).as_slice());
             }
         };
 
@@ -4586,11 +4611,10 @@ fn parse_opt_abi(&mut self) -> Option<abi::Abi> {
                     None => {
                         self.span_err(
                             self.span,
-                            format!("illegal ABI: \
-                                  expected one of [{}], \
-                                  found `{}`",
-                                 abi::all_names().connect(", "),
-                                 the_string));
+                            format!("illegal ABI: expected one of [{}], \
+                                     found `{}`",
+                                    abi::all_names().connect(", "),
+                                    the_string).as_slice());
                         None
                     }
                 }
@@ -4645,7 +4669,8 @@ fn parse_item_or_view_item(&mut self,
                    self.span_err(mk_sp(lo, self.last_span.hi),
                                  format!("`extern mod` is obsolete, use \
                                           `extern crate` instead \
-                                          to refer to external crates."))
+                                          to refer to external \
+                                          crates.").as_slice())
                 }
                 return self.parse_item_extern_crate(lo, visibility, attrs);
             }
@@ -4670,7 +4695,8 @@ fn parse_item_or_view_item(&mut self,
 
             let token_str = self.this_token_to_str();
             self.span_fatal(self.span,
-                            format!("expected `\\{` or `fn` but found `{}`", token_str));
+                            format!("expected `\\{` or `fn` but found `{}`",
+                                    token_str).as_slice());
         }
 
         let is_virtual = self.eat_keyword(keywords::Virtual);
@@ -5076,7 +5102,8 @@ fn parse_items_and_view_items(&mut self,
                         }
                         ViewItemExternCrate(..) if !extern_mod_allowed => {
                             self.span_err(view_item.span,
-                                          "\"extern crate\" declarations are not allowed here");
+                                          "\"extern crate\" declarations are \
+                                           not allowed here");
                         }
                         ViewItemExternCrate(..) => {}
                     }
index f08cf264f8bfb0390df7f06a808be338e36ac1d0..b334aa632706e2af6695da1d46b69de95e00362e 100644 (file)
@@ -135,7 +135,9 @@ pub fn buf_str(toks: Vec<Token>,
         if i != left {
             s.push_str(", ");
         }
-        s.push_str(format!("{}={}", szs.get(i), tok_str(toks.get(i).clone())));
+        s.push_str(format!("{}={}",
+                           szs.get(i),
+                           tok_str(toks.get(i).clone())).as_slice());
         i += 1u;
         i %= n;
     }
index 15b931d58545ebc6406e86d2504307a6abfe28a7..5500ca45753066c988db4febf874e865826f8ed2 100644 (file)
@@ -141,7 +141,8 @@ pub fn to_str(f: |&mut State| -> IoResult<()>) -> StrBuf {
         // that we "know" to be a `MemWriter` that works around the lack of checked
         // downcasts.
         let (_, wr): (uint, Box<MemWriter>) = mem::transmute_copy(&s.s.out);
-        let result = str::from_utf8_owned(wr.get_ref().to_owned()).unwrap();
+        let result =
+            str::from_utf8_owned(Vec::from_slice(wr.get_ref())).unwrap();
         mem::forget(wr);
         result.to_strbuf()
     }
@@ -623,7 +624,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
             }
             ast::ItemForeignMod(ref nmod) => {
                 try!(self.head("extern"));
-                try!(self.word_nbsp(nmod.abi.to_str()));
+                try!(self.word_nbsp(nmod.abi.to_str().as_slice()));
                 try!(self.bopen());
                 try!(self.print_foreign_mod(nmod, item.attrs.as_slice()));
                 try!(self.bclose(item.span));
@@ -2234,7 +2235,7 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
                 let mut res = StrBuf::from_str("'");
                 ch.escape_default(|c| res.push_char(c));
                 res.push_char('\'');
-                word(&mut self.s, res.into_owned())
+                word(&mut self.s, res.as_slice())
             }
             ast::LitInt(i, t) => {
                 word(&mut self.s,
@@ -2247,11 +2248,14 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
                                               ast_util::ForceSuffix).as_slice())
             }
             ast::LitIntUnsuffixed(i) => {
-                word(&mut self.s, format!("{}", i))
+                word(&mut self.s, format!("{}", i).as_slice())
             }
             ast::LitFloat(ref f, t) => {
                 word(&mut self.s,
-                     f.get() + ast_util::float_ty_to_str(t).as_slice())
+                     format!(
+                         "{}{}",
+                         f.get(),
+                         ast_util::float_ty_to_str(t).as_slice()).as_slice())
             }
             ast::LitFloatUnsuffixed(ref f) => word(&mut self.s, f.get()),
             ast::LitNil => word(&mut self.s, "()"),
@@ -2261,8 +2265,13 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
             ast::LitBinary(ref arr) => {
                 try!(self.ibox(indent_unit));
                 try!(word(&mut self.s, "["));
-                try!(self.commasep_cmnt(Inconsistent, arr.as_slice(),
-                                        |s, u| word(&mut s.s, format!("{}", *u)),
+                try!(self.commasep_cmnt(Inconsistent,
+                                        arr.as_slice(),
+                                        |s, u| {
+                                            word(&mut s.s,
+                                                 format!("{}",
+                                                         *u).as_slice())
+                                        },
                                         |_| lit.span));
                 try!(word(&mut self.s, "]"));
                 self.end()
@@ -2354,11 +2363,16 @@ pub fn print_comment(&mut self,
     pub fn print_string(&mut self, st: &str,
                         style: ast::StrStyle) -> IoResult<()> {
         let st = match style {
-            ast::CookedStr => format!("\"{}\"", st.escape_default()),
-            ast::RawStr(n) => format!("r{delim}\"{string}\"{delim}",
-                                      delim="#".repeat(n), string=st)
+            ast::CookedStr => {
+                (format!("\"{}\"", st.escape_default()))
+            }
+            ast::RawStr(n) => {
+                (format!("r{delim}\"{string}\"{delim}",
+                         delim="#".repeat(n),
+                         string=st))
+            }
         };
-        word(&mut self.s, st)
+        word(&mut self.s, st.as_slice())
     }
 
     pub fn next_comment(&mut self) -> Option<comments::Comment> {
@@ -2389,7 +2403,7 @@ pub fn print_opt_abi_and_extern_if_nondefault(&mut self,
             Some(abi::Rust) => Ok(()),
             Some(abi) => {
                 try!(self.word_nbsp("extern"));
-                self.word_nbsp(abi.to_str())
+                self.word_nbsp(abi.to_str().as_slice())
             }
             None => Ok(())
         }
@@ -2400,7 +2414,7 @@ pub fn print_extern_opt_abi(&mut self,
         match opt_abi {
             Some(abi) => {
                 try!(self.word_nbsp("extern"));
-                self.word_nbsp(abi.to_str())
+                self.word_nbsp(abi.to_str().as_slice())
             }
             None => Ok(())
         }
@@ -2416,7 +2430,7 @@ pub fn print_fn_header_info(&mut self,
 
         if abi != abi::Rust {
             try!(self.word_nbsp("extern"));
-            try!(self.word_nbsp(abi.to_str()));
+            try!(self.word_nbsp(abi.to_str().as_slice()));
         }
 
         word(&mut self.s, "fn")
index 36e5c1cf763a6459567402a26135b4d948a0d360..7562bf2d163dc4941510fa659456e622be9ba434 100644 (file)
@@ -81,9 +81,11 @@ fn new(out: T) -> Option<TerminfoTerminal<T>> {
             }
         };
 
-        let entry = open(term);
+        let entry = open(term.as_slice());
         if entry.is_err() {
-            if os::getenv("MSYSCON").map_or(false, |s| "mintty.exe" == s) {
+            if os::getenv("MSYSCON").map_or(false, |s| {
+                    "mintty.exe" == s.as_slice()
+                }) {
                 // msys terminal
                 return Some(TerminfoTerminal {out: out, ti: msys_terminfo(), num_colors: 8});
             }
index 5a1c8ea02e2219920a53b4f5b49c7f2eb9466ad1..687e27f4282a9567a5fc4e4cb6cbc3937e685099 100644 (file)
@@ -221,7 +221,8 @@ macro_rules! try( ($e:expr) => (
         None => return Err("input not utf-8".to_strbuf()),
     };
 
-    let term_names: Vec<StrBuf> = names_str.split('|')
+    let term_names: Vec<StrBuf> = names_str.as_slice()
+                                           .split('|')
                                            .map(|s| s.to_strbuf())
                                            .collect();
 
index a7365102f96cadbfdc9246d005f9063352110cde..ac5737c46ed41d93d653de1cdb052ec58411e6ee 100644 (file)
@@ -36,11 +36,11 @@ pub fn get_dbpath_for_term(term: &str) -> Option<Box<Path>> {
                 dirs_to_search.push(homedir.unwrap().join(".terminfo"))
             }
             match getenv("TERMINFO_DIRS") {
-                Some(dirs) => for i in dirs.split(':') {
+                Some(dirs) => for i in dirs.as_slice().split(':') {
                     if i == "" {
                         dirs_to_search.push(Path::new("/usr/share/terminfo"));
                     } else {
-                        dirs_to_search.push(Path::new(i.to_owned()));
+                        dirs_to_search.push(Path::new(i.to_strbuf()));
                     }
                 },
                 // Found nothing in TERMINFO_DIRS, use the default paths:
index 06b1126ed05b55f2ebf41e7670a23ef0b546b611..1f10956b38015fdf15a5c90836239c2dab3a5c42 100644 (file)
@@ -355,7 +355,8 @@ fn usage(binary: &str) {
                      normal test runs. Running with --ignored will run these
                      tests. This may also be written as \#[ignore(cfg(...))] to
                      ignore the test on certain configurations.",
-             usage = getopts::usage(message, optgroups().as_slice()));
+             usage = getopts::usage(message.as_slice(),
+                                    optgroups().as_slice()));
 }
 
 // Parses command line arguments into test options
@@ -568,13 +569,13 @@ pub fn write_plain(&mut self, s: &str) -> io::IoResult<()> {
     pub fn write_run_start(&mut self, len: uint) -> io::IoResult<()> {
         self.total = len;
         let noun = if len != 1 { "tests" } else { "test" };
-        self.write_plain(format!("\nrunning {} {}\n", len, noun))
+        self.write_plain(format!("\nrunning {} {}\n", len, noun).as_slice())
     }
 
     pub fn write_test_start(&mut self, test: &TestDesc,
                             align: NamePadding) -> io::IoResult<()> {
         let name = test.padded_name(self.max_name_len, align);
-        self.write_plain(format!("test {} ... ", name))
+        self.write_plain(format!("test {} ... ", name).as_slice())
     }
 
     pub fn write_result(&mut self, result: &TestResult) -> io::IoResult<()> {
@@ -584,11 +585,12 @@ pub fn write_result(&mut self, result: &TestResult) -> io::IoResult<()> {
             TrIgnored => self.write_ignored(),
             TrMetrics(ref mm) => {
                 try!(self.write_metric());
-                self.write_plain(format!(": {}", fmt_metrics(mm)))
+                self.write_plain(format!(": {}", fmt_metrics(mm)).as_slice())
             }
             TrBench(ref bs) => {
                 try!(self.write_bench());
-                self.write_plain(format!(": {}", fmt_bench_samples(bs)))
+                self.write_plain(format!(": {}",
+                                         fmt_bench_samples(bs)).as_slice())
             }
         });
         self.write_plain("\n")
@@ -619,9 +621,11 @@ pub fn write_failures(&mut self) -> io::IoResult<()> {
             failures.push(f.name.to_str());
             if stdout.len() > 0 {
                 fail_out.push_str(format!("---- {} stdout ----\n\t",
-                                  f.name.as_slice()));
+                                          f.name.as_slice()).as_slice());
                 let output = str::from_utf8_lossy(stdout.as_slice());
-                fail_out.push_str(output.as_slice().replace("\n", "\n\t"));
+                fail_out.push_str(output.as_slice()
+                                        .replace("\n", "\n\t")
+                                        .as_slice());
                 fail_out.push_str("\n");
             }
         }
@@ -633,7 +637,8 @@ pub fn write_failures(&mut self) -> io::IoResult<()> {
         try!(self.write_plain("\nfailures:\n"));
         failures.as_mut_slice().sort();
         for name in failures.iter() {
-            try!(self.write_plain(format!("    {}\n", name.as_slice())));
+            try!(self.write_plain(format!("    {}\n",
+                                          name.as_slice()).as_slice()));
         }
         Ok(())
     }
@@ -651,24 +656,26 @@ pub fn write_metric_diff(&mut self, diff: &MetricDiff) -> io::IoResult<()> {
                 MetricAdded => {
                     added += 1;
                     try!(self.write_added());
-                    try!(self.write_plain(format!(": {}\n", *k)));
+                    try!(self.write_plain(format!(": {}\n", *k).as_slice()));
                 }
                 MetricRemoved => {
                     removed += 1;
                     try!(self.write_removed());
-                    try!(self.write_plain(format!(": {}\n", *k)));
+                    try!(self.write_plain(format!(": {}\n", *k).as_slice()));
                 }
                 Improvement(pct) => {
                     improved += 1;
-                    try!(self.write_plain(format!(": {}", *k)));
+                    try!(self.write_plain(format!(": {}", *k).as_slice()));
                     try!(self.write_improved());
-                    try!(self.write_plain(format!(" by {:.2f}%\n", pct as f64)));
+                    try!(self.write_plain(format!(" by {:.2f}%\n",
+                                                  pct as f64).as_slice()));
                 }
                 Regression(pct) => {
                     regressed += 1;
-                    try!(self.write_plain(format!(": {}", *k)));
+                    try!(self.write_plain(format!(": {}", *k).as_slice()));
                     try!(self.write_regressed());
-                    try!(self.write_plain(format!(" by {:.2f}%\n", pct as f64)));
+                    try!(self.write_plain(format!(" by {:.2f}%\n",
+                                                  pct as f64).as_slice()));
                 }
             }
         }
@@ -676,7 +683,7 @@ pub fn write_metric_diff(&mut self, diff: &MetricDiff) -> io::IoResult<()> {
                                         {} removed, {} improved, {} regressed, \
                                         {} noise\n",
                                        added, removed, improved, regressed,
-                                       noise)));
+                                       noise).as_slice()));
         if regressed == 0 {
             try!(self.write_plain("updated ratchet file\n"));
         } else {
@@ -694,13 +701,13 @@ pub fn write_run_finish(&mut self,
             None => true,
             Some(ref pth) => {
                 try!(self.write_plain(format!("\nusing metrics ratchet: {}\n",
-                                        pth.display())));
+                                              pth.display()).as_slice()));
                 match ratchet_pct {
                     None => (),
                     Some(pct) =>
                         try!(self.write_plain(format!("with noise-tolerance \
                                                          forced to: {}%\n",
-                                                        pct)))
+                                                        pct).as_slice()))
                 }
                 let (diff, ok) = self.metrics.ratchet(pth, ratchet_pct);
                 try!(self.write_metric_diff(&diff));
@@ -724,7 +731,7 @@ pub fn write_run_finish(&mut self,
         }
         let s = format!(". {} passed; {} failed; {} ignored; {} measured\n\n",
                         self.passed, self.failed, self.ignored, self.measured);
-        try!(self.write_plain(s));
+        try!(self.write_plain(s.as_slice()));
         return Ok(success);
     }
 }
@@ -771,7 +778,9 @@ fn callback<T: Writer>(event: &TestEvent, st: &mut ConsoleTestState<T>) -> io::I
                         let MetricMap(mm) = mm;
                         for (k,v) in mm.iter() {
                             st.metrics
-                              .insert_metric(tname + "." + k.as_slice(),
+                              .insert_metric(format!("{}.{}",
+                                                     tname,
+                                                     k).as_slice(),
                                              v.value,
                                              v.noise);
                         }
@@ -813,7 +822,7 @@ fn len_if_padded(t: &TestDescAndFn) -> uint {
         Some(ref pth) => {
             try!(st.metrics.save(pth));
             try!(st.write_plain(format!("\nmetrics saved to: {}",
-                                          pth.display())));
+                                          pth.display()).as_slice()));
         }
     }
     return st.write_run_finish(&opts.ratchet_metrics, opts.ratchet_noise_percent);
@@ -936,7 +945,7 @@ fn get_concurrency() -> uint {
     use std::rt;
     match os::getenv("RUST_TEST_TASKS") {
         Some(s) => {
-            let opt_n: Option<uint> = FromStr::from_str(s);
+            let opt_n: Option<uint> = FromStr::from_str(s.as_slice());
             match opt_n {
                 Some(n) if n > 0 => n,
                 _ => fail!("RUST_TEST_TASKS is `{}`, should be a positive integer.", s)
index 0e67076dc08e3f2e2c2a4dcc66250b05b9ace2f1..8f47a7ce2cb2a47054dbf93a275847150b2e5b07 100644 (file)
@@ -237,21 +237,11 @@ pub struct Tm {
     /// for U.S. Pacific Daylight Time, the value is -7*60*60 = -25200.
     pub tm_gmtoff: i32,
 
-    /// Abbreviated name for the time zone that was used to compute this broken-down time value.
-    /// For example, U.S. Pacific Daylight Time is "PDT".
-    pub tm_zone: ~str,
-
     /// Nanoseconds after the second – [0, 10<sup>9</sup> - 1]
     pub tm_nsec: i32,
 }
 
 pub fn empty_tm() -> Tm {
-    // 64 is the max size of the timezone buffer allocated on windows
-    // in rust_localtime. In glibc the max timezone size is supposedly 3.
-    let mut zone = StrBuf::new();
-    for _ in range(0, 64) {
-        zone.push_char(' ')
-    }
     Tm {
         tm_sec: 0_i32,
         tm_min: 0_i32,
@@ -263,7 +253,6 @@ pub fn empty_tm() -> Tm {
         tm_yday: 0_i32,
         tm_isdst: 0_i32,
         tm_gmtoff: 0_i32,
-        tm_zone: zone.into_owned(),
         tm_nsec: 0_i32,
     }
 }
@@ -745,7 +734,6 @@ fn parse_type(s: &str, pos: uint, ch: char, tm: &mut Tm)
           'Z' => {
             if match_str(s, pos, "UTC") || match_str(s, pos, "GMT") {
                 tm.tm_gmtoff = 0_i32;
-                tm.tm_zone = "UTC".to_owned();
                 Ok(pos + 3u)
             } else {
                 // It's odd, but to maintain compatibility with c's
@@ -770,7 +758,6 @@ fn parse_type(s: &str, pos: uint, ch: char, tm: &mut Tm)
                     let (v, pos) = item;
                     if v == 0_i32 {
                         tm.tm_gmtoff = 0_i32;
-                        tm.tm_zone = "UTC".to_owned();
                     }
 
                     Ok(pos)
@@ -801,7 +788,6 @@ fn parse_type(s: &str, pos: uint, ch: char, tm: &mut Tm)
         tm_yday: 0_i32,
         tm_isdst: 0_i32,
         tm_gmtoff: 0_i32,
-        tm_zone: "".to_owned(),
         tm_nsec: 0_i32,
     };
     let mut pos = 0u;
@@ -848,7 +834,6 @@ fn parse_type(s: &str, pos: uint, ch: char, tm: &mut Tm)
             tm_yday: tm.tm_yday,
             tm_isdst: tm.tm_isdst,
             tm_gmtoff: tm.tm_gmtoff,
-            tm_zone: tm.tm_zone.clone(),
             tm_nsec: tm.tm_nsec,
         })
     } else { result }
@@ -1050,7 +1035,7 @@ fn parse_type(ch: char, tm: &Tm) -> StrBuf {
           'w' => (tm.tm_wday as int).to_str().to_strbuf(),
           'Y' => (tm.tm_year as int + 1900).to_str().to_strbuf(),
           'y' => format_strbuf!("{:02d}", (tm.tm_year as int + 1900) % 100),
-          'Z' => tm.tm_zone.to_strbuf(),
+          'Z' => "".to_strbuf(),    // FIXME(pcwalton): Implement this.
           'z' => {
             let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' };
             let mut m = num::abs(tm.tm_gmtoff) / 60_i32;
@@ -1176,7 +1161,6 @@ fn test_at_utc() {
         assert_eq!(utc.tm_yday, 43_i32);
         assert_eq!(utc.tm_isdst, 0_i32);
         assert_eq!(utc.tm_gmtoff, 0_i32);
-        assert_eq!(utc.tm_zone, "UTC".to_owned());
         assert_eq!(utc.tm_nsec, 54321_i32);
     }
 
@@ -1198,12 +1182,6 @@ fn test_at() {
         assert_eq!(local.tm_yday, 43_i32);
         assert_eq!(local.tm_isdst, 0_i32);
         assert_eq!(local.tm_gmtoff, -28800_i32);
-
-        // FIXME (#2350): We should probably standardize on the timezone
-        // abbreviation.
-        let zone = &local.tm_zone;
-        assert!(*zone == "PST".to_owned() || *zone == "Pacific Standard Time".to_owned());
-
         assert_eq!(local.tm_nsec, 54321_i32);
     }
 
@@ -1246,7 +1224,6 @@ fn test_strptime() {
             assert!(tm.tm_wday == 0_i32);
             assert!(tm.tm_isdst == 0_i32);
             assert!(tm.tm_gmtoff == 0_i32);
-            assert!(tm.tm_zone == "".to_owned());
             assert!(tm.tm_nsec == 0_i32);
           }
           Err(_) => ()
@@ -1270,7 +1247,6 @@ fn test_strptime() {
             assert!(tm.tm_yday == 0_i32);
             assert!(tm.tm_isdst == 0_i32);
             assert!(tm.tm_gmtoff == 0_i32);
-            assert!(tm.tm_zone == "".to_owned());
             assert!(tm.tm_nsec == 12340000_i32);
           }
         }
@@ -1382,10 +1358,6 @@ fn test(s: &str, format: &str) -> bool {
         assert!(test("6", "%w"));
         assert!(test("2009", "%Y"));
         assert!(test("09", "%y"));
-        assert!(strptime("UTC", "%Z").unwrap().tm_zone ==
-            "UTC".to_owned());
-        assert!(strptime("PST", "%Z").unwrap().tm_zone ==
-            "".to_owned());
         assert!(strptime("-0000", "%z").unwrap().tm_gmtoff ==
             0);
         assert!(strptime("-0800", "%z").unwrap().tm_gmtoff ==
@@ -1457,22 +1429,9 @@ fn test_strftime() {
         assert_eq!(local.strftime("%Y"), "2009".to_strbuf());
         assert_eq!(local.strftime("%y"), "09".to_strbuf());
         assert_eq!(local.strftime("%+"), "2009-02-13T15:31:30-08:00".to_strbuf());
-
-        // FIXME (#2350): We should probably standardize on the timezone
-        // abbreviation.
-        let zone = local.strftime("%Z");
-        assert!(zone == "PST".to_strbuf() || zone == "Pacific Standard Time".to_strbuf());
-
         assert_eq!(local.strftime("%z"), "-0800".to_strbuf());
         assert_eq!(local.strftime("%%"), "%".to_strbuf());
 
-        // FIXME (#2350): We should probably standardize on the timezone
-        // abbreviation.
-        let rfc822 = local.rfc822();
-        let prefix = "Fri, 13 Feb 2009 15:31:30 ".to_strbuf();
-        assert!(rfc822 == format_strbuf!("{}PST", prefix) ||
-                rfc822 == format_strbuf!("{}Pacific Standard Time", prefix));
-
         assert_eq!(local.ctime(), "Fri Feb 13 15:31:30 2009".to_strbuf());
         assert_eq!(local.rfc822z(), "Fri, 13 Feb 2009 15:31:30 -0800".to_strbuf());
         assert_eq!(local.rfc3339(), "2009-02-13T15:31:30-08:00".to_strbuf());
index 5fc567f06d38d8fbed9fee6d5b4b7275bf6e9d2f..e75afa04cd40d6b0194e564b07acb37dbf8d3520 100644 (file)
@@ -164,10 +164,10 @@ fn encode_inner(s: &str, full_url: bool) -> StrBuf {
                     out.push_char(ch);
                   }
 
-                  _ => out.push_str(format!("%{:X}", ch as uint))
+                  _ => out.push_str(format!("%{:X}", ch as uint).as_slice())
                 }
             } else {
-                out.push_str(format!("%{:X}", ch as uint));
+                out.push_str(format!("%{:X}", ch as uint).as_slice());
             }
           }
         }
@@ -292,7 +292,7 @@ fn encode_plus(s: &str) -> StrBuf {
             out.push_char(ch);
           }
           ' ' => out.push_char('+'),
-          _ => out.push_str(format!("%{:X}", ch as uint))
+          _ => out.push_str(format!("%{:X}", ch as uint).as_slice())
         }
     }
 
@@ -319,7 +319,7 @@ pub fn encode_form_urlencoded(m: &HashMap<StrBuf, Vec<StrBuf>>) -> StrBuf {
 
             out.push_str(format!("{}={}",
                                  key,
-                                 encode_plus(value.as_slice())));
+                                 encode_plus(value.as_slice())).as_slice());
         }
     }
 
index d2032b9d49281a7436149776718c389cae4e563b..de9d6ef7c89aa87490ff926c81ab1d7ba46aa6ab 100644 (file)
@@ -326,8 +326,8 @@ pub fn to_simple_str(&self) -> StrBuf {
         let mut s: Vec<u8> = Vec::from_elem(32, 0u8);
         for i in range(0u, 16u) {
             let digit = format!("{:02x}", self.bytes[i] as uint);
-            *s.get_mut(i*2+0) = digit[0];
-            *s.get_mut(i*2+1) = digit[1];
+            *s.get_mut(i*2+0) = digit.as_slice()[0];
+            *s.get_mut(i*2+1) = digit.as_slice()[1];
         }
         str::from_utf8(s.as_slice()).unwrap().to_strbuf()
     }
@@ -426,14 +426,16 @@ pub fn parse_string(us: &str) -> Result<Uuid, ParseError> {
 
         // At this point, we know we have a valid hex string, without hyphens
         assert!(vs.len() == 32);
-        assert!(vs.chars().all(|c| c.is_digit_radix(16)));
+        assert!(vs.as_slice().chars().all(|c| c.is_digit_radix(16)));
 
         // Allocate output UUID buffer
         let mut ub = [0u8, ..16];
 
         // Extract each hex digit from the string
         for i in range(0u, 16u) {
-            ub[i] = FromStrRadix::from_str_radix(vs.slice(i*2, (i+1)*2), 16).unwrap();
+            ub[i] = FromStrRadix::from_str_radix(vs.as_slice()
+                                                   .slice(i*2, (i+1)*2),
+                                                 16).unwrap();
         }
 
         Ok(Uuid::from_bytes(ub).unwrap())
@@ -624,7 +626,7 @@ fn test_parse_uuid_v4() {
         // Round-trip
         let uuid_orig = Uuid::new_v4();
         let orig_str = uuid_orig.to_str();
-        let uuid_out = Uuid::parse_string(orig_str).unwrap();
+        let uuid_out = Uuid::parse_string(orig_str.as_slice()).unwrap();
         assert!(uuid_orig == uuid_out);
 
         // Test error reporting
@@ -706,7 +708,7 @@ fn test_string_roundtrip() {
         assert!(uuid_hs == uuid);
 
         let ss = uuid.to_str();
-        let uuid_ss = Uuid::parse_string(ss).unwrap();
+        let uuid_ss = Uuid::parse_string(ss.as_slice()).unwrap();
         assert!(uuid_ss == uuid);
     }
 
index 6ab36f1db7a82f56ffb5c46b0af730e2d8c9e46f..ed077e69978a9416b2fcd8ff72da3573e33cad00 100644 (file)
@@ -127,15 +127,6 @@ rust_list_dir_wfd_fp_buf(void* wfd) {
 }
 #endif
 
-typedef struct
-{
-    size_t fill;    // in bytes; if zero, heapified
-    size_t alloc;   // in bytes
-    uint8_t data[0];
-} rust_vec;
-
-typedef rust_vec rust_str;
-
 typedef struct {
     int32_t tm_sec;
     int32_t tm_min;
@@ -147,7 +138,6 @@ typedef struct {
     int32_t tm_yday;
     int32_t tm_isdst;
     int32_t tm_gmtoff;
-    rust_str *tm_zone;
     int32_t tm_nsec;
 } rust_tm;
 
@@ -164,8 +154,10 @@ void rust_tm_to_tm(rust_tm* in_tm, struct tm* out_tm) {
     out_tm->tm_isdst = in_tm->tm_isdst;
 }
 
-void tm_to_rust_tm(struct tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
-                   const char *zone, int32_t nsec) {
+void tm_to_rust_tm(struct tm* in_tm,
+                   rust_tm* out_tm,
+                   int32_t gmtoff,
+                   int32_t nsec) {
     out_tm->tm_sec = in_tm->tm_sec;
     out_tm->tm_min = in_tm->tm_min;
     out_tm->tm_hour = in_tm->tm_hour;
@@ -177,13 +169,6 @@ void tm_to_rust_tm(struct tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
     out_tm->tm_isdst = in_tm->tm_isdst;
     out_tm->tm_gmtoff = gmtoff;
     out_tm->tm_nsec = nsec;
-
-    if (zone != NULL) {
-        size_t size = strlen(zone);
-        assert(out_tm->tm_zone->alloc >= size);
-        memcpy(out_tm->tm_zone->data, zone, size);
-        out_tm->tm_zone->fill = size;
-    }
 }
 
 #if defined(__WIN32__)
@@ -225,7 +210,7 @@ rust_gmtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
     time_t s = sec;
     GMTIME(&s, &tm);
 
-    tm_to_rust_tm(&tm, timeptr, 0, "UTC", nsec);
+    tm_to_rust_tm(&tm, timeptr, 0, nsec);
 }
 
 void
@@ -234,28 +219,13 @@ rust_localtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
     time_t s = sec;
     LOCALTIME(&s, &tm);
 
-    const char* zone = NULL;
 #if defined(__WIN32__)
     int32_t gmtoff = -timezone;
-    wchar_t wbuffer[64] = {0};
-    char buffer[256] = {0};
-    // strftime("%Z") can contain non-UTF-8 characters on non-English locale (issue #9418),
-    // so time zone should be converted from UTF-16 string.
-    // Since wcsftime depends on setlocale() result,
-    // instead we convert it using MultiByteToWideChar.
-    if (strftime(buffer, sizeof(buffer) / sizeof(char), "%Z", &tm) > 0) {
-        // ANSI -> UTF-16
-        MultiByteToWideChar(CP_ACP, 0, buffer, -1, wbuffer, sizeof(wbuffer) / sizeof(wchar_t));
-        // UTF-16 -> UTF-8
-        WideCharToMultiByte(CP_UTF8, 0, wbuffer, -1, buffer, sizeof(buffer), NULL, NULL);
-        zone = buffer;
-    }
 #else
     int32_t gmtoff = tm.tm_gmtoff;
-    zone = tm.tm_zone;
 #endif
 
-    tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);
+    tm_to_rust_tm(&tm, timeptr, gmtoff, nsec);
 }
 
 int64_t
index 6a8a56b4f1f8a2a4ce036226ef5e37775b7bdc20..d7acd82092fac66e426344c3a0dcff3c8e4f50d4 100644 (file)
@@ -93,7 +93,7 @@ fn main() {
     let args = args.as_slice();
     let n_keys = {
         if args.len() == 2 {
-            from_str::<uint>(args[1]).unwrap()
+            from_str::<uint>(args[1].as_slice()).unwrap()
         } else {
             1000000
         }
index 757d61f28574692221efacea58c0ab390477901b..ffc2fdffba4473ea4f50a5d0b83c0b6e745fd8e7 100644 (file)
@@ -158,7 +158,7 @@ fn main() {
     let args = args.as_slice();
     let num_keys = {
         if args.len() == 2 {
-            from_str::<uint>(args[1]).unwrap()
+            from_str::<uint>(args[1].as_slice()).unwrap()
         } else {
             100 // woefully inadequate for any real measurement
         }
index d954b0c12e3c8513dfe89786de8259a7836856cb..381527763c9628c4910b64c6bad347c620c868bd 100644 (file)
@@ -21,7 +21,7 @@ fn main() {
         args.move_iter().collect()
     };
 
-    let n = from_str::<uint>(*args.get(1)).unwrap();
+    let n = from_str::<uint>(args.get(1).as_slice()).unwrap();
 
     for i in range(0u, n) {
         let x = i.to_str();
index 2779ec06e9ff0bc5a7ab3fb0cb88cc7bf15e0721..633ac6ebcdff89761700ecd943c5471554c79639 100644 (file)
@@ -70,8 +70,8 @@ fn main() {
         args.clone().move_iter().collect()
     };
 
-    let num_tasks = from_str::<uint>(*args.get(1)).unwrap();
-    let msg_per_task = from_str::<uint>(*args.get(2)).unwrap();
+    let num_tasks = from_str::<uint>(args.get(1).as_slice()).unwrap();
+    let msg_per_task = from_str::<uint>(args.get(2).as_slice()).unwrap();
 
     let (mut num_chan, num_port) = init();
 
index 70b31017223e68f13461eda8de593f9e49220408..a324f10fb33af98c6bd59aa48565a8698b7a5567 100644 (file)
@@ -71,8 +71,8 @@ fn main() {
         args.clone().move_iter().collect()
     };
 
-    let num_tasks = from_str::<uint>(*args.get(1)).unwrap();
-    let msg_per_task = from_str::<uint>(*args.get(2)).unwrap();
+    let num_tasks = from_str::<uint>(args.get(1).as_slice()).unwrap();
+    let msg_per_task = from_str::<uint>(args.get(2).as_slice()).unwrap();
 
     let (mut num_chan, num_port) = init();
 
index bbe6b6c23f0f97082a618803abc7d7a00887b997..34e0742b6324af1114831bd4987a33474a92a63b 100644 (file)
@@ -63,13 +63,13 @@ fn main() {
     let args = os::args();
     let args = args.as_slice();
     let n = if args.len() == 3 {
-        from_str::<uint>(args[1]).unwrap()
+        from_str::<uint>(args[1].as_slice()).unwrap()
     } else {
         10000
     };
 
     let m = if args.len() == 3 {
-        from_str::<uint>(args[2]).unwrap()
+        from_str::<uint>(args[2].as_slice()).unwrap()
     } else {
         4
     };
index 29cee668389f873d89d557508625e63f43b6d265..4072dc0064afba5ebe7db90a5a9ba86fd8f7ba22 100644 (file)
@@ -33,7 +33,7 @@ fn main() {
     let args = os::args();
     let args = args.as_slice();
     let n = if args.len() == 2 {
-        from_str::<uint>(args[1]).unwrap()
+        from_str::<uint>(args[1].as_slice()).unwrap()
     } else {
         10
     };
index 48d4a41c1a39aae1f9d7032ffc8d990bccd3a7f4..a091c6be9f8c6aa676aa0ddec2324270ac692ff0 100644 (file)
@@ -30,7 +30,7 @@ fn main() {
     let args = os::args();
     let args = args.as_slice();
     let n = if args.len() == 2 {
-        from_str::<uint>(args[1]).unwrap()
+        from_str::<uint>(args[1].as_slice()).unwrap()
     } else {
         100000
     };
index 46ea188a271a46798e06cd4d30d3c57c2afb7da8..e0116931538e9deb8f947f12d0514cad30ad00be 100644 (file)
@@ -31,6 +31,6 @@ fn main() {
     } else {
         args.move_iter().collect()
     };
-    let n = from_str::<int>(*args.get(1)).unwrap();
+    let n = from_str::<int>(args.get(1).as_slice()).unwrap();
     println!("Ack(3,{}): {}\n", n, ack(3, n));
 }
index 181d19ade3ab421068e9659f13cc5a2ba6cb1c63..eab8b66b90d1ecc5f035b74eb7ffe5c6a36abfbf 100644 (file)
@@ -46,7 +46,7 @@ fn main() {
     } else if args.len() <= 1u {
         8
     } else {
-        from_str(args[1]).unwrap()
+        from_str(args[1].as_slice()).unwrap()
     };
     let min_depth = 4;
     let max_depth = if min_depth + 2 > n {min_depth + 2} else {n};
index f0bc0204fd26d17a53262f6581ba2619246396ea..181fe29c89185eec23b34ae2ef9b8fe6c0260bfa 100644 (file)
@@ -48,7 +48,7 @@ fn show_color_list(set: Vec<Color>) -> StrBuf {
     let mut out = StrBuf::new();
     for col in set.iter() {
         out.push_char(' ');
-        out.push_str(col.to_str());
+        out.push_str(col.to_str().as_slice());
     }
     out
 }
@@ -198,7 +198,10 @@ fn main() {
     let nn = if std::os::getenv("RUST_BENCH").is_some() {
         200000
     } else {
-        std::os::args().as_slice().get(1).and_then(|arg| from_str(*arg)).unwrap_or(600)
+        std::os::args().as_slice()
+                       .get(1)
+                       .and_then(|arg| from_str(arg.as_slice()))
+                       .unwrap_or(600)
     };
 
     print_complements();
index 3525b90d3f681c2fddbefa8aefc5aed08cd847a2..9cc8f2f23ff26aa4a3a24f422d86a94fe34aa43a 100644 (file)
@@ -53,7 +53,10 @@ fn fannkuch(n: uint, i: uint) -> (int, int) {
 }
 
 fn main() {
-    let n = std::os::args().as_slice().get(1).and_then(|arg| from_str(*arg)).unwrap_or(2u);
+    let n = std::os::args().as_slice()
+                           .get(1)
+                           .and_then(|arg| from_str(arg.as_slice()))
+                           .unwrap_or(2u);
 
     let (tx, rx) = channel();
     for i in range(0, n) {
index 3f8d3275b64f9456c33312b2da515b2b2e0abc3a..adec9d31afecbed4b2b6b08ffbe9c2747be1f26d 100644 (file)
@@ -179,7 +179,7 @@ fn main() {
     let args = os::args();
     let args = args.as_slice();
     let n = if args.len() > 1 {
-        from_str::<uint>(args[1]).unwrap()
+        from_str::<uint>(args[1].as_slice()).unwrap()
     } else {
         5
     };
index c526ef54caff2277c9af923bca84ec485929ca07..4126fda00bcce0db085ba2f767712192abc77f73 100644 (file)
@@ -80,7 +80,7 @@ fn run<W: Writer>(writer: &mut W) {
     } else if args.len() <= 1u {
         1000
     } else {
-        from_str(args[1]).unwrap()
+        from_str(args[1].as_slice()).unwrap()
     };
 
     let rng = &mut MyRandom::new();
index a453ddccde51057a6b03444145199aff75782c38..76f96f8d43b993d743df9a86a6937923439d8a32 100644 (file)
@@ -27,6 +27,6 @@ fn main() {
     } else {
         args.move_iter().collect()
     };
-    let n = from_str::<int>(*args.get(1)).unwrap();
+    let n = from_str::<int>(args.get(1).as_slice()).unwrap();
     println!("{}\n", fib(n));
 }
index 250562a095ea035658372b2d962102d5b2eb5ac6..6f8c44f4bdfb84d9d57406cf1a1f22f02ac6cb59 100644 (file)
@@ -64,7 +64,7 @@ fn sortKV(mut orig: Vec<(Vec<u8> ,f64)> ) -> Vec<(Vec<u8> ,f64)> {
                                k.as_slice()
                                .to_ascii()
                                .to_upper()
-                               .into_str(), v));
+                               .into_str(), v).as_slice());
    }
 
    return buffer
@@ -179,15 +179,15 @@ fn main() {
    let mut proc_mode = false;
 
    for line in rdr.lines() {
-       let line = line.unwrap().trim().to_owned();
+       let line = line.unwrap().as_slice().trim().to_owned();
 
        if line.len() == 0u { continue; }
 
-       match (line[0] as char, proc_mode) {
+       match (line.as_slice()[0] as char, proc_mode) {
 
            // start processing if this is the one
            ('>', false) => {
-               match line.slice_from(1).find_str("THREE") {
+               match line.as_slice().slice_from(1).find_str("THREE") {
                    option::Some(_) => { proc_mode = true; }
                    option::None    => { }
                }
index 1434838e59bce81008381670be25f4a830cc4a95..e46f27a9f41587ddb2bed22e9abdb89a20a05b1c 100644 (file)
@@ -252,9 +252,9 @@ fn print_occurrences(frequencies: &mut Table, occurrence: &'static str) {
 fn get_sequence<R: Buffer>(r: &mut R, key: &str) -> Vec<u8> {
     let mut res = Vec::new();
     for l in r.lines().map(|l| l.ok().unwrap())
-        .skip_while(|l| key != l.slice_to(key.len())).skip(1)
+        .skip_while(|l| key != l.as_slice().slice_to(key.len())).skip(1)
     {
-        res.push_all(l.trim().as_bytes());
+        res.push_all(l.as_slice().trim().as_bytes());
     }
     for b in res.mut_iter() {
         *b = b.to_ascii().to_upper().to_byte();
index debd12874da1ee6e1c485096df7ef1ae3143e7b1..6b3079b8fc8d1246761b77f490cea9609d707352 100644 (file)
@@ -169,7 +169,7 @@ fn main() {
                   which interferes with the test runner.");
         mandelbrot(1000, io::util::NullWriter)
     } else {
-        mandelbrot(from_str(args[1]).unwrap(), io::stdout())
+        mandelbrot(from_str(args[1].as_slice()).unwrap(), io::stdout())
     };
     res.unwrap();
 }
index f9a84f276bf6e36bf890865f033d59b4facee7f2..5a077b377475c3aee20a8466764aabc59c9c2aa1 100644 (file)
@@ -141,7 +141,7 @@ fn main() {
         5000000
     } else {
         std::os::args().as_slice().get(1)
-            .and_then(|arg| from_str(*arg))
+            .and_then(|arg| from_str(arg.as_slice()))
             .unwrap_or(1000)
     };
     let mut bodies = BODIES;
index 49356e6e6458ebaf9a4444910c449ca2c28b6b96..8b522f362b33099a9670f41b7a9fa34f2cb1f148 100644 (file)
@@ -92,7 +92,7 @@ fn main() {
     let n = if args.len() < 2 {
         512
     } else {
-        FromStr::from_str(args[1]).unwrap()
+        FromStr::from_str(args[1].as_slice()).unwrap()
     };
     pidigits(n);
 }
index f5409688bc6c4e1b60afebd3363b693997863cc8..002eaf2bbf92167ea9fa9889d221e7504add4543 100644 (file)
@@ -38,7 +38,7 @@ fn main() {
     } else {
         box io::stdin() as Box<io::Reader>
     };
-    let mut seq = StrBuf::from_str(rdr.read_to_str().unwrap());
+    let mut seq = rdr.read_to_str().unwrap();
     let ilen = seq.len();
 
     seq = regex!(">[^\n]*\n|\n").replace_all(seq.as_slice(), NoExpand(""));
index 70a0e7a957c6b0aa9aa68f5c425f7eed374e7e45..c6a678828c15beea961f0b354227b3a693e5b94f 100644 (file)
@@ -100,7 +100,7 @@ fn main() {
     } else if args.len() < 2 {
         2000
     } else {
-        FromStr::from_str(args[1]).unwrap()
+        FromStr::from_str(args[1].as_slice()).unwrap()
     };
     let u = Arc::new(RWLock::new(Vec::from_elem(n, 1.)));
     let v = Arc::new(RWLock::new(Vec::from_elem(n, 1.)));
index 60485f40ba4e0f064e268b0fe8420082d8c2e151..1a6582927caf2bbc7429c0fa25c5fe276b87e233 100644 (file)
@@ -39,9 +39,11 @@ fn main() {
     let token = if std::os::getenv("RUST_BENCH").is_some() {
         2000000
     } else {
-        args.get(1).and_then(|arg| from_str(*arg)).unwrap_or(1000)
+        args.get(1).and_then(|arg| from_str(arg.as_slice())).unwrap_or(1000)
     };
-    let n_tasks = args.get(2).and_then(|arg| from_str(*arg)).unwrap_or(503);
+    let n_tasks = args.get(2)
+                      .and_then(|arg| from_str(arg.as_slice()))
+                      .unwrap_or(503);
 
     start(n_tasks, token);
 }
index ae1d9db8982bb29ad9908a7707d8018b39a07d81..3b26de9cf47be2a0a4465ddf54910aa38b6e90b8 100644 (file)
@@ -38,8 +38,8 @@ fn main() {
     } else {
         args.move_iter().collect()
     };
-    let max = from_str::<uint>(*args.get(1)).unwrap();
-    let rep = from_str::<uint>(*args.get(2)).unwrap();
+    let max = from_str::<uint>(args.get(1).as_slice()).unwrap();
+    let rep = from_str::<uint>(args.get(2).as_slice()).unwrap();
 
     let mut checkf = 0.0;
     let mut appendf = 0.0;
index 58568282e1584ab1c71d89254c1e55233f6577c6..0485e10a38bfa7e9c520c86832e745d4c3c69eed 100644 (file)
@@ -72,7 +72,10 @@ pub fn read(mut reader: BufferedReader<StdReader>) -> Sudoku {
         let mut g = Vec::from_fn(10u, { |_i| vec!(0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8) });
         for line in reader.lines() {
             let line = line.unwrap();
-            let comps: Vec<&str> = line.trim().split(',').collect();
+            let comps: Vec<&str> = line.as_slice()
+                                       .trim()
+                                       .split(',')
+                                       .collect();
 
             if comps.len() == 3u {
                 let row     = from_str::<uint>(*comps.get(0)).unwrap() as u8;
index 442386e30586eb631cff7f9a4dc925f150fd137c..1669f41374d1f952463df08979f973abdcfff048 100644 (file)
@@ -49,7 +49,7 @@ fn main() {
     };
 
     let (tx, rx) = channel();
-    child_generation(from_str::<uint>(*args.get(1)).unwrap(), tx);
+    child_generation(from_str::<uint>(args.get(1).as_slice()).unwrap(), tx);
     if rx.recv_opt().is_err() {
         fail!("it happened when we slumbered");
     }
index e64b807ca3acc436696c8e38ab8b6b812a26760f..cb5eb77df6c23838e1328f33fdf8d5c22c45e7d3 100644 (file)
@@ -31,7 +31,7 @@ fn main() {
     } else {
         args.move_iter().collect()
     };
-    let n = from_str::<uint>(*args.get(1)).unwrap();
+    let n = from_str::<uint>(args.get(1).as_slice()).unwrap();
     let mut i = 0u;
     while i < n { task::spawn(proc() f(n) ); i += 1u; }
 }
index a5168c46045805948e728e64139313070f9d5256..1e1889c7339d26ce6e430545bdf71cd5fb7987ac 100644 (file)
@@ -17,7 +17,7 @@ fn call_bare(f: fn(&str)) {
 
 fn main() {
     let string = "world!";
-    let f: |&str| = |s| println!("{}", s + string);
+    let f: |&str| = |s| println!("{}{}", s, string);
     call_bare(f)    //~ ERROR mismatched types
 }
 
index eaa1819bd53e5a4e9a6aac82a5fa311affecf6eb..ae18e9bebad599b07c45a29ba05203fca3f55af1 100644 (file)
@@ -27,6 +27,5 @@ fn main() {
 
     box 2; //~ ERROR type uses owned
     fn g(_: Box<Clone>) {} //~ ERROR type uses owned
-    "".to_owned(); //~ ERROR type uses owned
     proc() {}; //~ ERROR type uses owned
 }
index d8a6391826b48f6356e16fcc65ee3b689377e1eb..1d8c4cec655441b854bdfdf344e0951a67605967 100644 (file)
@@ -33,7 +33,7 @@ pub fn set_desc(self, s: &str) -> Flag<'a> {
 }
 
 fn main () {
-    let f : argparse::Flag = argparse::flag("flag".to_owned(), "My flag".to_owned());
-    let updated_flag = f.set_desc("My new flag".to_owned());
-    assert_eq!(updated_flag.desc, "My new flag");
+    let f : argparse::Flag = argparse::flag("flag", "My flag");
+    let updated_flag = f.set_desc("My new flag");
+    assert_eq!(updated_flag.desc.as_slice(), "My new flag");
 }
index 04239de2a83cc44e258ecd5c61221b545da3e779..cf7a5c4ad14feb4a67f935c86c130b3802a3f4c9 100644 (file)
@@ -25,7 +25,7 @@ fn f(&self, x: &'static str) {
 
 fn main() {
     let person = "Fred".to_owned();
-    let person: &str = person;  //~ ERROR `person[..]` does not live long enough
+    let person: &str = person.as_slice();  //~ ERROR `person` does not live long enough
     let s: Box<Trait<&'static str>> = box Struct { person: person };
 }
 
diff --git a/src/test/compile-fail/unsafe-modifying-str.rs b/src/test/compile-fail/unsafe-modifying-str.rs
deleted file mode 100644 (file)
index 1adf88c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
-    let mut s = "test".to_owned();
-    s[0] = 3; //~ ERROR: not allowed
-    s[0] += 3; //~ ERROR: not allowed
-    {
-        let _a = &mut s[0]; //~ ERROR: not allowed
-    }
-}
diff --git a/src/test/pretty/match-naked-expr-long.rs b/src/test/pretty/match-naked-expr-long.rs
deleted file mode 100644 (file)
index 994a81d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// pp-exact
-
-// actually this doesn't quite look how I want it to, but I can't
-// get the prettyprinter to indent the long expr
-
-fn main() {
-    let x = Some(3);
-    let _y =
-        match x {
-            Some(_) =>
-            "some".to_owned() + "very" + "very" + "very" + "very" + "very" +
-                "very" + "very" + "very" + "long" + "string",
-            None => "none".to_owned()
-        };
-}
index 9dec60e488dbff93fbb9073968612a83fde8e151..bbbe29cc1341121f229d37f1438f25de72ff7007 100644 (file)
@@ -11,5 +11,5 @@
 // error-pattern:failed at 'test-assert-owned'
 
 fn main() {
-    assert!(false, "test-assert-owned".to_owned());
+    assert!(false, "test-assert-owned".to_strbuf());
 }
index 7b5d263071b76d3bebf8f60c4e0a5a7dc2536f70..9160b760c92d60a7e46ef7f4693593914f49466b 100644 (file)
@@ -15,5 +15,5 @@
 fn main() {
     let mut a = 1;
     if 1 == 1 { a = 2; }
-    fail!("woooo".to_owned() + "o");
+    fail!(format_strbuf!("woooo{}", "o"));
 }
index b3b1fd2082b8c7006bda013489f8f20d2ec8b551..a57f4683df315c6998931257667da01ddbbc51bc 100644 (file)
@@ -19,5 +19,4 @@ fn main() {
     let y = vec!(3);
     fail!("so long");
     x.push_all_move(y);
-    "good".to_owned() + "bye".to_owned();
 }
index fae1a8a17738cd169007f86e6ebd03ac9d302526..f160b92552504d478661cc435088a76f0e948ec9 100644 (file)
@@ -22,9 +22,9 @@ fn main() {
     let mut map = collections::HashMap::new();
     let mut arr = Vec::new();
     for _i in range(0u, 10u) {
-        arr.push(@"key stuff".to_owned());
+        arr.push(@"key stuff".to_strbuf());
         map.insert(arr.clone(),
-                   arr.clone().append([@"value stuff".to_owned()]));
+                   arr.clone().append([@"value stuff".to_strbuf()]));
         if arr.len() == 5 {
             fail!();
         }
index 219eb1a3ebd459da0c14e9a4d93d91cead169934..e41c5d1b6266e5c86c4e0f9f661599f43c05a7a7 100644 (file)
@@ -57,7 +57,11 @@ fn main() {
         // rustc is passed to us with --out-dir and -L etc., so we
         // can't exec it directly
         let result = Command::new("sh")
-                             .arg("-c").arg(rustc + " " + main_file.as_str().unwrap())
+                             .arg("-c")
+                             .arg(format!("{} {}",
+                                          rustc,
+                                          main_file.as_str()
+                                                   .unwrap()).as_slice())
                              .output().unwrap();
         let err = str::from_utf8_lossy(result.error.as_slice());
 
index 2bb89d7621320c2634c276c184f5d3bebbb22ed7..854ed94e20afa0aedb8a96211bbda3b96ea8796f 100644 (file)
@@ -52,13 +52,17 @@ fn main() {
         // rustc is passed to us with --out-dir and -L etc., so we
         // can't exec it directly
         let result = Command::new("sh")
-                             .arg("-c").arg(rustc + " " + main_file.as_str().unwrap())
+                             .arg("-c")
+                             .arg(format!("{} {}",
+                                          rustc,
+                                          main_file.as_str()
+                                                   .unwrap()).as_slice())
                              .output().unwrap();
 
         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";
-        assert!(err.as_slice().contains(expected_span));
+        let expected_span = format!("^{}\n", "~".repeat(n - 1));
+        assert!(err.as_slice().contains(expected_span.as_slice()));
     }
 }
index 626f19b51085d570d6222c5216bbc24b56c2c5cf..f7b9732f12e87ce88528c9fe9f0de934a91a5851 100644 (file)
@@ -30,7 +30,6 @@ pub fn main() {
     (vec!(1)).as_slice().test_imm();
     (&[1]).test_imm();
     ("test").test_imm();
-    ("test".to_owned()).test_imm();
     ("test").test_imm();
 
     // FIXME: Other types of mutable vecs don't currently exist
index 25df896ec15a12caff393dde26a9aedb00a746a0..5e7b9d9560e381794df09e73205090b79d22cee2 100644 (file)
@@ -92,6 +92,6 @@ fn main() {
     } else if args.len() >= 2 && args[1].as_slice() == "double-fail" {
         double();
     } else {
-        runtest(args[0]);
+        runtest(args[0].as_slice());
     }
 }
index bb101140ec39351650e880b8e5b59794499e34d4..636e879fe32a8283fa414bacf1f268df7ff4badd 100644 (file)
@@ -46,6 +46,6 @@ fn main() {
         info!("info");
     });
     let s = r.read_to_str().unwrap();
-    assert!(s.contains("info"));
-    assert!(!s.contains("debug"));
+    assert!(s.as_slice().contains("info"));
+    assert!(!s.as_slice().contains("debug"));
 }
index c409852c6736cd63022a2cf9bbe2d4eb8266fede..0c372deae2c12c1e364d5f7d4adf59e3e979f03e 100644 (file)
@@ -32,7 +32,7 @@ pub fn main() {
     // expression was never evaluated, we wound up trying to clean
     // uninitialized memory.
 
-    if args.len() >= 2 && args[1] == "signal".to_owned() {
+    if args.len() >= 2 && args[1].as_slice() == "signal" {
         // Raise a segfault.
         unsafe { *(0 as *mut int) = 0; }
     }
index 99f97a41907dfb314e4952b64fcc3c5d089e387c..c94887f16a981cdba0ceaaec7f161d1c5905b0a9 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 pub fn main() {
-    assert_eq!(format!(concat!("foo", "bar", "{}"), "baz"), "foobarbaz".to_owned());
-    assert_eq!(format!(concat!()), "".to_owned());
+    assert_eq!(format!(concat!("foo", "bar", "{}"), "baz"), "foobarbaz".to_strbuf());
+    assert_eq!(format!(concat!()), "".to_strbuf());
 
     assert_eq!(
         concat!(1, 2i, 3u, 4f32, 4.0, 'a', true, ()),
index 41650b680512977c99f7c45dfaf1608558e67628..1bcc8bbc2b7c02d4fcb1ba9461ae8ce5e2220c0e 100644 (file)
@@ -41,15 +41,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 pub fn main() {
-    assert_eq!(B1.to_str(), "B1".to_owned());
-    assert_eq!(B2.to_str(), "B2".to_owned());
-    assert_eq!(C1(3).to_str(), "C1(3)".to_owned());
-    assert_eq!(C2(B2).to_str(), "C2(B2)".to_owned());
-    assert_eq!(D1{ a: 2 }.to_str(), "D1 { a: 2 }".to_owned());
-    assert_eq!(E.to_str(), "E".to_owned());
-    assert_eq!(F(3).to_str(), "F(3)".to_owned());
-    assert_eq!(G(3, 4).to_str(), "G(3, 4)".to_owned());
-    assert_eq!(G(3, 4).to_str(), "G(3, 4)".to_owned());
-    assert_eq!(I{ a: 2, b: 4 }.to_str(), "I { a: 2, b: 4 }".to_owned());
-    assert_eq!(J(Custom).to_str(), "J(yay)".to_owned());
+    assert_eq!(B1.to_str(), "B1".to_strbuf());
+    assert_eq!(B2.to_str(), "B2".to_strbuf());
+    assert_eq!(C1(3).to_str(), "C1(3)".to_strbuf());
+    assert_eq!(C2(B2).to_str(), "C2(B2)".to_strbuf());
+    assert_eq!(D1{ a: 2 }.to_str(), "D1 { a: 2 }".to_strbuf());
+    assert_eq!(E.to_str(), "E".to_strbuf());
+    assert_eq!(F(3).to_str(), "F(3)".to_strbuf());
+    assert_eq!(G(3, 4).to_str(), "G(3, 4)".to_strbuf());
+    assert_eq!(G(3, 4).to_str(), "G(3, 4)".to_strbuf());
+    assert_eq!(I{ a: 2, b: 4 }.to_str(), "I { a: 2, b: 4 }".to_strbuf());
+    assert_eq!(J(Custom).to_str(), "J(yay)".to_strbuf());
 }
index 18800ac0438fad2e17751f6054d85d97c98eddf6..7254ed7d5301a930b879faca23a4cbf8b4f7cf1f 100644 (file)
@@ -28,7 +28,7 @@ enum Enum {
 
 macro_rules! t {
     ($x:expr, $expected:expr) => {
-        assert_eq!(format!("{}", $x), $expected.to_owned())
+        assert_eq!(format!("{}", $x), $expected.to_strbuf())
     }
 }
 
index 12ed4830c82d00aacc02ceed4f9d05536c9a6b09..f028d871c20def9fa27c4522c4f1f8a00dfc3d27 100644 (file)
@@ -23,8 +23,8 @@ pub fn check() {
                 assert_eq!(size_of::<E>(), size_of::<$t>());
                 assert_eq!(V as $t, $v);
                 assert_eq!(C as $t, $v);
-                assert_eq!(format!("{:?}", V), "V".to_owned());
-                assert_eq!(format!("{:?}", C), "V".to_owned());
+                assert_eq!(format!("{:?}", V), "V".to_strbuf());
+                assert_eq!(format!("{:?}", C), "V".to_strbuf());
             }
         }
         $m::check();
index 5c71d90c159be850e368186f9416c790425fdefc..b4bd4a8201ed5729fe733bb37c851866066c0b59 100644 (file)
@@ -13,5 +13,5 @@
 use std::os;
 
 pub fn main() {
-    assert_eq!(os::getenv("TEST_EXEC_ENV"), Some("22".to_owned()));
+    assert_eq!(os::getenv("TEST_EXEC_ENV"), Some("22".to_strbuf()));
 }
index f97afa2f3e0eaf877210844afe670c1e030817b6..efe0e0de40ebc84463a91ceac589df5c28696965 100644 (file)
@@ -13,7 +13,7 @@
 use s = std::num::strconv;
 use to_str = std::num::strconv::float_to_str_common;
 
-macro_rules! t(($a:expr, $b:expr) => { { let (r, _) = $a; assert_eq!(r, $b.to_owned()) } })
+macro_rules! t(($a:expr, $b:expr) => { { let (r, _) = $a; assert_eq!(r, $b.to_strbuf()) } })
 
 pub fn main() {
     // Basic usage
index 330ba896062e210b16198be3fb19a85519884e5d..9c9f0e82d14ac7c5b6e3c436c480e02a19d5901f 100644 (file)
@@ -17,5 +17,5 @@ pub fn main() {
     let arr = [1,2,3];
     let struc = Struc {a: 13u8, b: arr, c: 42};
     let s = repr::repr_to_str(&struc);
-    assert_eq!(s, "Struc{a: 13u8, b: [1, 2, 3], c: 42}".to_owned());
+    assert_eq!(s, "Struc{a: 13u8, b: [1, 2, 3], c: 42}".to_strbuf());
 }
index c43c22d592cdc453fefe2ff88e94cff427321f69..a033fc01df389874cc249c4c7105c21dc9c7d1a3 100644 (file)
@@ -14,5 +14,5 @@ pub fn main() {
     let name = RefCell::new("rust");
     let what = RefCell::new("rocks");
     let msg = format!("{name:?} {:?}", &*what.borrow(), name=&*name.borrow());
-    assert_eq!(msg, "&\"rust\" &\"rocks\"".to_owned());
+    assert_eq!(msg, "&\"rust\" &\"rocks\"".to_strbuf());
 }
index ee142aa8e6dbcdd0240dd60c5ae71c970b1af0d5..ca2420bc573208ab0cbde52e580f6e3cb1ee4afc 100644 (file)
@@ -222,5 +222,5 @@ fn foo() -> int {
     }
     assert_eq!(format!("{} {} {a} {b} {} {c}",
                        foo(), foo(), foo(), a=foo(), b=foo(), c=foo()),
-               "1 2 4 5 3 6".to_owned());
+               "1 2 4 5 3 6".to_strbuf());
 }
index ea10bc038f072f3127249588f0d63d56c7a1fab1..044087ec0ca0ea31dc79030501c688c10dc68259 100644 (file)
@@ -22,8 +22,8 @@ fn check_strs(actual: &str, expected: &str) -> bool {
 
 pub fn main() {
     let mut table = HashMap::new();
-    table.insert("one".to_owned(), 1);
-    table.insert("two".to_owned(), 2);
-    assert!(check_strs(table.to_str(), "{one: 1, two: 2}") ||
-            check_strs(table.to_str(), "{two: 2, one: 1}"));
+    table.insert("one".to_strbuf(), 1);
+    table.insert("two".to_strbuf(), 2);
+    assert!(check_strs(table.to_str().as_slice(), "{one: 1, two: 2}") ||
+            check_strs(table.to_str().as_slice(), "{two: 2, one: 1}"));
 }
index cdc07c026772e3bcff717ea5b00572717010c227..cc63b6223981201771aeca95fd7225767dc92cf6 100644 (file)
@@ -159,7 +159,7 @@ pub fn check_strs(actual: &str, expected: &str) -> bool {
 
 fn test_ascii_art_ctor() {
     let art = AsciiArt(3, 3, '*');
-    assert!(check_strs(art.to_str(), "...\n...\n..."));
+    assert!(check_strs(art.to_str().as_slice(), "...\n...\n..."));
 }
 
 
@@ -168,7 +168,7 @@ fn test_add_pt() {
     art.add_pt(0, 0);
     art.add_pt(0, -10);
     art.add_pt(1, 2);
-    assert!(check_strs(art.to_str(), "*..\n...\n.*."));
+    assert!(check_strs(art.to_str().as_slice(), "*..\n...\n.*."));
 }
 
 
@@ -176,7 +176,7 @@ fn test_shapes() {
     let mut art = AsciiArt(4, 4, '*');
     art.add_rect(Rect {top_left: Point {x: 0, y: 0}, size: Size {width: 4, height: 4}});
     art.add_point(Point {x: 2, y: 2});
-    assert!(check_strs(art.to_str(), "****\n*..*\n*.**\n****"));
+    assert!(check_strs(art.to_str().as_slice(), "****\n*..*\n*.**\n****"));
 }
 
 pub fn main() {
index 85c56733777332630550197c01ef07b773047c1b..e31f2ade125eb08d284bb47b53152b4244089a90 100644 (file)
@@ -8,21 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![allow(unnecessary_allocation)]
-
 // rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs
 
-fn compare(x: &str, y: &str) -> bool
-{
-    match x
-    {
+fn compare(x: &str, y: &str) -> bool {
+    match x {
         "foo" => y == "foo",
         _ => y == "bar",
     }
 }
 
-pub fn main()
-{
+pub fn main() {
     assert!(compare("foo", "foo"));
-    assert!(compare("foo".to_owned(), "foo".to_owned()));
 }
index e89151fcd9dd866c72c6ca37c2d48f53ef98234d..477f3b2acafda53ee608b36574dd02c06d0e3110 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 fn f() {
-    let a = "hello".to_owned();
-    let b: &str = a;
+    let a = box 1;
+    let b: &int = a;
     println!("{}", b);
 }
 
index 70ce2b93fc90b628131e39ae6d16e766c93350fb..343780b2463822111abade6f7c5275c800707370 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let x = "hello".to_owned();
+    let x = 3u;
     let ref y = x;
-    assert_eq!(x.slice(0, x.len()), y.slice(0, y.len()));
+    assert_eq!(x, *y);
 }
index 9ae8cc893b14175077b52ed68a52ba6db89d937f..2f8f16fb1aea9ecedea6cbbfc01044aff5a45f26 100644 (file)
@@ -16,7 +16,7 @@ pub fn main() {
     assert_eq!(y, 6);
     let s = "hello there".to_owned();
     let mut i: int = 0;
-    for c in s.bytes() {
+    for c in s.as_slice().bytes() {
         if i == 0 { assert!((c == 'h' as u8)); }
         if i == 1 { assert!((c == 'e' as u8)); }
         if i == 2 { assert!((c == 'l' as u8)); }
index cf3131514db6c17c7640509047cd066842a12bec..2f2328faaca7f8f3249098860c10b16d7cb3e695 100644 (file)
@@ -10,4 +10,8 @@
 
 
 
-pub fn main() { if false { println!("{}", "foo".to_owned() + "bar"); } }
+pub fn main() {
+    if false {
+        println!("{}", "foobar");
+    }
+}
index 967ca621948a2edd240dcdfe3f207fa09a3b92a5..7a816f913350130dfc9b53efcbb023099ea5f8ba 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let thing = "{{ f }}".to_owned();
+    let thing = "{{ f }}";
     let f = thing.find_str("{{");
 
     if f.is_none() {
index 5e1f9bbaf0cfd1291cc4214ef0435f600b3f762c..cdbb1fe84dc5a22f591515feb492b8c495b7bc1c 100644 (file)
@@ -36,12 +36,13 @@ fn main() {
     let blah       = "\u03c0\u042f\u97f3\u00e6\u221e";
 
     let child_name = "child";
-    let child_dir  = "process-spawn-with-unicode-params-" + blah;
+    let child_dir  = format_strbuf!("process-spawn-with-unicode-params-{}",
+                                    blah);
 
     // parameters sent to child / expected to be received from parent
     let arg = blah;
     let cwd = my_dir.join(Path::new(child_dir.clone()));
-    let env = ("RUST_TEST_PROC_SPAWN_UNICODE".to_owned(), blah.to_owned());
+    let env = ("RUST_TEST_PROC_SPAWN_UNICODE".to_strbuf(), blah.to_strbuf());
 
     // am I the parent or the child?
     if my_args.len() == 1 {             // parent
index 4c78d9e32c21839cd0a71bd184ceaf8abf07291d..0edb0a9670ee18f5977512ce48d1bc431218d06c 100644 (file)
@@ -64,6 +64,6 @@ pub fn main() {
         // because `inner`s alignment was 4.
         assert_eq!(mem::size_of::<Outer>(), m::size());
 
-        assert_eq!(y, "Outer{c8: 22u8, t: Inner{c64: 44u32}}".to_owned());
+        assert_eq!(y, "Outer{c8: 22u8, t: Inner{c64: 44u32}}".to_strbuf());
     }
 }
index 8aa67bf2ad650473d67f3a70f36c708c0b1f223c..aeb6adddcac53241a9a050b659163fecfd2768ec 100644 (file)
@@ -86,6 +86,6 @@ pub fn main() {
         // because `Inner`s alignment was 4.
         assert_eq!(mem::size_of::<Outer>(), m::m::size());
 
-        assert_eq!(y, "Outer{c8: 22u8, t: Inner{c64: 44u64}}".to_owned());
+        assert_eq!(y, "Outer{c8: 22u8, t: Inner{c64: 44u64}}".to_strbuf());
     }
 }
diff --git a/src/test/run-pass/regions-borrow-estr-uniq.rs b/src/test/run-pass/regions-borrow-estr-uniq.rs
deleted file mode 100644 (file)
index 161e392..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn foo(x: &str) -> u8 {
-    x[0]
-}
-
-pub fn main() {
-    let p = "hello".to_owned();
-    let r = foo(p);
-    assert_eq!(r, 'h' as u8);
-
-    let p = "hello".to_owned();
-    let r = foo(p);
-    assert_eq!(r, 'h' as u8);
-}
index 01ee61e1ed54825cd4d76727cf012bbb9470c5ee..869dd3f7ff15f788ce956b1ee29f73efc737f429 100644 (file)
@@ -54,18 +54,8 @@ pub fn main() {
     assert_eq!(map.find_equiv(&("cde")), Some(&c));
     assert_eq!(map.find_equiv(&("def")), Some(&d));
 
-    assert_eq!(map.find_equiv(&("abc".to_owned())), Some(&a));
-    assert_eq!(map.find_equiv(&("bcd".to_owned())), Some(&b));
-    assert_eq!(map.find_equiv(&("cde".to_owned())), Some(&c));
-    assert_eq!(map.find_equiv(&("def".to_owned())), Some(&d));
-
     assert_eq!(map.find_equiv(&Slice("abc")), Some(&a));
     assert_eq!(map.find_equiv(&Slice("bcd")), Some(&b));
     assert_eq!(map.find_equiv(&Slice("cde")), Some(&c));
     assert_eq!(map.find_equiv(&Slice("def")), Some(&d));
-
-    assert_eq!(map.find_equiv(&Owned("abc".to_owned())), Some(&a));
-    assert_eq!(map.find_equiv(&Owned("bcd".to_owned())), Some(&b));
-    assert_eq!(map.find_equiv(&Owned("cde".to_owned())), Some(&c));
-    assert_eq!(map.find_equiv(&Owned("def".to_owned())), Some(&d));
 }
index 174a441ace57547879e1eb2a9a441cd1b7e5cfbc..1989b638680c6e6f255c68221cbb96f4c29c569d 100644 (file)
@@ -26,7 +26,7 @@
 pub fn main() {
     let args = os::args();
     let args = args.as_slice();
-    if args.len() >= 2 && args[1] == "signal".to_owned() {
+    if args.len() >= 2 && args[1].as_slice() == "signal" {
         // Raise a segfault.
         unsafe { *(0 as *mut int) = 0; }
     } else {
index 7597b02e31b2e11b6020c7087ef40bb763363344..d65eb6415bfc09b50789233410fb51a4fc0d618c 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn main() {
     let s = "hello".to_owned();
-    let c: u8 = s[4];
+    let c: u8 = s.as_slice()[4];
     println!("{:?}", c);
     assert_eq!(c, 0x6f as u8);
 }
index 1204efc29ebd39344ebf1bc758174f627ffc1968..26cc43bcfa0baaccc49821f2569ca0c8545c2ab2 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// exec-env:RUST_MIN_STACK=8000000
+// exec-env:RUST_MIN_STACK=16000000
 //
 // Big stack is needed for pretty printing, a little sad...
 
index 017b17d0e9c2f6ca3fe7c653a12e321df3f04bee..9f58cbbff203aded8c9e54cf56aec599b00beaa6 100644 (file)
 
 pub mod m1 {
     pub mod m2 {
-        pub fn where_am_i() -> StrBuf { (module_path!()).to_strbuf() }
+        pub fn where_am_i() -> StrBuf {
+            (module_path!()).to_strbuf()
+        }
     }
 }
 
 macro_rules! indirect_line( () => ( line!() ) )
 
 pub fn main() {
-    assert_eq!(line!(), 25);
+    assert_eq!(line!(), 27);
     //assert!((col!() == 11));
-    assert_eq!(indirect_line!(), 27);
-    assert!((file!().to_owned().ends_with("syntax-extension-source-utils.rs")));
+    assert_eq!(indirect_line!(), 29);
+    assert!((file!().ends_with("syntax-extension-source-utils.rs")));
     assert_eq!(stringify!((2*3) + 5).to_strbuf(), "( 2 * 3 ) + 5".to_strbuf());
     assert!(include!("syntax-extension-source-utils-files/includeme.\
                       fragment").to_strbuf()
index 4f079da2ff3f397980cf2ba2cc5903640b744db4..700cfacb856042f7f77ec2faacd4a864f16feb03 100644 (file)
@@ -22,5 +22,5 @@ pub fn main() {
     let x = t_rec {c8: 22u8, t: a_tag(44u64)};
     let y = format!("{:?}", x);
     println!("y = {}", y);
-    assert_eq!(y, "t_rec{c8: 22u8, t: a_tag(44u64)}".to_owned());
+    assert_eq!(y, "t_rec{c8: 22u8, t: a_tag(44u64)}".to_strbuf());
 }
index 8c09ba6ba6a65555aa4de500b4ff8914ae1a7d65..a795881cd6de24f73a3ee94adeced0bba3ef5941 100644 (file)
@@ -19,7 +19,7 @@ enum color {
 pub fn main() {
     let act = format!("{:?}", red);
     println!("{}", act);
-    assert_eq!("red".to_owned(), act);
-    assert_eq!("green".to_owned(), format!("{:?}", green));
-    assert_eq!("white".to_owned(), format!("{:?}", white));
+    assert_eq!("red".to_strbuf(), act);
+    assert_eq!("green".to_strbuf(), format!("{:?}", green));
+    assert_eq!("white".to_strbuf(), format!("{:?}", white));
 }
index 47f21a0c60c8fff99d5640197bb672bd9f5ba0f0..963121fff82280da696a085f460765f89118b983 100644 (file)
@@ -39,10 +39,10 @@ fn test_str() {
     let s0 = "test".to_owned();
     tx.send(s0);
     let s1 = rx.recv();
-    assert_eq!(s1[0], 't' as u8);
-    assert_eq!(s1[1], 'e' as u8);
-    assert_eq!(s1[2], 's' as u8);
-    assert_eq!(s1[3], 't' as u8);
+    assert_eq!(s1.as_slice()[0], 't' as u8);
+    assert_eq!(s1.as_slice()[1], 'e' as u8);
+    assert_eq!(s1.as_slice()[2], 's' as u8);
+    assert_eq!(s1.as_slice()[3], 't' as u8);
 }
 
 #[deriving(Show)]
index 5612c50142cafa045087fd00e075e8774b7ba0fe..6116ed29e1aa89fca8eca361d971de52dcd68d04 100644 (file)
@@ -63,7 +63,7 @@ fn f() $b
     let (tx1, rx1) = channel();
     let (_tx2, rx2) = channel::<()>();
     native::task::spawn(proc() {
-        let _l = TcpListener::bind(host, port).unwrap().listen();
+        let _l = TcpListener::bind(host.as_slice(), port).unwrap().listen();
         tx1.send(());
         let _ = rx2.recv_opt();
     });
@@ -84,7 +84,7 @@ fn f() $b
     let addr = next_test_ip4();
     let host = addr.ip.to_str();
     let port = addr.port;
-    let _l = TcpListener::bind(host, port).unwrap().listen();
+    let _l = TcpListener::bind(host.as_slice(), port).unwrap().listen();
 
     assert!(TcpStream::connect_timeout(addr, 1000).is_ok());
 })
index f1a609b258498351fe1f7b3a8accbcb4121af889..799d07891db0cfff2e367fd4258e74fc870bb7a8 100644 (file)
@@ -64,7 +64,7 @@ fn main() {
         builder.spawn(proc() {
             let host = addr.ip.to_str();
             let port = addr.port;
-            match TcpStream::connect(host, port) {
+            match TcpStream::connect(host.as_slice(), port) {
                 Ok(stream) => {
                     let mut stream = stream;
                     stream.write([1]);
index 309325ab7db4a1fca09d2efbc931833e2f8a8124..c3387a963a701d44c8e4d1f84f80394ac8160327 100644 (file)
@@ -27,10 +27,10 @@ fn checktests() {
     let tests = __test::TESTS;
 
     assert!(
-        tests.iter().any(|t| t.desc.name.to_str() == "shouldignore".to_owned() &&
+        tests.iter().any(|t| t.desc.name.to_str().as_slice() == "shouldignore" &&
                          t.desc.ignore));
 
     assert!(
-        tests.iter().any(|t| t.desc.name.to_str() == "shouldnotignore".to_owned() &&
+        tests.iter().any(|t| t.desc.name.to_str().as_slice() == "shouldnotignore" &&
                          !t.desc.ignore));
 }
index 2ec7cac7508936b355a71bd4781dc61d0e0bbd21..190007a7811646c32f49ed41d0393f9395ad94ea 100644 (file)
@@ -9,12 +9,12 @@
 // except according to those terms.
 
 pub fn main() {
-    assert_eq!((vec!(0, 1)).to_str(), "[0, 1]".to_owned());
-    assert_eq!((&[1, 2]).to_str(), "[1, 2]".to_owned());
+    assert_eq!((vec!(0, 1)).to_str(), "[0, 1]".to_strbuf());
+    assert_eq!((&[1, 2]).to_str(), "[1, 2]".to_strbuf());
 
     let foo = vec!(3, 4);
     let bar = &[4, 5];
 
-    assert_eq!(foo.to_str(), "[3, 4]".to_owned());
-    assert_eq!(bar.to_str(), "[4, 5]".to_owned());
+    assert_eq!(foo.to_str(), "[3, 4]".to_strbuf());
+    assert_eq!(bar.to_str(), "[4, 5]".to_strbuf());
 }