about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer/comments.rs16
-rw-r--r--src/libsyntax/parse/lexer/mod.rs6
-rw-r--r--src/libsyntax/parse/mod.rs10
-rw-r--r--src/libsyntax/parse/parser.rs60
4 files changed, 49 insertions, 43 deletions
diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs
index c53638ed07d..551d15048f1 100644
--- a/src/libsyntax/parse/lexer/comments.rs
+++ b/src/libsyntax/parse/lexer/comments.rs
@@ -64,21 +64,21 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String {
         let mut j = lines.len();
         // first line of all-stars should be omitted
         if lines.len() > 0 &&
-                lines.get(0).as_slice().chars().all(|c| c == '*') {
+                lines[0].as_slice().chars().all(|c| c == '*') {
             i += 1;
         }
-        while i < j && lines.get(i).as_slice().trim().is_empty() {
+        while i < j && lines[i].as_slice().trim().is_empty() {
             i += 1;
         }
         // like the first, a last line of all stars should be omitted
-        if j > i && lines.get(j - 1)
+        if j > i && lines[j - 1]
                          .as_slice()
                          .chars()
                          .skip(1)
                          .all(|c| c == '*') {
             j -= 1;
         }
-        while j > i && lines.get(j - 1).as_slice().trim().is_empty() {
+        while j > i && lines[j - 1].as_slice().trim().is_empty() {
             j -= 1;
         }
         return lines.slice(i, j).iter().map(|x| (*x).clone()).collect();
@@ -252,7 +252,7 @@ fn read_block_comment(rdr: &mut StringReader,
     // doc-comments are not really comments, they are attributes
     if (rdr.curr_is('*') && !rdr.nextch_is('*')) || rdr.curr_is('!') {
         while !(rdr.curr_is('*') && rdr.nextch_is('/')) && !rdr.is_eof() {
-            curr_line.push_char(rdr.curr.unwrap());
+            curr_line.push(rdr.curr.unwrap());
             rdr.bump();
         }
         if !rdr.is_eof() {
@@ -279,17 +279,17 @@ fn read_block_comment(rdr: &mut StringReader,
                 curr_line = String::new();
                 rdr.bump();
             } else {
-                curr_line.push_char(rdr.curr.unwrap());
+                curr_line.push(rdr.curr.unwrap());
                 if rdr.curr_is('/') && rdr.nextch_is('*') {
                     rdr.bump();
                     rdr.bump();
-                    curr_line.push_char('*');
+                    curr_line.push('*');
                     level += 1;
                 } else {
                     if rdr.curr_is('*') && rdr.nextch_is('/') {
                         rdr.bump();
                         rdr.bump();
-                        curr_line.push_char('/');
+                        curr_line.push('/');
                         level -= 1;
                     } else { rdr.bump(); }
                 }
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs
index 38c985af370..55d071b8d60 100644
--- a/src/libsyntax/parse/lexer/mod.rs
+++ b/src/libsyntax/parse/lexer/mod.rs
@@ -180,7 +180,7 @@ impl<'a> StringReader<'a> {
     fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) -> ! {
         let mut m = m.to_string();
         m.push_str(": ");
-        char::escape_default(c, |c| m.push_char(c));
+        char::escape_default(c, |c| m.push(c));
         self.fatal_span_(from_pos, to_pos, m.as_slice());
     }
 
@@ -189,7 +189,7 @@ impl<'a> StringReader<'a> {
     fn err_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) {
         let mut m = m.to_string();
         m.push_str(": ");
-        char::escape_default(c, |c| m.push_char(c));
+        char::escape_default(c, |c| m.push(c));
         self.err_span_(from_pos, to_pos, m.as_slice());
     }
 
@@ -1227,7 +1227,7 @@ impl<'a> StringReader<'a> {
     fn read_to_eol(&mut self) -> String {
         let mut val = String::new();
         while !self.curr_is('\n') && !self.is_eof() {
-            val.push_char(self.curr.unwrap());
+            val.push(self.curr.unwrap());
             self.bump();
         }
         if self.curr_is('\n') { self.bump(); }
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index c4a8775a012..f1baccfcd80 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -455,7 +455,7 @@ pub fn str_lit(lit: &str) -> String {
                             for _ in range(0, n - 1) { // we don't need to move past the first \
                                 chars.next();
                             }
-                            res.push_char(c);
+                            res.push(c);
                         }
                     },
                     '\r' => {
@@ -467,9 +467,9 @@ pub fn str_lit(lit: &str) -> String {
                             fail!("lexer accepted bare CR");
                         }
                         chars.next();
-                        res.push_char('\n');
+                        res.push('\n');
                     }
-                    c => res.push_char(c),
+                    c => res.push(c),
                 }
             },
             None => break
@@ -497,9 +497,9 @@ pub fn raw_str_lit(lit: &str) -> String {
                         fail!("lexer accepted bare CR");
                     }
                     chars.next();
-                    res.push_char('\n');
+                    res.push('\n');
                 } else {
-                    res.push_char(c);
+                    res.push(c);
                 }
             },
             None => break
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 17f52bc21c5..abab816bfeb 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -281,12 +281,13 @@ macro_rules! maybe_whole (
 )
 
 
-fn maybe_append(lhs: Vec<Attribute> , rhs: Option<Vec<Attribute> >)
-             -> Vec<Attribute> {
+fn maybe_append(mut lhs: Vec<Attribute>, rhs: Option<Vec<Attribute>>)
+                -> Vec<Attribute> {
     match rhs {
-        None => lhs,
-        Some(ref attrs) => lhs.append(attrs.as_slice())
+        Some(ref attrs) => lhs.extend(attrs.iter().map(|a| a.clone())),
+        None => {}
     }
+    lhs
 }
 
 
@@ -452,7 +453,8 @@ impl<'a> Parser<'a> {
         } else if inedible.contains(&self.token) {
             // leave it in the input
         } else {
-            let expected = edible.iter().map(|x| (*x).clone()).collect::<Vec<_>>().append(inedible);
+            let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>();
+            expected.push_all(inedible);
             let expect = tokens_to_string(expected.as_slice());
             let actual = self.this_token_to_string();
             self.fatal(
@@ -496,8 +498,8 @@ impl<'a> Parser<'a> {
         match e.node {
             ExprPath(..) => {
                 // might be unit-struct construction; check for recoverableinput error.
-                let expected = edible.iter().map(|x| (*x).clone()).collect::<Vec<_>>()
-                              .append(inedible);
+                let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>();
+                expected.push_all(inedible);
                 self.check_for_erroneous_unit_struct_expecting(
                     expected.as_slice());
             }
@@ -517,8 +519,8 @@ impl<'a> Parser<'a> {
         if self.last_token
                .as_ref()
                .map_or(false, |t| is_ident_or_path(&**t)) {
-            let expected = edible.iter().map(|x| (*x).clone()).collect::<Vec<_>>()
-                           .append(inedible.as_slice());
+            let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>();
+            expected.push_all(inedible.as_slice());
             self.check_for_erroneous_unit_struct_expecting(
                 expected.as_slice());
         }
@@ -1335,7 +1337,8 @@ impl<'a> Parser<'a> {
                     debug!("parse_trait_methods(): parsing provided method");
                     let (inner_attrs, body) =
                         p.parse_inner_attrs_and_block();
-                    let attrs = attrs.append(inner_attrs.as_slice());
+                    let mut attrs = attrs;
+                    attrs.push_all(inner_attrs.as_slice());
                     ProvidedMethod(P(ast::Method {
                         attrs: attrs,
                         id: ast::DUMMY_NODE_ID,
@@ -2119,7 +2122,7 @@ impl<'a> Parser<'a> {
                             |p| p.parse_expr()
                                 );
                         let mut exprs = vec!(first_expr);
-                        exprs.push_all_move(remaining_exprs);
+                        exprs.extend(remaining_exprs.into_iter());
                         ex = ExprVec(exprs);
                     } else {
                         // Vector with one element.
@@ -2337,7 +2340,7 @@ impl<'a> Parser<'a> {
                             );
                             hi = self.last_span.hi;
 
-                            es.unshift(e);
+                            es.insert(0, e);
                             let id = spanned(dot, hi, i);
                             let nd = self.mk_method_call(id, tys, es);
                             e = self.mk_expr(lo, hi, nd);
@@ -2600,7 +2603,7 @@ impl<'a> Parser<'a> {
                     self.parse_seq_to_before_end(&close_delim,
                                                  seq_sep_none(),
                                                  |p| p.parse_token_tree());
-                result.push_all_move(trees);
+                result.extend(trees.into_iter());
 
                 // Parse the close delimiter.
                 result.push(parse_any_tt_tok(self));
@@ -3380,12 +3383,10 @@ impl<'a> Parser<'a> {
                           _ => {
                               if !enum_path.global &&
                                     enum_path.segments.len() == 1 &&
-                                    enum_path.segments
-                                             .get(0)
+                                    enum_path.segments[0]
                                              .lifetimes
                                              .len() == 0 &&
-                                    enum_path.segments
-                                             .get(0)
+                                    enum_path.segments[0]
                                              .types
                                              .len() == 0 {
                                   // it could still be either an enum
@@ -3394,7 +3395,7 @@ impl<'a> Parser<'a> {
                                   pat = PatIdent(BindByValue(MutImmutable),
                                                  codemap::Spanned{
                                                     span: enum_path.span,
-                                                    node: enum_path.segments.get(0)
+                                                    node: enum_path.segments[0]
                                                            .identifier},
                                                  None);
                               } else {
@@ -4256,7 +4257,7 @@ impl<'a> Parser<'a> {
                         sep,
                         parse_arg_fn
                     );
-                    fn_inputs.unshift(Arg::new_self(explicit_self_sp, mutbl_self, $self_id));
+                    fn_inputs.insert(0, Arg::new_self(explicit_self_sp, mutbl_self, $self_id));
                     fn_inputs
                 }
                 token::RPAREN => {
@@ -4449,7 +4450,8 @@ impl<'a> Parser<'a> {
                 self.parse_where_clause(&mut generics);
                 let (inner_attrs, body) = self.parse_inner_attrs_and_block();
                 let body_span = body.span;
-                let new_attrs = attrs.append(inner_attrs.as_slice());
+                let mut new_attrs = attrs;
+                new_attrs.push_all(inner_attrs.as_slice());
                 (ast::MethDecl(ident,
                                generics,
                                abi,
@@ -4490,7 +4492,7 @@ impl<'a> Parser<'a> {
         let (inner_attrs, mut method_attrs) =
             self.parse_inner_attrs_and_next();
         while !self.eat(&token::RBRACE) {
-            method_attrs.push_all_move(self.parse_outer_attributes());
+            method_attrs.extend(self.parse_outer_attributes().into_iter());
             let vis = self.parse_visibility();
             if self.eat_keyword(keywords::Type) {
                 impl_items.push(TypeImplItem(P(self.parse_typedef(
@@ -4711,7 +4713,9 @@ impl<'a> Parser<'a> {
         while self.token != term {
             let mut attrs = self.parse_outer_attributes();
             if first {
-                attrs = attrs_remaining.clone().append(attrs.as_slice());
+                let mut tmp = attrs_remaining.clone();
+                tmp.push_all(attrs.as_slice());
+                attrs = tmp;
                 first = false;
             }
             debug!("parse_mod_items: parse_item_or_view_item(attrs={})",
@@ -4826,7 +4830,7 @@ impl<'a> Parser<'a> {
                                   "cannot declare a new module at this location");
                     let this_module = match self.mod_path_stack.last() {
                         Some(name) => name.get().to_string(),
-                        None => self.root_module_name.get_ref().clone(),
+                        None => self.root_module_name.as_ref().unwrap().clone(),
                     };
                     self.span_note(id_sp,
                                    format!("maybe move this module `{0}` \
@@ -5536,7 +5540,7 @@ impl<'a> Parser<'a> {
             } else {
                 s.push_str("priv")
             }
-            s.push_char('`');
+            s.push('`');
             let last_span = self.last_span;
             self.span_fatal(last_span, s.as_slice());
         }
@@ -5677,7 +5681,7 @@ impl<'a> Parser<'a> {
           }
           _ => ()
         }
-        let mut rename_to = *path.get(path.len() - 1u);
+        let mut rename_to = path[path.len() - 1u];
         let path = ast::Path {
             span: mk_sp(lo, self.span.hi),
             global: false,
@@ -5705,7 +5709,8 @@ impl<'a> Parser<'a> {
                                   mut extern_mod_allowed: bool,
                                   macros_allowed: bool)
                                   -> ParsedItemsAndViewItems {
-        let mut attrs = first_item_attrs.append(self.parse_outer_attributes().as_slice());
+        let mut attrs = first_item_attrs;
+        attrs.push_all(self.parse_outer_attributes().as_slice());
         // First, parse view items.
         let mut view_items : Vec<ast::ViewItem> = Vec::new();
         let mut items = Vec::new();
@@ -5786,7 +5791,8 @@ impl<'a> Parser<'a> {
     fn parse_foreign_items(&mut self, first_item_attrs: Vec<Attribute> ,
                            macros_allowed: bool)
         -> ParsedItemsAndViewItems {
-        let mut attrs = first_item_attrs.append(self.parse_outer_attributes().as_slice());
+        let mut attrs = first_item_attrs;
+        attrs.push_all(self.parse_outer_attributes().as_slice());
         let mut foreign_items = Vec::new();
         loop {
             match self.parse_foreign_item(attrs, macros_allowed) {