about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-06-11 19:13:42 -0700
committerCorey Richardson <corey@octayn.net>2013-06-28 10:44:16 -0400
commita1531ed946e2d650fc6cb5af6258fed8003e9443 (patch)
tree8f629d34e6cb62bd9a5a2ef22656075715446c0e /src/libsyntax
parent3fcd4dca301d01c41a7db7f9023bc11be1025fc7 (diff)
downloadrust-a1531ed946e2d650fc6cb5af6258fed8003e9443.tar.gz
rust-a1531ed946e2d650fc6cb5af6258fed8003e9443.zip
librustc: Remove the broken overloaded assign-ops from the language.
They evaluated the receiver twice. They should be added back with
`AddAssign`, `SubAssign`, etc., traits.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/diagnostic.rs27
-rw-r--r--src/libsyntax/ext/concat_idents.rs3
-rw-r--r--src/libsyntax/ext/pipes/pipec.rs57
-rw-r--r--src/libsyntax/parse/attr.rs16
-rw-r--r--src/libsyntax/parse/comments.rs6
-rw-r--r--src/libsyntax/parse/common.rs8
-rw-r--r--src/libsyntax/parse/lexer.rs8
-rw-r--r--src/libsyntax/parse/parser.rs8
-rw-r--r--src/libsyntax/parse/token.rs4
-rw-r--r--src/libsyntax/print/pp.rs8
10 files changed, 79 insertions, 66 deletions
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs
index c7f33587f31..ab7d3fda501 100644
--- a/src/libsyntax/diagnostic.rs
+++ b/src/libsyntax/diagnostic.rs
@@ -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));
     }
diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs
index 80ab54b7e2c..7df8874076e 100644
--- a/src/libsyntax/ext/concat_idents.rs
+++ b/src/libsyntax/ext/concat_idents.rs
@@ -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.")
             }
         }
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 2c5ec0909d9..8e1276d52d1 100644
--- a/src/libsyntax/ext/pipes/pipec.rs
+++ b/src/libsyntax/ext/pipes/pipec.rs
@@ -65,8 +65,8 @@ impl gen_send for message {
                 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 @@ impl gen_send for message {
                   (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 @@ impl gen_send for message {
                   (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 @@ impl gen_send for message {
                 };
 
                 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 @@ impl gen_init for protocol {
         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() {
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index ddcad5c3e8f..d33b72ae3c9 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -42,7 +42,7 @@ impl parser_attr for Parser {
                 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 @@ impl parser_attr for Parser {
                 if attr.node.style != ast::attr_outer {
                   self.fatal("expected outer comment");
                 }
-                attrs += [attr];
+                attrs.push(attr);
                 self.bump();
               }
               _ => break
@@ -77,9 +77,7 @@ impl parser_attr for Parser {
         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 @@ impl parser_attr for Parser {
                 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 @@ impl parser_attr for Parser {
                             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 @@ impl parser_attr for Parser {
                 );
                 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;
                 }
               }
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 2baf08b68f1..01af33b13b8 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -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); }
                 }
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index cde4c754d56..e003e2b27e9 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -192,10 +192,10 @@ impl Parser {
             );
         } 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);
         }
     }
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 2092f0fa5fa..4a872832952 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -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 => ()
     }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index ee5ef8dfa6b..a7c46d609ca 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4257,8 +4257,12 @@ impl Parser {
         // 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;
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index df599596d7d..18e6c181799 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -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
       }
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index 4e03d9bac70..7cd3faf9a90 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -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;
 }