]> git.lizzy.rs Git - rust.git/commitdiff
librustc: Remove the broken overloaded assign-ops from the language.
authorPatrick Walton <pcwalton@mimiga.net>
Wed, 12 Jun 2013 02:13:42 +0000 (19:13 -0700)
committerCorey Richardson <corey@octayn.net>
Fri, 28 Jun 2013 14:44:16 +0000 (10:44 -0400)
They evaluated the receiver twice. They should be added back with
`AddAssign`, `SubAssign`, etc., traits.

57 files changed:
doc/tutorial.md
src/compiletest/errors.rs
src/compiletest/runtest.rs
src/libextra/arena.rs
src/libextra/bitv.rs
src/libextra/getopts.rs
src/libextra/json.rs
src/libextra/md4.rs
src/libextra/net_url.rs
src/libextra/num/bigint.rs
src/libextra/time.rs
src/librustc/back/link.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/tydecode.rs
src/librustc/middle/resolve.rs
src/librustc/middle/trans/asm.rs
src/librustc/middle/trans/build.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/mod.rs
src/librustdoc/markdown_pass.rs
src/librustdoc/markdown_writer.rs
src/librustdoc/page_pass.rs
src/librusti/rusti.rs
src/libstd/hash.rs
src/libstd/num/num.rs
src/libstd/path.rs
src/libsyntax/diagnostic.rs
src/libsyntax/ext/concat_idents.rs
src/libsyntax/ext/pipes/pipec.rs
src/libsyntax/parse/attr.rs
src/libsyntax/parse/comments.rs
src/libsyntax/parse/common.rs
src/libsyntax/parse/lexer.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/libsyntax/print/pp.rs
src/test/bench/core-std.rs
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/sudoku.rs
src/test/compile-fail/issue-2149.rs
src/test/run-fail/issue-3029.rs
src/test/run-pass/istr.rs
src/test/run-pass/liveness-move-in-loop.rs
src/test/run-pass/match-join.rs
src/test/run-pass/monad.rs
src/test/run-pass/mutable-alias-vec.rs
src/test/run-pass/operator-overloading.rs
src/test/run-pass/shadow.rs
src/test/run-pass/static-impl.rs
src/test/run-pass/str-append.rs
src/test/run-pass/str-growth.rs
src/test/run-pass/trait-generic.rs
src/test/run-pass/vec-growth.rs
src/test/run-pass/while-prelude-drop.rs

index fc0f7b74a7af87e44b23020de53bada9fb3da741..aa6e90826bbbf5d902eeb4cbd0477244abb1bbcd 100644 (file)
@@ -1281,9 +1281,9 @@ let your_crayons = ~[BananaMania, Beaver, Bittersweet];
 // Add two vectors to create a new one
 let our_crayons = my_crayons + your_crayons;
 
-// += will append to a vector, provided it lives in a mutable slot
+// .push_all() will append to a vector, provided it lives in a mutable slot
 let mut my_crayons = my_crayons;
-my_crayons += your_crayons;
+my_crayons.push_all(your_crayons);
 ~~~~
 
 > ***Note:*** The above examples of vector addition use owned
index cdc0defcbcab08c3bd9ffb00f857cb628be6c4bc..4649d4dfc3c4b913f1f7f38f5cea63e82bd0a8db 100644 (file)
@@ -21,7 +21,7 @@ pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
     let mut line_num = 1u;
     while !rdr.eof() {
         let ln = rdr.read_line();
-        error_patterns += parse_expected(line_num, ln);
+        error_patterns.push_all_move(parse_expected(line_num, ln));
         line_num += 1u;
     }
     return error_patterns;
index a31e0b961f7f2bad7e72b9a740ca620ebe6ba9f9..0e04be34c795a7a4ac32e854b8be5a2bb53fd36c 100644 (file)
@@ -226,8 +226,8 @@ fn make_typecheck_args(config: &config, props: &TestProps, testfile: &Path) -> P
                          ~"-L", config.build_base.to_str(),
                          ~"-L",
                          aux_output_dir_name(config, testfile).to_str()];
-        args += split_maybe_args(&config.rustcflags);
-        args += split_maybe_args(&props.compile_flags);
+        args.push_all_move(split_maybe_args(&config.rustcflags));
+        args.push_all_move(split_maybe_args(&props.compile_flags));
         return ProcArgs {prog: config.rustc_path.to_str(), args: args};
     }
 }
@@ -581,8 +581,8 @@ fn make_compile_args(config: &config, props: &TestProps, extras: ~[~str],
                      ~"-o", xform(config, testfile).to_str(),
                      ~"-L", config.build_base.to_str()]
         + extras;
-    args += split_maybe_args(&config.rustcflags);
-    args += split_maybe_args(&props.compile_flags);
+    args.push_all_move(split_maybe_args(&config.rustcflags));
+    args.push_all_move(split_maybe_args(&props.compile_flags));
     return ProcArgs {prog: config.rustc_path.to_str(), args: args};
 }
 
index 604d9ba73732ae6448b36a12649c47c7ed4260c8..79e09c32030b3ffc004ed16fb0a9b57c9efabf57 100644 (file)
@@ -186,20 +186,18 @@ fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
     #[inline]
     fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
         unsafe {
-            // XXX: Borrow check
-            let head = transmute_mut_region(&mut self.pod_head);
-
-            let start = round_up_to(head.fill, align);
+            let this = transmute_mut_region(self);
+            let start = round_up_to(this.pod_head.fill, align);
             let end = start + n_bytes;
-            if end > at_vec::capacity(head.data) {
-                return self.alloc_pod_grow(n_bytes, align);
+            if end > at_vec::capacity(this.pod_head.data) {
+                return this.alloc_pod_grow(n_bytes, align);
             }
-            head.fill = end;
+            this.pod_head.fill = end;
 
             //debug!("idx = %u, size = %u, align = %u, fill = %u",
             //       start, n_bytes, align, head.fill);
 
-            ptr::offset(vec::raw::to_ptr(head.data), start)
+            ptr::offset(vec::raw::to_ptr(this.pod_head.data), start)
         }
     }
 
@@ -237,7 +235,7 @@ fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
             let after_tydesc = head.fill + sys::size_of::<*TyDesc>();
             let start = round_up_to(after_tydesc, align);
             let end = start + n_bytes;
-            if end > at_vec::capacity(head.data) {
+            if end > at_vec::capacity(self.head.data) {
                 return self.alloc_nonpod_grow(n_bytes, align);
             }
             head.fill = round_up_to(end, sys::pref_align_of::<*TyDesc>());
@@ -245,7 +243,7 @@ fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
             //debug!("idx = %u, size = %u, align = %u, fill = %u",
             //       start, n_bytes, align, head.fill);
 
-            let buf = vec::raw::to_ptr(head.data);
+            let buf = vec::raw::to_ptr(self.head.data);
             return (ptr::offset(buf, tydesc_start), ptr::offset(buf, start));
         }
     }
index 6e4507d4277ab9444a02af464b66c60a8eba7123..4fe7761bf18da24bcdd50c89ab057a093e6036db 100644 (file)
@@ -476,9 +476,15 @@ pub fn to_bools(&self) -> ~[bool] {
      * character is either '0' or '1'.
      */
      pub fn to_str(&self) -> ~str {
-       let mut rs = ~"";
-       for self.each() |i| { if i { rs += "1"; } else { rs += "0"; } };
-       rs
+        let mut rs = ~"";
+        for self.each() |i| {
+            if i {
+                rs.push_char('1');
+            } else {
+                rs.push_char('0');
+            }
+        };
+        rs
      }
 
 
index 9c416550eb787be896de787f23370c7af21577fc..fa064e6330e7b4dd3d9bad6a30c34df3300123b3 100644 (file)
@@ -606,33 +606,47 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str {
             let mut row = " ".repeat(4);
 
             // short option
-            row += match short_name.len() {
-                0 => ~"",
-                1 => ~"-" + short_name + " ",
+            match short_name.len() {
+                0 => {}
+                1 => {
+                    row.push_char('-');
+                    row.push_str(short_name);
+                    row.push_char(' ');
+                }
                 _ => fail!("the short name should only be 1 ascii char long"),
-            };
+            }
 
             // long option
-            row += match long_name.len() {
-                0 => ~"",
-                _ => ~"--" + long_name + " ",
-            };
+            match long_name.len() {
+                0 => {}
+                _ => {
+                    row.push_str("--");
+                    row.push_str(long_name);
+                    row.push_char(' ');
+                }
+            }
 
             // arg
-            row += match hasarg {
-                No    => ~"",
-                Yes   => hint,
-                Maybe => ~"[" + hint + "]",
-            };
+            match hasarg {
+                No => {}
+                Yes => row.push_str(hint),
+                Maybe => {
+                    row.push_char('[');
+                    row.push_str(hint);
+                    row.push_char(']');
+                }
+            }
 
             // FIXME: #5516
             // here we just need to indent the start of the description
             let rowlen = row.len();
-            row += if rowlen < 24 {
-                " ".repeat(24 - rowlen)
+            if rowlen < 24 {
+                for (24 - rowlen).times {
+                    row.push_char(' ')
+                }
             } else {
-                copy desc_sep
-            };
+                row.push_str(desc_sep)
+            }
 
             // Normalize desc to contain words separated by one space character
             let mut desc_normalized_whitespace = ~"";
@@ -649,7 +663,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str {
 
             // FIXME: #5516
             // wrapped description
-            row += desc_rows.connect(desc_sep);
+            row.push_str(desc_rows.connect(desc_sep));
 
             row
         });
index 15553b035f65e7dadcae1c5c464b7992c15874cb..a71be18174ab872a9457ecbbe98794798dbea82d 100644 (file)
@@ -60,25 +60,27 @@ fn escape_str(s: &str) -> ~str {
     let mut escaped = ~"\"";
     for s.iter().advance |c| {
         match c {
-          '"' => escaped += "\\\"",
-          '\\' => escaped += "\\\\",
-          '\x08' => escaped += "\\b",
-          '\x0c' => escaped += "\\f",
-          '\n' => escaped += "\\n",
-          '\r' => escaped += "\\r",
-          '\t' => escaped += "\\t",
-          _ => escaped += str::from_char(c)
+          '"' => escaped.push_str("\\\""),
+          '\\' => escaped.push_str("\\\\"),
+          '\x08' => escaped.push_str("\\b"),
+          '\x0c' => escaped.push_str("\\f"),
+          '\n' => escaped.push_str("\\n"),
+          '\r' => escaped.push_str("\\r"),
+          '\t' => escaped.push_str("\\t"),
+          _ => escaped.push_char(c),
         }
     };
 
-    escaped += "\"";
+    escaped.push_char('"');
 
     escaped
 }
 
 fn spaces(n: uint) -> ~str {
     let mut ss = ~"";
-    for n.times { ss.push_str(" "); }
+    for n.times {
+        ss.push_str(" ");
+    }
     return ss;
 }
 
index 2534fedd9611fb099243dcd02e90f39466f4199b..3be7394b46d0bd275fdb31273d5fa971e653ec0b 100644 (file)
@@ -119,8 +119,10 @@ fn app(a: u32, b: u32, c: u32, d: u32, f: &fn(u32)) {
         let mut i = 0u32;
         while i < 4u32 {
             let byte = (u >> (i * 8u32)) as u8;
-            if byte <= 16u8 { result += "0"; }
-            result += uint::to_str_radix(byte as uint, 16u);
+            if byte <= 16u8 {
+                result.push_char('0')
+            }
+            result.push_str(uint::to_str_radix(byte as uint, 16u));
             i += 1u32;
         }
     }
index f9eaa2bf02ddff8534a28513fe83a0af9e87837e..a60f51e751e1c4cd73eafe6a391717f44d460b21 100644 (file)
@@ -93,10 +93,10 @@ fn encode_inner(s: &str, full_url: bool) -> ~str {
                         out.push_char(ch);
                       }
 
-                      _ => out += fmt!("%%%X", ch as uint)
+                      _ => out.push_str(fmt!("%%%X", ch as uint))
                     }
                 } else {
-                    out += fmt!("%%%X", ch as uint);
+                    out.push_str(fmt!("%%%X", ch as uint));
                 }
               }
             }
@@ -192,7 +192,7 @@ fn encode_plus(s: &str) -> ~str {
                 out.push_char(ch);
               }
               ' ' => out.push_char('+'),
-              _ => out += fmt!("%%%X", ch as uint)
+              _ => out.push_str(fmt!("%%%X", ch as uint))
             }
         }
 
@@ -218,7 +218,7 @@ pub fn encode_form_urlencoded(m: &HashMap<~str, ~[~str]>) -> ~str {
                 first = false;
             }
 
-            out += fmt!("%s=%s", key, encode_plus(*value));
+            out.push_str(fmt!("%s=%s", key, encode_plus(*value)));
         }
     }
 
index c2702ac70b133c9c5236c823cb71a9a059251632..b0fa715fdd81a65622255bd711bb23901f47bc55 100644 (file)
@@ -510,11 +510,11 @@ fn convert_base(n: BigUint, base: uint) -> ~[BigDigit] {
             let mut m      = n;
             while m > divider {
                 let (d, m0) = m.div_mod_floor(&divider);
-                result += [m0.to_uint() as BigDigit];
+                result.push(m0.to_uint() as BigDigit);
                 m = d;
             }
             if !m.is_zero() {
-                result += [m.to_uint() as BigDigit];
+                result.push(m.to_uint() as BigDigit);
             }
             return result;
         }
index 555563a0cd7e33c4b6ebf9c1a39f612a7c6aaa74..931a42d3c5377f2f196aeddbbb0976460c41a8a2 100644 (file)
@@ -849,7 +849,7 @@ fn parse_type(ch: char, tm: &Tm) -> ~str {
     do io::with_str_reader(format) |rdr| {
         while !rdr.eof() {
             match rdr.read_char() {
-                '%' => buf += parse_type(rdr.read_char(), tm),
+                '%' => buf.push_str(parse_type(rdr.read_char(), tm)),
                 ch => buf.push_char(ch)
             }
         }
index 55d0219a78716adfa9bc9a06d47eefa5b6705c3a..af23696cbc1a6b882e0172d49bd8164eba8adce0 100644 (file)
@@ -642,15 +642,15 @@ pub fn sanitize(s: &str) -> ~str {
     for s.iter().advance |c| {
         match c {
             // Escape these with $ sequences
-            '@' => result += "$SP$",
-            '~' => result += "$UP$",
-            '*' => result += "$RP$",
-            '&' => result += "$BP$",
-            '<' => result += "$LT$",
-            '>' => result += "$GT$",
-            '(' => result += "$LP$",
-            ')' => result += "$RP$",
-            ',' => result += "$C$",
+            '@' => result.push_str("$SP$"),
+            '~' => result.push_str("$UP$"),
+            '*' => result.push_str("$RP$"),
+            '&' => result.push_str("$BP$"),
+            '<' => result.push_str("$LT$"),
+            '>' => result.push_str("$GT$"),
+            '(' => result.push_str("$LP$"),
+            ')' => result.push_str("$RP$"),
+            ',' => result.push_str("$C$"),
 
             // '.' doesn't occur in types and functions, so reuse it
             // for ':'
@@ -686,12 +686,14 @@ pub fn mangle(sess: Session, ss: path) -> ~str {
     let mut n = ~"_ZN"; // Begin name-sequence.
 
     for ss.iter().advance |s| {
-        match *s { path_name(s) | path_mod(s) => {
-          let sani = sanitize(sess.str_of(s));
-          n += fmt!("%u%s", sani.len(), sani);
-        } }
+        match *s {
+            path_name(s) | path_mod(s) => {
+                let sani = sanitize(sess.str_of(s));
+                n.push_str(fmt!("%u%s", sani.len(), sani));
+            }
+        }
     }
-    n += "E"; // End name-sequence.
+    n.push_char('E'); // End name-sequence.
     n
 }
 
index b96e96c9618fb07be9c75a270b59ee003f565246..f8ecef3b4a49c64384f0af52f1f484e54fa70dcb 100644 (file)
@@ -979,7 +979,7 @@ fn add_to_index_(item: @item, ebml_w: &writer::Encoder,
 
         // >:-<
         let mut impl_path = vec::append(~[], path);
-        impl_path += [ast_map::path_name(item.ident)];
+        impl_path.push(ast_map::path_name(item.ident));
 
         for methods.iter().advance |m| {
             index.push(entry {val: m.id, pos: ebml_w.writer.tell()});
index 1507fc186e7a5615e9eb032ae927974f4e04ed78..1ec5c983f624819bc697666cf6c21de838317ae8 100644 (file)
@@ -261,7 +261,9 @@ fn parse_opt<T>(st: &mut PState, f: &fn(&mut PState) -> T) -> Option<T> {
 fn parse_str(st: &mut PState, term: char) -> ~str {
     let mut result = ~"";
     while peek(st) != term {
-        result += str::from_byte(next_byte(st));
+        unsafe {
+            str::raw::push_byte(&mut result, next_byte(st));
+        }
     }
     next(st);
     return result;
index b839e22f9060f53a3cd976d8b9778f6fdc288012..bf37ce676a817f75f36360aa1497cb99f72588cb 100644 (file)
@@ -2091,8 +2091,12 @@ pub fn idents_to_str(@mut self, idents: &[ident]) -> ~str {
         let mut first = true;
         let mut result = ~"";
         for idents.iter().advance |ident| {
-            if first { first = false; } else { result += "::" };
-            result += self.session.str_of(*ident);
+            if first {
+                first = false
+            } else {
+                result.push_str("::")
+            }
+            result.push_str(*self.session.str_of(*ident));
         };
         return result;
     }
index 7d0defde4354fbfe8c89b3c099dc2dbfb6d59caf..b208592d113f383e0726ee084a045d10667c30d9 100644 (file)
@@ -98,15 +98,15 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
     if !ia.clobbers.is_empty() && !clobbers.is_empty() {
         clobbers = fmt!("%s,%s", ia.clobbers, clobbers);
     } else {
-        clobbers += ia.clobbers;
+        clobbers.push_str(*ia.clobbers);
     };
 
     // Add the clobbers to our constraints list
-    if !clobbers.is_empty() && !constraints.is_empty() {
-        constraints += ",";
-        constraints += clobbers;
+    if clobbers.len() != 0 && constraints.len() != 0 {
+        constraints.push_char(',');
+        constraints.push_str(clobbers);
     } else {
-        constraints += clobbers;
+        constraints.push_str(clobbers);
     }
 
     debug!("Asm Constraints: %?", constraints);
index a90089bb47035f23c61750ea575bca45b8630ff9..e48a98cd90c0fc50978fd0bdf540013fe00e5e1e 100644 (file)
@@ -68,13 +68,13 @@ pub fn count_insn(cx: block, category: &str) {
         i = 0u;
         while i < len {
             i = *mm.get(&v[i]);
-            s += "/";
-            s += v[i];
+            s.push_char('/');
+            s.push_str(v[i]);
             i += 1u;
         }
 
-        s += "/";
-        s += category;
+        s.push_char('/');
+        s.push_str(category);
 
         let n = match h.find(&s) {
           Some(&n) => n,
index 67ca647862baece7550346a6a42943022febfa16..4e3583a4095add2240b345bd1059c80ba1f79fd3 100644 (file)
@@ -964,9 +964,12 @@ pub fn path_str(sess: session::Session, p: &[path_elt]) -> ~str {
     for p.iter().advance |e| {
         match *e {
             ast_map::path_name(s) | ast_map::path_mod(s) => {
-                if first { first = false; }
-                else { r += "::"; }
-                r += sess.str_of(s);
+                if first {
+                    first = false
+                } else {
+                    r.push_str("::")
+                }
+                r.push_str(*sess.str_of(s));
             }
         }
     }
index 81a1ef6563f47916c7a2d8eca44fb5e1e2857394..212f78c47568047bf35b7671b39126224b000c0d 100644 (file)
@@ -2120,7 +2120,7 @@ fn tc_ty(cx: ctxt,
                     TC_NONE,
                     |tc, f| tc + tc_mt(cx, f.mt, cache));
                 if ty::has_dtor(cx, did) {
-                    res += TC_DTOR;
+                    res = res + TC_DTOR;
                 }
                 apply_tc_attr(cx, did, res)
             }
@@ -2205,10 +2205,10 @@ fn tc_mt(cx: ctxt,
 
     fn apply_tc_attr(cx: ctxt, did: def_id, mut tc: TypeContents) -> TypeContents {
         if has_attr(cx, did, "mutable") {
-            tc += TC_MUTABLE;
+            tc = tc + TC_MUTABLE;
         }
         if has_attr(cx, did, "non_sendable") {
-            tc += TC_NON_SENDABLE;
+            tc = tc + TC_NON_SENDABLE;
         }
         tc
     }
index 97e0cd4baf84449bd33e4be7e876795eca1a614d..1da76644244fad58e25a6be21d587fb8e8f1f70d 100644 (file)
@@ -213,6 +213,13 @@ pub fn recurse(&mut self, blk: &ast::blk) -> PurityState {
     }
 }
 
+/// Whether `check_binop` allows overloaded operators to be invoked.
+#[deriving(Eq)]
+enum AllowOverloadedOperatorsFlag {
+    AllowOverloadedOperators,
+    DontAllowOverloadedOperators,
+}
+
 pub struct FnCtxt {
     // Number of errors that had been reported when we started
     // checking this function. On exit, if we find that *more* errors
@@ -1487,7 +1494,8 @@ fn check_binop(fcx: @mut FnCtxt,
                    lhs: @ast::expr,
                    rhs: @ast::expr,
                    // Used only in the error case
-                   expected_result: Option<ty::t>
+                   expected_result: Option<ty::t>,
+                   allow_overloaded_operators: AllowOverloadedOperatorsFlag
                   ) {
         let tcx = fcx.ccx.tcx;
 
@@ -1537,8 +1545,30 @@ fn check_binop(fcx: @mut FnCtxt,
 
         }
 
-        let result_t = check_user_binop(fcx, callee_id, expr, lhs, lhs_t, op, rhs,
-                                       expected_result);
+        // Check for overloaded operators if allowed.
+        let result_t;
+        if allow_overloaded_operators == AllowOverloadedOperators {
+            result_t = check_user_binop(fcx,
+                                        callee_id,
+                                        expr,
+                                        lhs,
+                                        lhs_t,
+                                        op,
+                                        rhs,
+                                        expected_result);
+        } else {
+            fcx.type_error_message(expr.span,
+                                   |actual| {
+                                        fmt!("binary operation %s cannot be \
+                                              applied to type `%s`",
+                                             ast_util::binop_to_str(op),
+                                             actual)
+                                   },
+                                   lhs_t,
+                                   None);
+            result_t = ty::mk_err();
+        }
+
         fcx.write_ty(expr.id, result_t);
         if ty::type_is_error(result_t) {
             fcx.write_ty(rhs.id, result_t);
@@ -2229,7 +2259,15 @@ fn check_loop_body(fcx: @mut FnCtxt,
         fcx.write_ty(id, typ);
       }
       ast::expr_binary(callee_id, op, lhs, rhs) => {
-        check_binop(fcx, callee_id, expr, op, lhs, rhs, expected);
+        check_binop(fcx,
+                    callee_id,
+                    expr,
+                    op,
+                    lhs,
+                    rhs,
+                    expected,
+                    AllowOverloadedOperators);
+
         let lhs_ty = fcx.expr_ty(lhs);
         let rhs_ty = fcx.expr_ty(rhs);
         if ty::type_is_error(lhs_ty) ||
@@ -2242,7 +2280,15 @@ fn check_loop_body(fcx: @mut FnCtxt,
         }
       }
       ast::expr_assign_op(callee_id, op, lhs, rhs) => {
-        check_binop(fcx, callee_id, expr, op, lhs, rhs, expected);
+        check_binop(fcx,
+                    callee_id,
+                    expr,
+                    op,
+                    lhs,
+                    rhs,
+                    expected,
+                    DontAllowOverloadedOperators);
+
         let lhs_t = fcx.expr_ty(lhs);
         let result_t = fcx.expr_ty(expr);
         demand::suptype(fcx, expr.span, result_t, lhs_t);
index ca167c3726ae23c89044b7d3509336b0c0bb4e58..e9deef6b22364b613ac6ed77610bebac94e3d601 100644 (file)
@@ -192,11 +192,11 @@ pub fn header_name(doc: doc::ItemTag) -> ~str {
             let mut trait_part = ~"";
             for doc.trait_types.iter().enumerate().advance |(i, trait_type)| {
                 if i == 0 {
-                    trait_part += " of ";
+                    trait_part.push_str(" of ");
                 } else {
-                    trait_part += ", ";
+                    trait_part.push_str(", ");
                 }
-                trait_part += *trait_type;
+                trait_part.push_str(*trait_type);
             }
             fmt!("%s for %s%s", trait_part, *self_ty, bounds)
         }
index 353152763267cc5ece79a75071620145ac27307e..a093824e453bff8b9c5f73b759a8be9e0799e11f 100644 (file)
@@ -130,7 +130,7 @@ fn generic_writer(process: ~fn(markdown: ~str)) -> Writer {
         let mut keep_going = true;
         while keep_going {
             match po.recv() {
-              Write(s) => markdown += s,
+              Write(s) => markdown.push_str(s),
               Done => keep_going = false
             }
         }
@@ -214,7 +214,7 @@ fn future_writer() -> (Writer, future::Future<~str>) {
         let mut res = ~"";
         loop {
             match port.recv() {
-              Write(s) => res += s,
+              Write(s) => res.push_str(s),
               Done => break
             }
         }
index 584e6ccc887301a3e2176cfbd0817ed170182965..35a433ec9dedd84e5edba12de3013af92e3c0334 100644 (file)
@@ -70,7 +70,7 @@ fn make_doc_from_pages(page_port: &PagePort) -> doc::Doc {
     loop {
         let val = page_port.recv();
         if val.is_some() {
-            pages += [val.unwrap()];
+            pages.push(val.unwrap());
         } else {
             break;
         }
index a586cb83fa180056dace49f4b70f3d4d94707ffa..abb0cf271ec464981212fc11eac42d4d8bc9777d 100644 (file)
@@ -402,7 +402,8 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
                         if line.trim() == ":}" {
                             end_multiline = true;
                         } else {
-                            multiline_cmd += line + "\n";
+                            multiline_cmd.push_str(line);
+                            multiline_cmd.push_char('\n');
                         }
                     }
                 }
index 8e88bfb463291f493c73ad4d16462032317a9eea..6c3fcd41ed3b9d6fb1b698f95faee702332efa27 100644 (file)
@@ -24,6 +24,7 @@
 use container::Container;
 use iterator::IteratorUtil;
 use rt::io::Writer;
+use str::OwnedStr;
 use to_bytes::IterBytes;
 use uint;
 use vec::ImmutableVector;
@@ -369,7 +370,7 @@ fn result_str(&mut self) -> ~str {
         let r = self.result_bytes();
         let mut s = ~"";
         for r.iter().advance |b| {
-            s += uint::to_str_radix(*b as uint, 16u);
+            s.push_str(uint::to_str_radix(*b as uint, 16u));
         }
         s
     }
@@ -471,7 +472,7 @@ fn test_siphash() {
         fn to_hex_str(r: &[u8, ..8]) -> ~str {
             let mut s = ~"";
             for r.iter().advance |b| {
-                s += uint::to_str_radix(*b as uint, 16u);
+                s.push_str(uint::to_str_radix(*b as uint, 16u));
             }
             s
         }
@@ -492,7 +493,7 @@ fn to_hex_str(r: &[u8, ..8]) -> ~str {
 
             assert!(f == i && f == v);
 
-            buf += [t as u8];
+            buf.push(t as u8);
             stream_inc.input([t as u8]);
 
             t += 1;
index 30a18a0587bc025781b86a519f5f51b591e25f05..b856c3c65ea5aa04e829815a93be8d00e57d6654 100644 (file)
@@ -412,7 +412,7 @@ pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(radix: uint, pow
         if my_pow % 2u == 1u {
             total = total * multiplier;
         }
-        my_pow     = my_pow / 2u;
+        my_pow = my_pow / 2u;
         multiplier = multiplier * multiplier;
     }
     total
index 897926940116f33dbe76c032f9884740f45df093..6059ba5cbddd92ce4475424bde80f8f198746984 100644 (file)
@@ -21,8 +21,8 @@
 use iterator::IteratorUtil;
 use libc;
 use option::{None, Option, Some};
-use str;
 use str::{Str, StrSlice, StrVector};
+use str;
 use to_str::ToStr;
 use ascii::{AsciiCast, AsciiStr};
 use vec::{OwnedVector, ImmutableVector};
@@ -476,7 +476,7 @@ impl ToStr for PosixPath {
     fn to_str(&self) -> ~str {
         let mut s = ~"";
         if self.is_absolute {
-            s += "/";
+            s.push_str("/");
         }
         s + self.components.connect("/")
     }
@@ -655,15 +655,21 @@ impl ToStr for WindowsPath {
     fn to_str(&self) -> ~str {
         let mut s = ~"";
         match self.host {
-          Some(ref h) => { s += "\\\\"; s += *h; }
+          Some(ref h) => {
+            s.push_str("\\\\");
+            s.push_str(*h);
+          }
           None => { }
         }
         match self.device {
-          Some(ref d) => { s += *d; s += ":"; }
+          Some(ref d) => {
+            s.push_str(*d);
+            s.push_str(":");
+          }
           None => { }
         }
         if self.is_absolute {
-            s += "\\";
+            s.push_str("\\");
         }
         s + self.components.connect("\\")
     }
index c7f33587f3157bfe67671901f7c6dc7a124620a1..ab7d3fda50137eb1bfda42b6947097a5f1ca764b 100644 (file)
@@ -263,8 +263,11 @@ fn highlight_lines(cm: @codemap::CodeMap,
         let s = fmt!("%s:%u ", fm.name, last_line + 1u);
         let mut indent = s.len();
         let mut out = ~"";
-        while indent > 0u { out += " "; indent -= 1u; }
-        out += "...\n";
+        while indent > 0u {
+            out.push_char(' ');
+            indent -= 1u;
+        }
+        out.push_str("...\n");
         io::stderr().write_str(out);
     }
 
@@ -285,23 +288,29 @@ fn highlight_lines(cm: @codemap::CodeMap,
         // part of the 'filename:line ' part of the previous line.
         let skip = fm.name.len() + digits + 3u;
         for skip.times() {
-            s += " ";
+            s.push_char(' ');
         }
         let orig = fm.get_line(lines.lines[0] as int);
         for uint::range(0u,left-skip) |pos| {
             let curChar = (orig[pos] as char);
-            s += match curChar { // Whenever a tab occurs on the previous
-                '\t' => "\t",    // line, we insert one on the error-point-
-                _ => " "         // -squiggly-line as well (instead of a
-            };                   // space). This way the squiggly-line will
-        }                        // usually appear in the correct position.
+            // Whenever a tab occurs on the previous line, we insert one on
+            // the error-point-squiggly-line as well (instead of a space).
+            // That way the squiggly line will usually appear in the correct
+            // position.
+            match curChar {
+                '\t' => s.push_char('\t'),
+                _ => s.push_char(' '),
+            };
+        }
         io::stderr().write_str(s);
         let mut s = ~"^";
         let hi = cm.lookup_char_pos(sp.hi);
         if hi.col != lo.col {
             // the ^ already takes up one space
             let num_squigglies = hi.col.to_uint()-lo.col.to_uint()-1u;
-            for num_squigglies.times() { s += "~"; }
+            for num_squigglies.times() {
+                s.push_char('~')
+            }
         }
         print_maybe_colored(s + "\n", diagnosticcolor(lvl));
     }
index 80ab54b7e2cfe1540ca6184420dba22ce5a10cef..7df8874076e091456f2fb32bdc485f1ccd9629ba 100644 (file)
@@ -26,8 +26,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
             }
         } else {
             match *e {
-                ast::tt_tok(_, token::IDENT(ident,_)) =>
-                res_str += cx.str_of(ident),
+                ast::tt_tok(_, token::IDENT(ident,_)) => res_str.push_str(cx.str_of(ident)),
                 _ => cx.span_fatal(sp, "concat_idents! requires ident args.")
             }
         }
index 2c5ec0909d9514416155fc3660054f10040be52f..8e1276d52d1d60b2b40ef4a28ae7fd2482fc96ad 100644 (file)
@@ -65,8 +65,8 @@ fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item {
                 args_ast);
 
             let mut body = ~"{\n";
-            body += fmt!("use super::%s;\n", name);
-            body += "let mut pipe = pipe;\n";
+            body.push_str(fmt!("use super::%s;\n", name));
+            body.push_str("let mut pipe = pipe;\n");
 
             if this.proto.is_bounded() {
                 let (sp, rp) = match (this.dir, next.dir) {
@@ -76,13 +76,15 @@ fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item {
                   (recv, recv) => (~"c", ~"s")
                 };
 
-                body += "let mut b = pipe.reuse_buffer();\n";
-                body += fmt!("let %s = ::std::pipes::SendPacketBuffered(\
-                              &mut (b.buffer.data.%s));\n",
-                             sp, next.name);
-                body += fmt!("let %s = ::std::pipes::RecvPacketBuffered(\
-                              &mut (b.buffer.data.%s));\n",
-                             rp, next.name);
+                body.push_str("let mut b = pipe.reuse_buffer();\n");
+                body.push_str(fmt!("let %s = ::std::pipes::SendPacketBuffered(\
+                                    &mut (b.buffer.data.%s));\n",
+                                    sp,
+                                    next.name));
+                body.push_str(fmt!("let %s = ::std::pipes::RecvPacketBuffered(\
+                                   &mut (b.buffer.data.%s));\n",
+                                   rp,
+                                   next.name));
             }
             else {
                 let pat = match (this.dir, next.dir) {
@@ -92,23 +94,22 @@ fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item {
                   (recv, recv) => "(s, c)"
                 };
 
-                body += fmt!("let %s = ::std::pipes::entangle();\n", pat);
+                body.push_str(fmt!("let %s = ::std::pipes::entangle();\n", pat));
             }
-            body += fmt!("let message = %s(%s);\n",
-                         name,
-                         vec::append_one(
-                             arg_names.map(|x| cx.str_of(*x)),
-                             @"s").connect(", "));
+            body.push_str(fmt!("let message = %s(%s);\n",
+                                name,
+                                vec::append_one(arg_names.map(|x| cx.str_of(*x)), ~"s")
+                                                         .connect(", ")));
 
             if !try {
-                body += fmt!("::std::pipes::send(pipe, message);\n");
+                body.push_str(fmt!("::std::pipes::send(pipe, message);\n"));
                 // return the new channel
-                body += "c }";
+                body.push_str("c }");
             }
             else {
-                body += fmt!("if ::std::pipes::send(pipe, message) {\n \
+                body.push_str(fmt!("if ::std::pipes::send(pipe, message) {\n \
                                   ::std::pipes::rt::make_some(c) \
-                              } else { ::std::pipes::rt::make_none() } }");
+                              } else { ::std::pipes::rt::make_none() } }"));
             }
 
             let body = cx.parse_expr(body.to_managed());
@@ -155,19 +156,19 @@ fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item {
                 };
 
                 let mut body = ~"{ ";
-                body += fmt!("use super::%s;\n", name);
-                body += fmt!("let message = %s%s;\n", name, message_args);
+                body.push_str(fmt!("use super::%s;\n", name));
+                body.push_str(fmt!("let message = %s%s;\n", name, message_args));
 
                 if !try {
-                    body += fmt!("::std::pipes::send(pipe, message);\n");
-                    body += " }";
+                    body.push_str(fmt!("::std::pipes::send(pipe, message);\n"));
+                    body.push_str(" }");
                 } else {
-                    body += fmt!("if ::std::pipes::send(pipe, message) \
+                    body.push_str(fmt!("if ::std::pipes::send(pipe, message) \
                                         { \
                                       ::std::pipes::rt::make_some(()) \
                                   } else { \
                                     ::std::pipes::rt::make_none() \
-                                  } }");
+                                  } }"));
                 }
 
                 let body = cx.parse_expr(body.to_managed());
@@ -433,10 +434,10 @@ fn compile(&self, cx: @ExtCtxt) -> @ast::item {
         let mut server_states = ~[];
 
         for (copy self.states).iter().advance |s| {
-            items += s.to_type_decls(cx);
+            items.push_all_move(s.to_type_decls(cx));
 
-            client_states += s.to_endpoint_decls(cx, send);
-            server_states += s.to_endpoint_decls(cx, recv);
+            client_states.push_all_move(s.to_endpoint_decls(cx, send));
+            server_states.push_all_move(s.to_endpoint_decls(cx, recv));
         }
 
         if self.is_bounded() {
index ddcad5c3e8f6c29bf59d2a2d003ec9bcf0af41a4..d33b72ae3c90e8170d031e360b1503ce72fa039b 100644 (file)
@@ -42,7 +42,7 @@ fn parse_outer_attributes(&self) -> ~[ast::attribute] {
                 if self.look_ahead(1u) != token::LBRACKET {
                     break;
                 }
-                attrs += [self.parse_attribute(ast::attr_outer)];
+                attrs.push(self.parse_attribute(ast::attr_outer));
               }
               token::DOC_COMMENT(s) => {
                 let attr = ::attr::mk_sugared_doc_attr(
@@ -53,7 +53,7 @@ fn parse_outer_attributes(&self) -> ~[ast::attribute] {
                 if attr.node.style != ast::attr_outer {
                   self.fatal("expected outer comment");
                 }
-                attrs += [attr];
+                attrs.push(attr);
                 self.bump();
               }
               _ => break
@@ -77,9 +77,7 @@ fn parse_attribute_naked(&self, style: ast::attr_style, lo: BytePos) ->
         self.expect(&token::RBRACKET);
         let hi = self.span.hi;
         return spanned(lo, hi, ast::attribute_ { style: style,
-                                                 value: meta_item,
-                                                 is_sugared_doc: false });
-    }
+                                                 value: meta_item, is_sugared_doc: false }); }
 
     // Parse attributes that appear after the opening of an item, each
     // terminated by a semicolon. In addition to a vector of inner attributes,
@@ -105,7 +103,7 @@ fn parse_inner_attrs_and_next(&self) ->
                 let attr = self.parse_attribute(ast::attr_inner);
                 if *self.token == token::SEMI {
                     self.bump();
-                    inner_attrs += [attr];
+                    inner_attrs.push(attr);
                 } else {
                     // It's not really an inner attribute
                     let outer_attr =
@@ -113,7 +111,7 @@ fn parse_inner_attrs_and_next(&self) ->
                             ast::attribute_ { style: ast::attr_outer,
                                               value: attr.node.value,
                                               is_sugared_doc: false });
-                    next_outer_attrs += [outer_attr];
+                    next_outer_attrs.push(outer_attr);
                     break;
                 }
               }
@@ -125,9 +123,9 @@ fn parse_inner_attrs_and_next(&self) ->
                 );
                 self.bump();
                 if attr.node.style == ast::attr_inner {
-                  inner_attrs += [attr];
+                  inner_attrs.push(attr);
                 } else {
-                  next_outer_attrs += [attr];
+                  next_outer_attrs.push(attr);
                   break;
                 }
               }
index 2baf08b68f1c6f394338ef8848a4ae785ac63295..01af33b13b856316c9ac235e57eeb0f32d56488d 100644 (file)
@@ -254,7 +254,7 @@ fn read_block_comment(rdr: @mut StringReader,
             bump(rdr);
         }
         if !is_eof(rdr) {
-            curr_line += "*/";
+            curr_line.push_str("*/");
             bump(rdr);
             bump(rdr);
         }
@@ -278,13 +278,13 @@ fn read_block_comment(rdr: @mut StringReader,
                 if rdr.curr == '/' && nextch(rdr) == '*' {
                     bump(rdr);
                     bump(rdr);
-                    curr_line += "*";
+                    curr_line.push_char('*');
                     level += 1;
                 } else {
                     if rdr.curr == '*' && nextch(rdr) == '/' {
                         bump(rdr);
                         bump(rdr);
-                        curr_line += "/";
+                        curr_line.push_char('/');
                         level -= 1;
                     } else { bump(rdr); }
                 }
index cde4c754d560eba1fb208d1b8ec40e8c8e367474..e003e2b27e9a2c24f3e27f87615b518423951e2c 100644 (file)
@@ -192,10 +192,10 @@ pub fn expect_gt(&self) {
             );
         } else {
             let mut s: ~str = ~"expected `";
-            s += self.token_to_str(&token::GT);
-            s += "`, found `";
-            s += self.this_token_to_str();
-            s += "`";
+            s.push_str(self.token_to_str(&token::GT));
+            s.push_str("`, found `");
+            s.push_str(self.this_token_to_str());
+            s.push_str("`");
             self.fatal(s);
         }
     }
index 2092f0fa5facddb821df24f1215e3ebc4c0f1c04..4a872832952665b31a7f6a38874c833e3f134f2a 100644 (file)
@@ -180,7 +180,7 @@ pub fn bump(rdr: &mut StringReader) {
         let byte_offset_diff = next.next - current_byte_offset;
         rdr.pos = rdr.pos + BytePos(byte_offset_diff);
         rdr.curr = next.ch;
-        rdr.col += CharPos(1u);
+        rdr.col = rdr.col + CharPos(1u);
         if last_char == '\n' {
             rdr.filemap.next_line(rdr.last_pos);
             rdr.col = CharPos(0u);
@@ -448,8 +448,8 @@ fn scan_number(c: char, rdr: @mut StringReader) -> token::Token {
         is_float = true;
         bump(rdr);
         let dec_part = scan_digits(rdr, 10u);
-        num_str += ".";
-        num_str += dec_part;
+        num_str.push_char('.');
+        num_str.push_str(dec_part);
     }
     if is_float {
         match base {
@@ -461,7 +461,7 @@ fn scan_number(c: char, rdr: @mut StringReader) -> token::Token {
     match scan_exponent(rdr) {
       Some(ref s) => {
         is_float = true;
-        num_str += (*s);
+        num_str.push_str(*s);
       }
       None => ()
     }
index ee5ef8dfa6b9e0466354e4abf3f194ccc9ad20eb..a7c46d609cae2582a6879eb3077a775ad5d3cf69 100644 (file)
@@ -4257,8 +4257,12 @@ fn parse_macro_use_or_failure(
         // FAILURE TO PARSE ITEM
         if visibility != inherited {
             let mut s = ~"unmatched visibility `";
-            s += if visibility == public { "pub" } else { "priv" };
-            s += "`";
+            if visibility == public {
+                s.push_str("pub")
+            } else {
+                s.push_str("priv")
+            }
+            s.push_char('`');
             self.span_fatal(*self.last_span, s);
         }
         return iovi_none;
index df599596d7d00264cafb599c01ccc6bd248b1b3b..18e6c1817991bb4d7616d8a0d493a7c90ced40ba 100644 (file)
@@ -178,14 +178,14 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
       LIT_FLOAT(ref s, t) => {
         let mut body = ident_to_str(s).to_owned();
         if body.ends_with(".") {
-            body += "0";  // `10.f` is not a float literal
+            body.push_char('0');  // `10.f` is not a float literal
         }
         body + ast_util::float_ty_to_str(t)
       }
       LIT_FLOAT_UNSUFFIXED(ref s) => {
         let mut body = ident_to_str(s).to_owned();
         if body.ends_with(".") {
-            body += "0";  // `10.f` is not a float literal
+            body.push_char('0');  // `10.f` is not a float literal
         }
         body
       }
index 4e03d9bac70407b4eebf2cc3ecca5391427178a1..7cd3faf9a90533cba4b9fcbd81b570c23ee7f237 100644 (file)
@@ -122,12 +122,14 @@ pub fn buf_str(toks: ~[token], szs: ~[int], left: uint, right: uint,
     let mut s = ~"[";
     while i != right && L != 0u {
         L -= 1u;
-        if i != left { s += ", "; }
-        s += fmt!("%d=%s", szs[i], tok_str(toks[i]));
+        if i != left {
+            s.push_str(", ");
+        }
+        s.push_str(fmt!("%d=%s", szs[i], tok_str(toks[i])));
         i += 1u;
         i %= n;
     }
-    s += "]";
+    s.push_char(']');
     return s;
 }
 
index 787cf696cc34851fce7aa37b4bb7f085fd6e68e3..c4d89a698c1abecf6d310f61957470d58f40fff3 100644 (file)
@@ -87,9 +87,8 @@ fn vec_plus() {
     while i < 1500 {
         let rv = vec::from_elem(r.gen_uint_range(0, i + 1), i);
         if r.gen() {
-            v += rv;
-        }
-        else {
+            v.push_all_move(rv);
+        } else {
             v = rv + v;
         }
         i += 1;
index 96c7e4e9b375bb5656fb31fcd06328d0d3d6839a..49a3a3ec5d7d39801df461ea4595ae7816956573 100644 (file)
@@ -50,8 +50,8 @@ fn show_color(cc: color) -> ~str {
 fn show_color_list(set: ~[color]) -> ~str {
     let mut out = ~"";
     for set.iter().advance |col| {
-        out += " ";
-        out += show_color(*col);
+        out.push_char(' ');
+        out.push_str(show_color(*col));
     }
     return out;
 }
index f3efcc21ea9bdc7069723a5a4473ae465443e6ba..da8d65a1dcbab449ba3b98fca941ba240dd2d992 100644 (file)
@@ -47,7 +47,7 @@ fn make_cumulative(aa: ~[AminoAcids]) -> ~[AminoAcids] {
     let mut ans: ~[AminoAcids] = ~[];
     for aa.iter().advance |a| {
         cp += a.prob;
-        ans += [AminoAcids {ch: a.ch, prob: cp}];
+        ans.push(AminoAcids {ch: a.ch, prob: cp});
     }
     ans
 }
index 57683fa3dbf0c6eda9dd8fb6793dbf893d34b24b..d26fe80e8a124f4c815a4ce73c83828dfe5783e0 100644 (file)
@@ -70,7 +70,7 @@ fn sortKV<TT:Copy + Ord,UU:Copy + Ord>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
            let b = str::raw::from_bytes(k);
            // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use
            // to_ascii_consume and to_str_consume to not do a unnecessary copy.
-           buffer += (fmt!("%s %0.3f\n", b.to_ascii().to_upper().to_str_ascii(), v));
+           buffer.push_str(fmt!("%s %0.3f\n", b.to_ascii().to_upper().to_str_ascii(), v));
        }
    }
 
index f66de3853743aabb552ef2b9968bd2500bbff5c7..2396d6efc5cc1a924c1911ee43cd65cf1c6e6205 100644 (file)
@@ -103,7 +103,9 @@ pub fn solve(&mut self) {
         for u8::range(0u8, 9u8) |row| {
             for u8::range(0u8, 9u8) |col| {
                 let color = self.grid[row][col];
-                if color == 0u8 { work += [(row, col)]; }
+                if color == 0u8 {
+                    work.push((row, col));
+                }
             }
         }
 
index f7b9371df5731b2293fcdecde71bd43987aa946a..b5a5eed6a35a21ba723fbb9f58ebc1806ffbd7bd 100644 (file)
@@ -15,7 +15,7 @@ trait vec_monad<A> {
 impl<A> vec_monad<A> for ~[A] {
     fn bind<B>(&self, f: &fn(A) -> ~[B]) {
         let mut r = fail!();
-        for self.iter().advance |elt| { r += f(*elt); }
+        for self.iter().advance |elt| { r = r + f(*elt); }
         //~^ WARNING unreachable expression
         //~^^ ERROR the type of this value must be known
    }
index 6f4a3f5ab1d2e337883fbe208a424ceef74f95fb..caee00027883a58eb1088de5bf59e7183caca97e 100644 (file)
@@ -10,9 +10,9 @@
 
 // error-pattern:so long
 fn main() {
-    let x = ~[];
+    let mut x = ~[];
     let y = ~[3];
     fail!("so long");
-    x += y;
+    x.push_all_move(y);
     ~"good" + ~"bye";
 }
index a82b263944982dd6f98825328411fae86b424c07..ab89a357d349c2172903d2bf4ec3326d684b6227 100644 (file)
@@ -44,19 +44,19 @@ fn test_heap_add() {
 
 fn test_append() {
     let mut s = ~"";
-    s += ~"a";
+    s.push_str(~"a");
     assert_eq!(s, ~"a");
 
     let mut s = ~"a";
-    s += ~"b";
+    s.push_str(~"b");
     debug!(s.clone());
     assert_eq!(s, ~"ab");
 
     let mut s = ~"c";
-    s += ~"offee";
+    s.push_str(~"offee");
     assert!(s == ~"coffee");
 
-    s += ~"&tea";
+    s.push_str(~"&tea");
     assert!(s == ~"coffee&tea");
 }
 
index acdf388a8ff033720b7111825985b9afdddaf84b..d910ac9a4e77ab21645b59bd1d3cf4251a438ec6 100644 (file)
@@ -15,7 +15,7 @@ fn the_loop() {
     loop {
         let x = 5;
         if x > 3 {
-            list += ~[take(x)];
+            list.push(take(x));
         } else {
             break;
         }
index 66b64768060943399f995ee88de850463474a35b..5ac62bae39224f569b45766d11195934156e384e 100644 (file)
@@ -23,7 +23,7 @@ fn foo<T>(y: Option<T>) {
           None::<T> => x = 17,
           _ => x = 42
         }
-        rs += ~[x];
+        rs.push(x);
     }
     return;
 }
index 3f3cf5e5aaa0eebea828908af1f6ef7679b3ec03..fe06c973dbfd815d92371c1fab6d02d83c12a1d3 100644 (file)
@@ -19,7 +19,9 @@ trait vec_monad<A> {
 impl<A> vec_monad<A> for ~[A] {
     fn bind<B:Copy>(&self, f: &fn(&A) -> ~[B]) -> ~[B] {
         let mut r = ~[];
-        for self.iter().advance |elt| { r += f(elt); }
+        for self.iter().advance |elt| {
+            r.push_all_move(f(elt));
+        }
         r
     }
 }
index 1d9e7d3c649667c4ec6387e2f4cb3780b2c37215..538aedcf7c8879f27614e5a3bef6a154edf5555f 100644 (file)
@@ -13,7 +13,9 @@
 
 use std::vec;
 
-fn grow(v: &mut ~[int]) { *v += ~[1]; }
+fn grow(v: &mut ~[int]) {
+    v.push(1);
+}
 
 pub fn main() {
     let mut v: ~[int] = ~[];
index e75af5729d5c2c36e6622b82f8c7f7d2259c6e11..05aa1e7460839a0b08b4c53278e3ef6a2efa1382 100644 (file)
@@ -57,7 +57,7 @@ fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
 
 pub fn main() {
     let mut p = Point {x: 10, y: 20};
-    p += Point {x: 101, y: 102};
+    p = p + Point {x: 101, y: 102};
     p = p - Point {x: 100, y: 100};
     assert_eq!(p + Point {x: 5, y: 5}, Point {x: 16, y: 27});
     assert_eq!(-p, Point {x: -11, y: -22});
index 85575b2ea8bb6803f6039f6512dcbf231debe6f4..d0c58b50e2cec179494520aef9d3c0fb5c2e0909 100644 (file)
@@ -19,7 +19,7 @@ fn foo(c: ~[int]) {
             for c.iter().advance |i| {
                 debug!(a);
                 let a = 17;
-                b += ~[a];
+                b.push(a);
             }
         }
         _ => { }
index 421cd1d4d0bb32c4a167ee0ded12deae7b89a641..0ddc39d6b18cc7eda81e94fc6fe3936267bffa69 100644 (file)
@@ -51,7 +51,9 @@ fn length_(&self) -> uint { self.len() }
     fn iter_(&self, f: &fn(&T)) { for self.iter().advance |x| { f(x); } }
     fn map_<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U] {
         let mut r = ~[];
-        for self.iter().advance |elt| { r += ~[f(elt)]; }
+        for self.iter().advance |elt| {
+            r.push(f(elt));
+        }
         r
     }
 }
index 4fdf7dde031a7c6a9c9fa1e13b0607b3b2cb382f..556247eb4260ee62b2613ed07718501250d78595 100644 (file)
@@ -15,7 +15,7 @@
 
 fn test1() {
     let mut s: ~str = ~"hello";
-    s += ~"world";
+    s.push_str("world");
     debug!(s.clone());
     assert_eq!(s[9], 'd' as u8);
 }
index 6938b52eee83ea10e2e99fe2d4b51cdfbe37dd6d..0cdf1841331a8d36fbac057fbeaf9782dec85257 100644 (file)
 
 pub fn main() {
     let mut s = ~"a";
-    s += ~"b";
+    s.push_char('b');
     assert_eq!(s[0], 'a' as u8);
     assert_eq!(s[1], 'b' as u8);
-    s += ~"c";
-    s += ~"d";
+    s.push_char('c');
+    s.push_char('d');
     assert_eq!(s[0], 'a' as u8);
     assert_eq!(s[1], 'b' as u8);
     assert_eq!(s[2], 'c' as u8);
index dc6bdbf5c1a5c6895cfa4d67e77607437bdb46c9..5952afa6676b7134a7e053c1697b896afbefdecf 100644 (file)
@@ -33,7 +33,7 @@ fn map<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U] {
         let mut r = ~[];
         // FIXME: #7355 generates bad code with Iterator
         for std::uint::range(0, self.len()) |i| {
-            r += ~[f(&self[i])];
+            r.push(f(&self[i]));
         }
         r
     }
index 816228b62c674d2e3424c9398f1b8c443e9e1ced..c9a4c57cc9d36e55d472d4bfa76fbe04e9176c36 100644 (file)
 
 pub fn main() {
     let mut v = ~[1];
-    v += ~[2];
-    v += ~[3];
-    v += ~[4];
-    v += ~[5];
+    v.push(2);
+    v.push(3);
+    v.push(4);
+    v.push(5);
     assert_eq!(v[0], 1);
     assert_eq!(v[1], 2);
     assert_eq!(v[2], 3);
index 082f2db259a4aea2bbfb64fe1c85bf41f61ce972..503e37fcd76ea32cdb8e71bc7ac3ff0ed98d800d 100644 (file)
@@ -17,7 +17,7 @@ fn make(i: int) -> t {
     let mut s = ~"hello";
     // Ensure s is non-const.
 
-    s += ~"there";
+    s.push_str("there");
     return b(s);
 }