about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-28 12:05:12 -0700
committerbors <bors@rust-lang.org>2013-06-28 12:05:12 -0700
commitf44b951a1ea40b61508b2d0abb3f239797f885c5 (patch)
tree326ffc88eb48938b5c57daad927cf6e7462a13e1 /src/libsyntax
parent4e4e2f70c90f01b5be22a192c883b9dcb34df7ff (diff)
parent4f044891a5457acb06338c78f9aa58d8b4c9d53f (diff)
downloadrust-f44b951a1ea40b61508b2d0abb3f239797f885c5.tar.gz
rust-f44b951a1ea40b61508b2d0abb3f239797f885c5.zip
auto merge of #7451 : cmr/rust/rewrite-each-path, r=pcwalton
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs7
-rw-r--r--src/libsyntax/ast_util.rs11
-rw-r--r--src/libsyntax/diagnostic.rs27
-rw-r--r--src/libsyntax/ext/concat_idents.rs3
-rw-r--r--src/libsyntax/ext/deriving/to_str.rs2
-rw-r--r--src/libsyntax/ext/deriving/ty.rs6
-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.rs248
-rw-r--r--src/libsyntax/parse/lexer.rs8
-rw-r--r--src/libsyntax/parse/obsolete.rs32
-rw-r--r--src/libsyntax/parse/parser.rs281
-rw-r--r--src/libsyntax/parse/token.rs4
-rw-r--r--src/libsyntax/print/pp.rs8
-rw-r--r--src/libsyntax/util/interner.rs2
16 files changed, 392 insertions, 326 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index feb03896558..8e1c51caf7c 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -147,7 +147,7 @@ pub static crate_node_id: node_id = 0;
 // The AST represents all type param bounds as types.
 // typeck::collect::compute_bounds matches these against
 // the "special" built-in traits (see middle::lang_items) and
-// detects Copy, Send, Owned, and Const.
+// detects Copy, Send, Send, and Freeze.
 pub enum TyParamBound {
     TraitTyParamBound(@trait_ref),
     RegionTyParamBound
@@ -205,7 +205,8 @@ pub enum def {
     def_struct(def_id),
     def_typaram_binder(node_id), /* struct, impl or trait with ty params */
     def_region(node_id),
-    def_label(node_id)
+    def_label(node_id),
+    def_method(def_id /* method */, Option<def_id> /* trait */),
 }
 
 
@@ -1047,7 +1048,7 @@ pub struct trait_ref {
 pub enum visibility { public, private, inherited }
 
 impl visibility {
-    fn inherit_from(&self, parent_visibility: visibility) -> visibility {
+    pub fn inherit_from(&self, parent_visibility: visibility) -> visibility {
         match self {
             &inherited => parent_visibility,
             &public | &private => *self
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 9ba7cb3c818..6761736d2f3 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -59,7 +59,7 @@ pub fn def_id_of_def(d: def) -> def_id {
       def_fn(id, _) | def_static_method(id, _, _) | def_mod(id) |
       def_foreign_mod(id) | def_static(id, _) |
       def_variant(_, id) | def_ty(id) | def_ty_param(id, _) |
-      def_use(id) | def_struct(id) | def_trait(id) => {
+      def_use(id) | def_struct(id) | def_trait(id) | def_method(id, _) => {
         id
       }
       def_arg(id, _) | def_local(id, _) | def_self(id, _) | def_self_ty(id)
@@ -619,6 +619,15 @@ pub enum Privacy {
     Public
 }
 
+/// Returns true if the given pattern consists solely of an identifier
+/// and false otherwise.
+pub fn pat_is_ident(pat: @ast::pat) -> bool {
+    match pat.node {
+        ast::pat_ident(*) => true,
+        _ => false,
+    }
+}
+
 // HYGIENE FUNCTIONS
 
 /// Construct an identifier with the given name and an empty context:
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/deriving/to_str.rs b/src/libsyntax/ext/deriving/to_str.rs
index d1d4d173a3f..c9d63d2c416 100644
--- a/src/libsyntax/ext/deriving/to_str.rs
+++ b/src/libsyntax/ext/deriving/to_str.rs
@@ -30,7 +30,7 @@ pub fn expand_deriving_to_str(cx: @ExtCtxt,
                 generics: LifetimeBounds::empty(),
                 explicit_self: borrowed_explicit_self(),
                 args: ~[],
-                ret_ty: Ptr(~Literal(Path::new_local("str")), Owned),
+                ret_ty: Ptr(~Literal(Path::new_local("str")), Send),
                 const_nonmatching: false,
                 combine_substructure: to_str_substructure
             }
diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs
index 2f21eba11d7..a2f9aa58d99 100644
--- a/src/libsyntax/ext/deriving/ty.rs
+++ b/src/libsyntax/ext/deriving/ty.rs
@@ -22,7 +22,7 @@ use opt_vec;
 
 /// The types of pointers
 pub enum PtrTy<'self> {
-    Owned, // ~
+    Send, // ~
     Managed(ast::mutability), // @[mut]
     Borrowed(Option<&'self str>, ast::mutability), // &['lifetime] [mut]
 }
@@ -128,7 +128,7 @@ impl<'self> Ty<'self> {
             Ptr(ref ty, ref ptr) => {
                 let raw_ty = ty.to_ty(cx, span, self_ty, self_generics);
                 match *ptr {
-                    Owned => {
+                    Send => {
                         cx.ty_uniq(span, raw_ty)
                     }
                     Managed(mutbl) => {
@@ -248,7 +248,7 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option<PtrTy>)
             let self_ty = respan(
                 span,
                 match *ptr {
-                    Owned => ast::sty_uniq(ast::m_imm),
+                    Send => ast::sty_uniq(ast::m_imm),
                     Managed(mutbl) => ast::sty_box(mutbl),
                     Borrowed(ref lt, mutbl) => {
                         let lt = lt.map(|s| @cx.lifetime(span,
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 2c5ec0909d9..3044cd50b34 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..04f62f35749 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -51,251 +51,3 @@ pub fn token_to_str(token: &token::Token) -> ~str {
     token::to_str(get_ident_interner(), token)
 }
 
-impl Parser {
-    // convert a token to a string using self's reader
-    pub fn token_to_str(&self, token: &token::Token) -> ~str {
-        token::to_str(get_ident_interner(), token)
-    }
-
-    // convert the current token to a string using self's reader
-    pub fn this_token_to_str(&self) -> ~str {
-        self.token_to_str(self.token)
-    }
-
-    pub fn unexpected_last(&self, t: &token::Token) -> ! {
-        self.span_fatal(
-            *self.last_span,
-            fmt!(
-                "unexpected token: `%s`",
-                self.token_to_str(t)
-            )
-        );
-    }
-
-    pub fn unexpected(&self) -> ! {
-        self.fatal(
-            fmt!(
-                "unexpected token: `%s`",
-                self.this_token_to_str()
-            )
-        );
-    }
-
-    // expect and consume the token t. Signal an error if
-    // the next token is not t.
-    pub fn expect(&self, t: &token::Token) {
-        if *self.token == *t {
-            self.bump();
-        } else {
-            self.fatal(
-                fmt!(
-                    "expected `%s` but found `%s`",
-                    self.token_to_str(t),
-                    self.this_token_to_str()
-                )
-            )
-        }
-    }
-
-    pub fn parse_ident(&self) -> ast::ident {
-        self.check_strict_keywords();
-        self.check_reserved_keywords();
-        match *self.token {
-            token::IDENT(i, _) => {
-                self.bump();
-                i
-            }
-            token::INTERPOLATED(token::nt_ident(*)) => {
-                self.bug("ident interpolation not converted to real token");
-            }
-            _ => {
-                self.fatal(
-                    fmt!(
-                        "expected ident, found `%s`",
-                        self.this_token_to_str()
-                    )
-                );
-            }
-        }
-    }
-
-    pub fn parse_path_list_ident(&self) -> ast::path_list_ident {
-        let lo = self.span.lo;
-        let ident = self.parse_ident();
-        let hi = self.last_span.hi;
-        spanned(lo, hi, ast::path_list_ident_ { name: ident,
-                                                id: self.get_id() })
-    }
-
-    // consume token 'tok' if it exists. Returns true if the given
-    // token was present, false otherwise.
-    pub fn eat(&self, tok: &token::Token) -> bool {
-        return if *self.token == *tok { self.bump(); true } else { false };
-    }
-
-    pub fn is_keyword(&self, kw: keywords::Keyword) -> bool {
-        token::is_keyword(kw, self.token)
-    }
-
-    // if the next token is the given keyword, eat it and return
-    // true. Otherwise, return false.
-    pub fn eat_keyword(&self, kw: keywords::Keyword) -> bool {
-        let is_kw = match *self.token {
-            token::IDENT(sid, false) => kw.to_ident().name == sid.name,
-            _ => false
-        };
-        if is_kw { self.bump() }
-        is_kw
-    }
-
-    // if the given word is not a keyword, signal an error.
-    // if the next token is not the given word, signal an error.
-    // otherwise, eat it.
-    pub fn expect_keyword(&self, kw: keywords::Keyword) {
-        if !self.eat_keyword(kw) {
-            self.fatal(
-                fmt!(
-                    "expected `%s`, found `%s`",
-                    self.id_to_str(kw.to_ident()),
-                    self.this_token_to_str()
-                )
-            );
-        }
-    }
-
-    // signal an error if the given string is a strict keyword
-    pub fn check_strict_keywords(&self) {
-        if token::is_strict_keyword(self.token) {
-            self.span_err(*self.last_span,
-                          fmt!("found `%s` in ident position", self.this_token_to_str()));
-        }
-    }
-
-    // signal an error if the current token is a reserved keyword
-    pub fn check_reserved_keywords(&self) {
-        if token::is_reserved_keyword(self.token) {
-            self.fatal(fmt!("`%s` is a reserved keyword", self.this_token_to_str()));
-        }
-    }
-
-    // expect and consume a GT. if a >> is seen, replace it
-    // with a single > and continue. If a GT is not seen,
-    // signal an error.
-    pub fn expect_gt(&self) {
-        if *self.token == token::GT {
-            self.bump();
-        } else if *self.token == token::BINOP(token::SHR) {
-            self.replace_token(
-                token::GT,
-                self.span.lo + BytePos(1u),
-                self.span.hi
-            );
-        } else {
-            let mut s: ~str = ~"expected `";
-            s += self.token_to_str(&token::GT);
-            s += "`, found `";
-            s += self.this_token_to_str();
-            s += "`";
-            self.fatal(s);
-        }
-    }
-
-    // parse a sequence bracketed by '<' and '>', stopping
-    // before the '>'.
-    pub fn parse_seq_to_before_gt<T: Copy>(&self,
-                                           sep: Option<token::Token>,
-                                           f: &fn(&Parser) -> T)
-                                           -> OptVec<T> {
-        let mut first = true;
-        let mut v = opt_vec::Empty;
-        while *self.token != token::GT
-            && *self.token != token::BINOP(token::SHR) {
-            match sep {
-              Some(ref t) => {
-                if first { first = false; }
-                else { self.expect(t); }
-              }
-              _ => ()
-            }
-            v.push(f(self));
-        }
-        return v;
-    }
-
-    pub fn parse_seq_to_gt<T: Copy>(&self,
-                                    sep: Option<token::Token>,
-                                    f: &fn(&Parser) -> T)
-                                    -> OptVec<T> {
-        let v = self.parse_seq_to_before_gt(sep, f);
-        self.expect_gt();
-        return v;
-    }
-
-    // parse a sequence, including the closing delimiter. The function
-    // f must consume tokens until reaching the next separator or
-    // closing bracket.
-    pub fn parse_seq_to_end<T: Copy>(&self,
-                                     ket: &token::Token,
-                                     sep: SeqSep,
-                                     f: &fn(&Parser) -> T)
-                                     -> ~[T] {
-        let val = self.parse_seq_to_before_end(ket, sep, f);
-        self.bump();
-        val
-    }
-
-    // parse a sequence, not including the closing delimiter. The function
-    // f must consume tokens until reaching the next separator or
-    // closing bracket.
-    pub fn parse_seq_to_before_end<T: Copy>(&self,
-                                            ket: &token::Token,
-                                            sep: SeqSep,
-                                            f: &fn(&Parser) -> T)
-                                            -> ~[T] {
-        let mut first: bool = true;
-        let mut v: ~[T] = ~[];
-        while *self.token != *ket {
-            match sep.sep {
-              Some(ref t) => {
-                if first { first = false; }
-                else { self.expect(t); }
-              }
-              _ => ()
-            }
-            if sep.trailing_sep_allowed && *self.token == *ket { break; }
-            v.push(f(self));
-        }
-        return v;
-    }
-
-    // parse a sequence, including the closing delimiter. The function
-    // f must consume tokens until reaching the next separator or
-    // closing bracket.
-    pub fn parse_unspanned_seq<T: Copy>(&self,
-                                        bra: &token::Token,
-                                        ket: &token::Token,
-                                        sep: SeqSep,
-                                        f: &fn(&Parser) -> T)
-                                        -> ~[T] {
-        self.expect(bra);
-        let result = self.parse_seq_to_before_end(ket, sep, f);
-        self.bump();
-        result
-    }
-
-    // NB: Do not use this function unless you actually plan to place the
-    // spanned list in the AST.
-    pub fn parse_seq<T: Copy>(&self,
-                              bra: &token::Token,
-                              ket: &token::Token,
-                              sep: SeqSep,
-                              f: &fn(&Parser) -> T)
-                              -> spanned<~[T]> {
-        let lo = self.span.lo;
-        self.expect(bra);
-        let result = self.parse_seq_to_before_end(ket, sep, f);
-        let hi = self.span.hi;
-        self.bump();
-        spanned(lo, hi, result)
-    }
-}
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/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 32508f3b477..fff4c125af6 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -62,6 +62,8 @@ pub enum ObsoleteSyntax {
     ObsoleteFixedLengthVectorType,
     ObsoleteNamedExternModule,
     ObsoleteMultipleLocalDecl,
+    ObsoleteMutWithMultipleBindings,
+    ObsoletePatternCopyKeyword,
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -71,7 +73,26 @@ impl to_bytes::IterBytes for ObsoleteSyntax {
     }
 }
 
-impl Parser {
+pub trait ParserObsoleteMethods {
+    /// Reports an obsolete syntax non-fatal error.
+    fn obsolete(&self, sp: span, kind: ObsoleteSyntax);
+    // Reports an obsolete syntax non-fatal error, and returns
+    // a placeholder expression
+    fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr;
+    fn report(&self,
+              sp: span,
+              kind: ObsoleteSyntax,
+              kind_str: &str,
+              desc: &str);
+    fn token_is_obsolete_ident(&self, ident: &str, token: &Token) -> bool;
+    fn is_obsolete_ident(&self, ident: &str) -> bool;
+    fn eat_obsolete_ident(&self, ident: &str) -> bool;
+    fn try_parse_obsolete_struct_ctor(&self) -> bool;
+    fn try_parse_obsolete_with(&self) -> bool;
+    fn try_parse_obsolete_priv_section(&self, attrs: &[attribute]) -> bool;
+}
+
+impl ParserObsoleteMethods for Parser {
     /// Reports an obsolete syntax non-fatal error.
     pub fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
         let (kind_str, desc) = match kind {
@@ -223,6 +244,15 @@ impl Parser {
                 "instead of e.g. `let a = 1, b = 2`, write \
                  `let (a, b) = (1, 2)`."
             ),
+            ObsoleteMutWithMultipleBindings => (
+                "`mut` with multiple bindings",
+                "use multiple local declarations instead of e.g. `let mut \
+                 (x, y) = ...`."
+            ),
+            ObsoletePatternCopyKeyword => (
+                "`copy` in patterns",
+                "`copy` in patterns no longer has any effect"
+            ),
         };
 
         self.report(sp, kind, kind_str, desc);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index d67771fc435..f1b5c4d16be 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -64,7 +64,7 @@ use codemap::{span, BytePos, spanned, mk_sp};
 use codemap;
 use parse::attr::parser_attr;
 use parse::classify;
-use parse::common::{seq_sep_none};
+use parse::common::{SeqSep, seq_sep_none};
 use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed};
 use parse::lexer::reader;
 use parse::lexer::TokenAndSpan;
@@ -83,8 +83,12 @@ use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer};
 use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
 use parse::obsolete::{ObsoleteConstItem, ObsoleteFixedLengthVectorType};
 use parse::obsolete::{ObsoleteNamedExternModule, ObsoleteMultipleLocalDecl};
-use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident, is_ident_or_path};
-use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents, token_to_binop};
+use parse::obsolete::{ObsoleteMutWithMultipleBindings};
+use parse::obsolete::{ObsoletePatternCopyKeyword, ParserObsoleteMethods};
+use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident};
+use parse::token::{is_ident_or_path};
+use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents};
+use parse::token::{token_to_binop};
 use parse::token;
 use parse::{new_sub_parser_from_file, next_node_id, ParseSess};
 use opt_vec;
@@ -270,6 +274,253 @@ impl Drop for Parser {
 }
 
 impl Parser {
+    // convert a token to a string using self's reader
+    pub fn token_to_str(&self, token: &token::Token) -> ~str {
+        token::to_str(get_ident_interner(), token)
+    }
+
+    // convert the current token to a string using self's reader
+    pub fn this_token_to_str(&self) -> ~str {
+        self.token_to_str(self.token)
+    }
+
+    pub fn unexpected_last(&self, t: &token::Token) -> ! {
+        self.span_fatal(
+            *self.last_span,
+            fmt!(
+                "unexpected token: `%s`",
+                self.token_to_str(t)
+            )
+        );
+    }
+
+    pub fn unexpected(&self) -> ! {
+        self.fatal(
+            fmt!(
+                "unexpected token: `%s`",
+                self.this_token_to_str()
+            )
+        );
+    }
+
+    // expect and consume the token t. Signal an error if
+    // the next token is not t.
+    pub fn expect(&self, t: &token::Token) {
+        if *self.token == *t {
+            self.bump();
+        } else {
+            self.fatal(
+                fmt!(
+                    "expected `%s` but found `%s`",
+                    self.token_to_str(t),
+                    self.this_token_to_str()
+                )
+            )
+        }
+    }
+
+    pub fn parse_ident(&self) -> ast::ident {
+        self.check_strict_keywords();
+        self.check_reserved_keywords();
+        match *self.token {
+            token::IDENT(i, _) => {
+                self.bump();
+                i
+            }
+            token::INTERPOLATED(token::nt_ident(*)) => {
+                self.bug("ident interpolation not converted to real token");
+            }
+            _ => {
+                self.fatal(
+                    fmt!(
+                        "expected ident, found `%s`",
+                        self.this_token_to_str()
+                    )
+                );
+            }
+        }
+    }
+
+    pub fn parse_path_list_ident(&self) -> ast::path_list_ident {
+        let lo = self.span.lo;
+        let ident = self.parse_ident();
+        let hi = self.last_span.hi;
+        spanned(lo, hi, ast::path_list_ident_ { name: ident,
+                                                id: self.get_id() })
+    }
+
+    // consume token 'tok' if it exists. Returns true if the given
+    // token was present, false otherwise.
+    pub fn eat(&self, tok: &token::Token) -> bool {
+        return if *self.token == *tok { self.bump(); true } else { false };
+    }
+
+    pub fn is_keyword(&self, kw: keywords::Keyword) -> bool {
+        token::is_keyword(kw, self.token)
+    }
+
+    // if the next token is the given keyword, eat it and return
+    // true. Otherwise, return false.
+    pub fn eat_keyword(&self, kw: keywords::Keyword) -> bool {
+        let is_kw = match *self.token {
+            token::IDENT(sid, false) => kw.to_ident().name == sid.name,
+            _ => false
+        };
+        if is_kw { self.bump() }
+        is_kw
+    }
+
+    // if the given word is not a keyword, signal an error.
+    // if the next token is not the given word, signal an error.
+    // otherwise, eat it.
+    pub fn expect_keyword(&self, kw: keywords::Keyword) {
+        if !self.eat_keyword(kw) {
+            self.fatal(
+                fmt!(
+                    "expected `%s`, found `%s`",
+                    self.id_to_str(kw.to_ident()).to_str(),
+                    self.this_token_to_str()
+                )
+            );
+        }
+    }
+
+    // signal an error if the given string is a strict keyword
+    pub fn check_strict_keywords(&self) {
+        if token::is_strict_keyword(self.token) {
+            self.span_err(*self.last_span,
+                          fmt!("found `%s` in ident position", self.this_token_to_str()));
+        }
+    }
+
+    // signal an error if the current token is a reserved keyword
+    pub fn check_reserved_keywords(&self) {
+        if token::is_reserved_keyword(self.token) {
+            self.fatal(fmt!("`%s` is a reserved keyword", self.this_token_to_str()));
+        }
+    }
+
+    // expect and consume a GT. if a >> is seen, replace it
+    // with a single > and continue. If a GT is not seen,
+    // signal an error.
+    pub fn expect_gt(&self) {
+        if *self.token == token::GT {
+            self.bump();
+        } else if *self.token == token::BINOP(token::SHR) {
+            self.replace_token(
+                token::GT,
+                self.span.lo + BytePos(1u),
+                self.span.hi
+            );
+        } else {
+            let mut s: ~str = ~"expected `";
+            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);
+        }
+    }
+
+    // parse a sequence bracketed by '<' and '>', stopping
+    // before the '>'.
+    pub fn parse_seq_to_before_gt<T: Copy>(&self,
+                                           sep: Option<token::Token>,
+                                           f: &fn(&Parser) -> T)
+                                           -> OptVec<T> {
+        let mut first = true;
+        let mut v = opt_vec::Empty;
+        while *self.token != token::GT
+            && *self.token != token::BINOP(token::SHR) {
+            match sep {
+              Some(ref t) => {
+                if first { first = false; }
+                else { self.expect(t); }
+              }
+              _ => ()
+            }
+            v.push(f(self));
+        }
+        return v;
+    }
+
+    pub fn parse_seq_to_gt<T: Copy>(&self,
+                                    sep: Option<token::Token>,
+                                    f: &fn(&Parser) -> T)
+                                    -> OptVec<T> {
+        let v = self.parse_seq_to_before_gt(sep, f);
+        self.expect_gt();
+        return v;
+    }
+
+    // parse a sequence, including the closing delimiter. The function
+    // f must consume tokens until reaching the next separator or
+    // closing bracket.
+    pub fn parse_seq_to_end<T: Copy>(&self,
+                                     ket: &token::Token,
+                                     sep: SeqSep,
+                                     f: &fn(&Parser) -> T)
+                                     -> ~[T] {
+        let val = self.parse_seq_to_before_end(ket, sep, f);
+        self.bump();
+        val
+    }
+
+    // parse a sequence, not including the closing delimiter. The function
+    // f must consume tokens until reaching the next separator or
+    // closing bracket.
+    pub fn parse_seq_to_before_end<T: Copy>(&self,
+                                            ket: &token::Token,
+                                            sep: SeqSep,
+                                            f: &fn(&Parser) -> T)
+                                            -> ~[T] {
+        let mut first: bool = true;
+        let mut v: ~[T] = ~[];
+        while *self.token != *ket {
+            match sep.sep {
+              Some(ref t) => {
+                if first { first = false; }
+                else { self.expect(t); }
+              }
+              _ => ()
+            }
+            if sep.trailing_sep_allowed && *self.token == *ket { break; }
+            v.push(f(self));
+        }
+        return v;
+    }
+
+    // parse a sequence, including the closing delimiter. The function
+    // f must consume tokens until reaching the next separator or
+    // closing bracket.
+    pub fn parse_unspanned_seq<T: Copy>(&self,
+                                        bra: &token::Token,
+                                        ket: &token::Token,
+                                        sep: SeqSep,
+                                        f: &fn(&Parser) -> T)
+                                        -> ~[T] {
+        self.expect(bra);
+        let result = self.parse_seq_to_before_end(ket, sep, f);
+        self.bump();
+        result
+    }
+
+    // NB: Do not use this function unless you actually plan to place the
+    // spanned list in the AST.
+    pub fn parse_seq<T: Copy>(&self,
+                              bra: &token::Token,
+                              ket: &token::Token,
+                              sep: SeqSep,
+                              f: &fn(&Parser) -> T)
+                              -> spanned<~[T]> {
+        let lo = self.span.lo;
+        self.expect(bra);
+        let result = self.parse_seq_to_before_end(ket, sep, f);
+        let hi = self.span.hi;
+        self.bump();
+        spanned(lo, hi, result)
+    }
+
     // advance the parser by one token
     pub fn bump(&self) {
         *self.last_span = copy *self.span;
@@ -821,6 +1072,11 @@ impl Parser {
             self.parse_arg_mode();
             is_mutbl = self.eat_keyword(keywords::Mut);
             let pat = self.parse_pat();
+
+            if is_mutbl && !ast_util::pat_is_ident(pat) {
+                self.obsolete(*self.span, ObsoleteMutWithMultipleBindings)
+            }
+
             self.expect(&token::COLON);
             pat
         } else {
@@ -2437,8 +2693,7 @@ impl Parser {
                 pat = self.parse_pat_ident(bind_by_ref(mutbl));
             } else if self.eat_keyword(keywords::Copy) {
                 // parse copy pat
-                self.warn("copy keyword in patterns no longer has any effect, \
-                           remove it");
+                self.obsolete(*self.span, ObsoletePatternCopyKeyword);
                 pat = self.parse_pat_ident(bind_infer);
             } else {
                 let can_be_enum_or_struct;
@@ -2560,6 +2815,11 @@ impl Parser {
     fn parse_local(&self, is_mutbl: bool) -> @local {
         let lo = self.span.lo;
         let pat = self.parse_pat();
+
+        if is_mutbl && !ast_util::pat_is_ident(pat) {
+            self.obsolete(*self.span, ObsoleteMutWithMultipleBindings)
+        }
+
         let mut ty = @Ty {
             id: self.get_id(),
             node: ty_infer,
@@ -4244,8 +4504,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;
@@ -4420,7 +4684,8 @@ impl Parser {
         let mut attrs = vec::append(first_item_attrs,
                                     self.parse_outer_attributes());
         // First, parse view items.
-        let mut (view_items, items) = (~[], ~[]);
+        let mut view_items = ~[];
+        let mut items = ~[];
         let mut done = false;
         // I think this code would probably read better as a single
         // loop with a mutable three-state-variable (for extern mods,
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 2ddae73a3fc..793626f0e18 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;
 }
 
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs
index af37c1d27d8..3cdc4fd0fa1 100644
--- a/src/libsyntax/util/interner.rs
+++ b/src/libsyntax/util/interner.rs
@@ -21,7 +21,7 @@ pub struct Interner<T> {
 }
 
 // when traits can extend traits, we should extend index<uint,T> to get []
-impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
+impl<T:Eq + IterBytes + Hash + Freeze + Copy> Interner<T> {
     pub fn new() -> Interner<T> {
         Interner {
             map: @mut HashMap::new(),