about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-05-14 10:10:54 -0700
committerbors <bors@rust-lang.org>2013-05-14 10:10:54 -0700
commit767e3ae86cba26437a60009d79ac2a295b41768e (patch)
tree8f3f8634548c02309d281d6cdbfd7b34b7ea8c9d /src/libsyntax/parse
parent27c228fad7d94a500866696f8c48ef1707a2507b (diff)
parentffcc680f9cc26b5b2cb2f453a89dbcf8144f8b9b (diff)
downloadrust-767e3ae86cba26437a60009d79ac2a295b41768e.tar.gz
rust-767e3ae86cba26437a60009d79ac2a295b41768e.zip
auto merge of #6434 : alexcrichton/rust/less-implicit-vecs, r=bstrie
This closes #5204 and #6421.

This also removes the `vecs_implicitly_copyable` lint (although now reading #6421, this may not be desired?). If we want to leave it in, it at least removes it from the compiler.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/comments.rs2
-rw-r--r--src/libsyntax/parse/mod.rs13
-rw-r--r--src/libsyntax/parse/obsolete.rs14
-rw-r--r--src/libsyntax/parse/parser.rs41
4 files changed, 36 insertions, 34 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 8faba022a90..fa91b968f69 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -192,7 +192,7 @@ fn read_line_comments(rdr: @mut StringReader, code_to_the_left: bool,
 
 // FIXME #3961: This is not the right way to convert string byte
 // offsets to characters.
-fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool {
+fn all_whitespace(s: &str, begin: uint, end: uint) -> bool {
     let mut i: uint = begin;
     while i != end {
         if !is_whitespace(s[i] as char) { return false; } i += 1u;
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index bbd93b71d36..9a8a6620652 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -351,15 +351,14 @@ mod test {
     use core::option::None;
     use core::int;
     use core::num::NumCast;
-    use core::path::Path;
-    use codemap::{dummy_sp, CodeMap, span, BytePos, spanned};
+    use codemap::{CodeMap, span, BytePos, spanned};
     use opt_vec;
     use ast;
     use abi;
     use ast_util::mk_ident;
     use parse::parser::Parser;
-    use parse::token::{ident_interner, mk_ident_interner, mk_fresh_ident_interner};
-    use diagnostic::{span_handler, mk_span_handler, mk_handler, Emitter};
+    use parse::token::{ident_interner, mk_fresh_ident_interner};
+    use diagnostic::{mk_span_handler, mk_handler};
 
     // add known names to interner for testing
     fn mk_testing_interner() -> @ident_interner {
@@ -408,7 +407,7 @@ mod test {
 
     // map a string to tts, return the tt without its parsesess
     fn string_to_tts_only(source_str : @~str) -> ~[ast::token_tree] {
-        let (tts,ps) = string_to_tts_t(source_str);
+        let (tts,_ps) = string_to_tts_t(source_str);
         tts
     }
 
@@ -483,7 +482,7 @@ mod test {
     }*/
 
     #[test] fn string_to_tts_1 () {
-        let (tts,ps) = string_to_tts_t(@~"fn a (b : int) { b; }");
+        let (tts,_ps) = string_to_tts_t(@~"fn a (b : int) { b; }");
         assert_eq!(to_json_str(@tts),
                    ~"[\
                 [\"tt_tok\",null,[\"IDENT\",\"fn\",false]],\
@@ -548,7 +547,7 @@ mod test {
     }
 
     fn parser_done(p: Parser){
-        assert_eq!(*p.token,token::EOF);
+        assert_eq!(copy *p.token,token::EOF);
     }
 
     #[test] fn parse_ident_pat () {
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 3e64133e893..211d123e887 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -253,9 +253,9 @@ pub impl Parser {
         }
     }
 
-    fn token_is_obsolete_ident(&self, ident: &str, token: Token) -> bool {
-        match token {
-            token::IDENT(copy sid, _) => {
+    fn token_is_obsolete_ident(&self, ident: &str, token: &Token) -> bool {
+        match *token {
+            token::IDENT(sid, _) => {
                 str::eq_slice(*self.id_to_str(sid), ident)
             }
             _ => false
@@ -263,7 +263,7 @@ pub impl Parser {
     }
 
     fn is_obsolete_ident(&self, ident: &str) -> bool {
-        self.token_is_obsolete_ident(ident, *self.token)
+        self.token_is_obsolete_ident(ident, self.token)
     }
 
     fn eat_obsolete_ident(&self, ident: &str) -> bool {
@@ -289,7 +289,7 @@ pub impl Parser {
     fn try_parse_obsolete_with(&self) -> bool {
         if *self.token == token::COMMA
             && self.token_is_obsolete_ident("with",
-                                            self.look_ahead(1u)) {
+                                            &self.look_ahead(1u)) {
             self.bump();
         }
         if self.eat_obsolete_ident("with") {
@@ -301,13 +301,13 @@ pub impl Parser {
         }
     }
 
-    fn try_parse_obsolete_priv_section(&self, attrs: ~[attribute]) -> bool {
+    fn try_parse_obsolete_priv_section(&self, attrs: &[attribute]) -> bool {
         if self.is_keyword(&~"priv") && self.look_ahead(1) == token::LBRACE {
             self.obsolete(copy *self.span, ObsoletePrivSection);
             self.eat_keyword(&~"priv");
             self.bump();
             while *self.token != token::RBRACE {
-                self.parse_single_struct_field(ast::private, attrs);
+                self.parse_single_struct_field(ast::private, attrs.to_owned());
             }
             self.bump();
             true
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index b35ae169e1a..e1fe20695c7 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -708,7 +708,7 @@ pub impl Parser {
             self.obsolete(*self.last_span, ObsoleteBareFnType);
             result
         } else if *self.token == token::MOD_SEP
-            || is_ident_or_path(&*self.token) {
+            || is_ident_or_path(self.token) {
             // NAMED TYPE
             let path = self.parse_path_with_tps(false);
             ty_path(path, self.get_id())
@@ -1556,9 +1556,12 @@ pub impl Parser {
                         |p| p.parse_token_tree()
                     );
                     let (s, z) = p.parse_sep_and_zerok();
+                    let seq = match seq {
+                        spanned { node, _ } => node,
+                    };
                     tt_seq(
-                        mk_sp(sp.lo ,p.span.hi),
-                        seq.node,
+                        mk_sp(sp.lo, p.span.hi),
+                        seq,
                         s,
                         z
                     )
@@ -1624,9 +1627,9 @@ pub impl Parser {
             token::LBRACE | token::LPAREN | token::LBRACKET => {
                 self.parse_matcher_subseq(
                     name_idx,
-                    *self.token,
+                    copy *self.token,
                     // tjc: not sure why we need a copy
-                    token::flip_delimiter(&*self.token)
+                    token::flip_delimiter(self.token)
                 )
             }
             _ => self.fatal(~"expected open delimiter")
@@ -1986,14 +1989,15 @@ pub impl Parser {
         // them as the lambda arguments
         let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP);
         match e.node {
-            expr_call(f, args, NoSugar) => {
+            expr_call(f, /*bad*/ copy args, NoSugar) => {
                 let block = self.parse_lambda_block_expr();
                 let last_arg = self.mk_expr(block.span.lo, block.span.hi,
                                             ctor(block));
                 let args = vec::append(args, ~[last_arg]);
                 self.mk_expr(lo.lo, block.span.hi, expr_call(f, args, sugar))
             }
-            expr_method_call(f, i, tps, args, NoSugar) => {
+            expr_method_call(f, i, /*bad*/ copy tps,
+                             /*bad*/ copy args, NoSugar) => {
                 let block = self.parse_lambda_block_expr();
                 let last_arg = self.mk_expr(block.span.lo, block.span.hi,
                                             ctor(block));
@@ -2001,7 +2005,7 @@ pub impl Parser {
                 self.mk_expr(lo.lo, block.span.hi,
                              expr_method_call(f, i, tps, args, sugar))
             }
-            expr_field(f, i, tps) => {
+            expr_field(f, i, /*bad*/ copy tps) => {
                 let block = self.parse_lambda_block_expr();
                 let last_arg = self.mk_expr(block.span.lo, block.span.hi,
                                             ctor(block));
@@ -2259,7 +2263,7 @@ pub impl Parser {
         let lo = self.span.lo;
         let mut hi = self.span.hi;
         let pat;
-        match *self.token {
+        match /*bad*/ copy *self.token {
             // parse _
           token::UNDERSCORE => { self.bump(); pat = pat_wild; }
             // parse @pat
@@ -2373,8 +2377,8 @@ pub impl Parser {
             self.expect(&token::RBRACKET);
             pat = ast::pat_vec(before, slice, after);
           }
-          tok => {
-            if !is_ident_or_path(&tok)
+          ref tok => {
+            if !is_ident_or_path(tok)
                 || self.is_keyword(&~"true")
                 || self.is_keyword(&~"false")
             {
@@ -2384,7 +2388,7 @@ pub impl Parser {
                 // preceded by unary-minus) or identifiers.
                 let val = self.parse_literal_maybe_minus();
                 if self.eat(&token::DOTDOT) {
-                    let end = if is_ident_or_path(&tok) {
+                    let end = if is_ident_or_path(tok) {
                         let path = self.parse_path_with_tps(true);
                         let hi = self.span.hi;
                         self.mk_expr(lo, hi, expr_path(path))
@@ -2897,7 +2901,7 @@ pub impl Parser {
                 loop;
             }
 
-            if is_ident_or_path(&*self.token) {
+            if is_ident_or_path(self.token) {
                 self.obsolete(*self.span,
                               ObsoleteTraitBoundSeparator);
             }
@@ -3531,6 +3535,7 @@ pub impl Parser {
     fn parse_item_mod(&self, outer_attrs: ~[ast::attribute]) -> item_info {
         let id_span = *self.span;
         let id = self.parse_ident();
+        let merge = ::attr::first_attr_value_str_by_name(outer_attrs, "merge");
         let info_ = if *self.token == token::SEMI {
             self.bump();
             // This mod is in an external file. Let's go get it!
@@ -3550,7 +3555,7 @@ pub impl Parser {
         // (int-template, iter-trait). If there's a 'merge' attribute
         // on the mod, then we'll go and suck in another file and merge
         // its contents
-        match ::attr::first_attr_value_str_by_name(outer_attrs, ~"merge") {
+        match merge {
             Some(path) => {
                 let prefix = Path(
                     self.sess.cm.span_to_filename(*self.span));
@@ -3636,10 +3641,7 @@ pub impl Parser {
             new_sub_parser_from_file(self.sess, copy self.cfg,
                                      &full_path, id_sp);
         let (inner, next) = p0.parse_inner_attrs_and_next();
-        let mod_attrs = vec::append(
-            /*bad*/ copy outer_attrs,
-            inner
-        );
+        let mod_attrs = vec::append(outer_attrs, inner);
         let first_item_outer_attrs = next;
         let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
         return (ast::item_mod(m0), mod_attrs);
@@ -4105,7 +4107,8 @@ pub impl Parser {
         }
         if self.eat_keyword(&~"mod") {
             // MODULE ITEM
-            let (ident, item_, extra_attrs) = self.parse_item_mod(attrs);
+            let (ident, item_, extra_attrs) =
+                self.parse_item_mod(/*bad*/ copy attrs);
             return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_,
                                           visibility,
                                           maybe_append(attrs, extra_attrs)));