about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-02 08:31:33 -0800
committerbors <bors@rust-lang.org>2014-03-02 08:31:33 -0800
commit910012aabae3dfd4b7190f46e88cde75804b5cb0 (patch)
treeac07696b5bb7a8ba6dacd1b2abd3926b59621058 /src/libsyntax/parse
parentbaf79083aedb8ae64efddbcf28b358841cfd1157 (diff)
parent355932407ba324d33cd9353a69203f7f76c059a6 (diff)
downloadrust-910012aabae3dfd4b7190f46e88cde75804b5cb0.tar.gz
rust-910012aabae3dfd4b7190f46e88cde75804b5cb0.zip
auto merge of #12637 : pcwalton/rust/devecing, r=alexcrichton
r? @alexcrichton
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/attr.rs26
-rw-r--r--src/libsyntax/parse/comments.rs47
-rw-r--r--src/libsyntax/parse/lexer.rs19
-rw-r--r--src/libsyntax/parse/mod.rs77
-rw-r--r--src/libsyntax/parse/parser.rs293
-rw-r--r--src/libsyntax/parse/token.rs15
6 files changed, 250 insertions, 227 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index c9bea78d02d..0a74c7ca821 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -15,21 +15,23 @@ use parse::token;
 use parse::parser::Parser;
 use parse::token::INTERPOLATED;
 
+use std::vec_ng::Vec;
+
 // a parser that can parse attributes.
 pub trait ParserAttr {
-    fn parse_outer_attributes(&mut self) -> ~[ast::Attribute];
+    fn parse_outer_attributes(&mut self) -> Vec<ast::Attribute> ;
     fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute;
     fn parse_inner_attrs_and_next(&mut self)
-                                  -> (~[ast::Attribute], ~[ast::Attribute]);
+                                  -> (Vec<ast::Attribute> , Vec<ast::Attribute> );
     fn parse_meta_item(&mut self) -> @ast::MetaItem;
-    fn parse_meta_seq(&mut self) -> ~[@ast::MetaItem];
-    fn parse_optional_meta(&mut self) -> ~[@ast::MetaItem];
+    fn parse_meta_seq(&mut self) -> Vec<@ast::MetaItem> ;
+    fn parse_optional_meta(&mut self) -> Vec<@ast::MetaItem> ;
 }
 
 impl ParserAttr for Parser {
     // Parse attributes that appear before an item
-    fn parse_outer_attributes(&mut self) -> ~[ast::Attribute] {
-        let mut attrs: ~[ast::Attribute] = ~[];
+    fn parse_outer_attributes(&mut self) -> Vec<ast::Attribute> {
+        let mut attrs: Vec<ast::Attribute> = Vec::new();
         loop {
             debug!("parse_outer_attributes: self.token={:?}",
                    self.token);
@@ -116,9 +118,9 @@ impl ParserAttr for Parser {
     // you can make the 'next' field an Option, but the result is going to be
     // more useful as a vector.
     fn parse_inner_attrs_and_next(&mut self)
-                                  -> (~[ast::Attribute], ~[ast::Attribute]) {
-        let mut inner_attrs: ~[ast::Attribute] = ~[];
-        let mut next_outer_attrs: ~[ast::Attribute] = ~[];
+                                  -> (Vec<ast::Attribute> , Vec<ast::Attribute> ) {
+        let mut inner_attrs: Vec<ast::Attribute> = Vec::new();
+        let mut next_outer_attrs: Vec<ast::Attribute> = Vec::new();
         loop {
             let attr = match self.token {
                 token::INTERPOLATED(token::NtAttr(..)) => {
@@ -188,17 +190,17 @@ impl ParserAttr for Parser {
     }
 
     // matches meta_seq = ( COMMASEP(meta_item) )
-    fn parse_meta_seq(&mut self) -> ~[@ast::MetaItem] {
+    fn parse_meta_seq(&mut self) -> Vec<@ast::MetaItem> {
         self.parse_seq(&token::LPAREN,
                        &token::RPAREN,
                        seq_sep_trailing_disallowed(token::COMMA),
                        |p| p.parse_meta_item()).node
     }
 
-    fn parse_optional_meta(&mut self) -> ~[@ast::MetaItem] {
+    fn parse_optional_meta(&mut self) -> Vec<@ast::MetaItem> {
         match self.token {
             token::LPAREN => self.parse_meta_seq(),
-            _ => ~[]
+            _ => Vec::new()
         }
     }
 }
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index bd1c4f9babb..c2a2097de24 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -20,6 +20,7 @@ use parse::token;
 use std::io;
 use std::str;
 use std::uint;
+use std::vec_ng::Vec;
 
 #[deriving(Clone, Eq)]
 pub enum CommentStyle {
@@ -32,7 +33,7 @@ pub enum CommentStyle {
 #[deriving(Clone)]
 pub struct Comment {
     style: CommentStyle,
-    lines: ~[~str],
+    lines: Vec<~str> ,
     pos: BytePos
 }
 
@@ -54,28 +55,28 @@ pub fn doc_comment_style(comment: &str) -> ast::AttrStyle {
 
 pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
     /// remove whitespace-only lines from the start/end of lines
-    fn vertical_trim(lines: ~[~str]) -> ~[~str] {
+    fn vertical_trim(lines: Vec<~str> ) -> Vec<~str> {
         let mut i = 0u;
         let mut j = lines.len();
         // first line of all-stars should be omitted
-        if lines.len() > 0 && lines[0].chars().all(|c| c == '*') {
+        if lines.len() > 0 && lines.get(0).chars().all(|c| c == '*') {
             i += 1;
         }
-        while i < j && lines[i].trim().is_empty() {
+        while i < j && lines.get(i).trim().is_empty() {
             i += 1;
         }
         // like the first, a last line of all stars should be omitted
-        if j > i && lines[j - 1].chars().skip(1).all(|c| c == '*') {
+        if j > i && lines.get(j - 1).chars().skip(1).all(|c| c == '*') {
             j -= 1;
         }
-        while j > i && lines[j - 1].trim().is_empty() {
+        while j > i && lines.get(j - 1).trim().is_empty() {
             j -= 1;
         }
-        return lines.slice(i, j).to_owned();
+        return lines.slice(i, j).iter().map(|x| (*x).clone()).collect();
     }
 
     /// remove a "[ \t]*\*" block from each line, if possible
-    fn horizontal_trim(lines: ~[~str]) -> ~[~str] {
+    fn horizontal_trim(lines: Vec<~str> ) -> Vec<~str> {
         let mut i = uint::MAX;
         let mut can_trim = true;
         let mut first = true;
@@ -122,7 +123,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
         let lines = comment.slice(3u, comment.len() - 2u)
             .lines_any()
             .map(|s| s.to_owned())
-            .collect::<~[~str]>();
+            .collect::<Vec<~str> >();
 
         let lines = vertical_trim(lines);
         let lines = horizontal_trim(lines);
@@ -157,9 +158,9 @@ fn consume_non_eol_whitespace(rdr: &StringReader) {
     }
 }
 
-fn push_blank_line_comment(rdr: &StringReader, comments: &mut ~[Comment]) {
+fn push_blank_line_comment(rdr: &StringReader, comments: &mut Vec<Comment> ) {
     debug!(">>> blank-line comment");
-    let v: ~[~str] = ~[];
+    let v: Vec<~str> = Vec::new();
     comments.push(Comment {
         style: BlankLine,
         lines: v,
@@ -168,7 +169,7 @@ fn push_blank_line_comment(rdr: &StringReader, comments: &mut ~[Comment]) {
 }
 
 fn consume_whitespace_counting_blank_lines(rdr: &StringReader,
-                                           comments: &mut ~[Comment]) {
+                                           comments: &mut Vec<Comment> ) {
     while is_whitespace(rdr.curr.get()) && !is_eof(rdr) {
         if rdr.col.get() == CharPos(0u) && rdr.curr_is('\n') {
             push_blank_line_comment(rdr, &mut *comments);
@@ -179,22 +180,22 @@ fn consume_whitespace_counting_blank_lines(rdr: &StringReader,
 
 
 fn read_shebang_comment(rdr: &StringReader, code_to_the_left: bool,
-                                            comments: &mut ~[Comment]) {
+                                            comments: &mut Vec<Comment> ) {
     debug!(">>> shebang comment");
     let p = rdr.last_pos.get();
     debug!("<<< shebang comment");
     comments.push(Comment {
         style: if code_to_the_left { Trailing } else { Isolated },
-        lines: ~[read_one_line_comment(rdr)],
+        lines: vec!(read_one_line_comment(rdr)),
         pos: p
     });
 }
 
 fn read_line_comments(rdr: &StringReader, code_to_the_left: bool,
-                                          comments: &mut ~[Comment]) {
+                                          comments: &mut Vec<Comment> ) {
     debug!(">>> line comments");
     let p = rdr.last_pos.get();
-    let mut lines: ~[~str] = ~[];
+    let mut lines: Vec<~str> = Vec::new();
     while rdr.curr_is('/') && nextch_is(rdr, '/') {
         let line = read_one_line_comment(rdr);
         debug!("{}", line);
@@ -232,7 +233,7 @@ fn all_whitespace(s: &str, col: CharPos) -> Option<uint> {
     return Some(cursor);
 }
 
-fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
+fn trim_whitespace_prefix_and_push_line(lines: &mut Vec<~str> ,
                                         s: ~str, col: CharPos) {
     let len = s.len();
     let s1 = match all_whitespace(s, col) {
@@ -249,10 +250,10 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
 
 fn read_block_comment(rdr: &StringReader,
                       code_to_the_left: bool,
-                      comments: &mut ~[Comment]) {
+                      comments: &mut Vec<Comment> ) {
     debug!(">>> block comment");
     let p = rdr.last_pos.get();
-    let mut lines: ~[~str] = ~[];
+    let mut lines: Vec<~str> = Vec::new();
     let col: CharPos = rdr.col.get();
     bump(rdr);
     bump(rdr);
@@ -324,7 +325,7 @@ fn peeking_at_comment(rdr: &StringReader) -> bool {
 
 fn consume_comment(rdr: &StringReader,
                    code_to_the_left: bool,
-                   comments: &mut ~[Comment]) {
+                   comments: &mut Vec<Comment> ) {
     debug!(">>> consume comment");
     if rdr.curr_is('/') && nextch_is(rdr, '/') {
         read_line_comments(rdr, code_to_the_left, comments);
@@ -348,15 +349,15 @@ pub fn gather_comments_and_literals(span_diagnostic:
                                         @diagnostic::SpanHandler,
                                     path: ~str,
                                     srdr: &mut io::Reader)
-                                 -> (~[Comment], ~[Literal]) {
+                                 -> (Vec<Comment> , Vec<Literal> ) {
     let src = srdr.read_to_end().unwrap();
     let src = str::from_utf8_owned(src).unwrap();
     let cm = CodeMap::new();
     let filemap = cm.new_filemap(path, src);
     let rdr = lexer::new_low_level_string_reader(span_diagnostic, filemap);
 
-    let mut comments: ~[Comment] = ~[];
-    let mut literals: ~[Literal] = ~[];
+    let mut comments: Vec<Comment> = Vec::new();
+    let mut literals: Vec<Literal> = Vec::new();
     let mut first_read: bool = true;
     while !is_eof(&rdr) {
         loop {
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 87706df5e31..884fc306f22 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -1005,6 +1005,7 @@ mod test {
     use parse::token;
     use parse::token::{str_to_ident};
     use std::io::util;
+    use std::vec_ng::Vec;
 
     // represents a testing reader (incl. both reader and interner)
     struct Env {
@@ -1048,7 +1049,7 @@ mod test {
 
     // check that the given reader produces the desired stream
     // of tokens (stop checking after exhausting the expected vec)
-    fn check_tokenization (env: Env, expected: ~[token::Token]) {
+    fn check_tokenization (env: Env, expected: Vec<token::Token> ) {
         for expected_tok in expected.iter() {
             let TokenAndSpan {tok:actual_tok, sp: _} =
                 env.string_reader.next_token();
@@ -1064,32 +1065,32 @@ mod test {
     #[test] fn doublecolonparsing () {
         let env = setup (~"a b");
         check_tokenization (env,
-                           ~[mk_ident("a",false),
-                             mk_ident("b",false)]);
+                           vec!(mk_ident("a",false),
+                             mk_ident("b",false)));
     }
 
     #[test] fn dcparsing_2 () {
         let env = setup (~"a::b");
         check_tokenization (env,
-                           ~[mk_ident("a",true),
+                           vec!(mk_ident("a",true),
                              token::MOD_SEP,
-                             mk_ident("b",false)]);
+                             mk_ident("b",false)));
     }
 
     #[test] fn dcparsing_3 () {
         let env = setup (~"a ::b");
         check_tokenization (env,
-                           ~[mk_ident("a",false),
+                           vec!(mk_ident("a",false),
                              token::MOD_SEP,
-                             mk_ident("b",false)]);
+                             mk_ident("b",false)));
     }
 
     #[test] fn dcparsing_4 () {
         let env = setup (~"a:: b");
         check_tokenization (env,
-                           ~[mk_ident("a",true),
+                           vec!(mk_ident("a",true),
                              token::MOD_SEP,
-                             mk_ident("b",false)]);
+                             mk_ident("b",false)));
     }
 
     #[test] fn character_a() {
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 8f45f911484..9e5db1770bf 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -21,6 +21,7 @@ use parse::parser::Parser;
 use std::cell::RefCell;
 use std::io::File;
 use std::str;
+use std::vec_ng::Vec;
 
 pub mod lexer;
 pub mod parser;
@@ -42,7 +43,7 @@ pub struct ParseSess {
     cm: @codemap::CodeMap, // better be the same as the one in the reader!
     span_diagnostic: @SpanHandler, // better be the same as the one in the reader!
     /// Used to determine and report recursive mod inclusions
-    included_mod_stack: RefCell<~[Path]>,
+    included_mod_stack: RefCell<Vec<Path> >,
 }
 
 pub fn new_parse_sess() -> @ParseSess {
@@ -50,7 +51,7 @@ pub fn new_parse_sess() -> @ParseSess {
     @ParseSess {
         cm: cm,
         span_diagnostic: mk_span_handler(default_handler(), cm),
-        included_mod_stack: RefCell::new(~[]),
+        included_mod_stack: RefCell::new(Vec::new()),
     }
 }
 
@@ -60,7 +61,7 @@ pub fn new_parse_sess_special_handler(sh: @SpanHandler,
     @ParseSess {
         cm: cm,
         span_diagnostic: sh,
-        included_mod_stack: RefCell::new(~[]),
+        included_mod_stack: RefCell::new(Vec::new()),
     }
 }
 
@@ -82,7 +83,7 @@ pub fn parse_crate_attrs_from_file(
     input: &Path,
     cfg: ast::CrateConfig,
     sess: @ParseSess
-) -> ~[ast::Attribute] {
+) -> Vec<ast::Attribute> {
     let mut parser = new_parser_from_file(sess, cfg, input);
     let (inner, _) = parser.parse_inner_attrs_and_next();
     return inner;
@@ -104,7 +105,7 @@ pub fn parse_crate_attrs_from_source_str(name: ~str,
                                          source: ~str,
                                          cfg: ast::CrateConfig,
                                          sess: @ParseSess)
-                                         -> ~[ast::Attribute] {
+                                         -> Vec<ast::Attribute> {
     let mut p = new_parser_from_source_str(sess,
                                            cfg,
                                            name,
@@ -144,7 +145,7 @@ pub fn parse_meta_from_source_str(name: ~str,
 pub fn parse_stmt_from_source_str(name: ~str,
                                   source: ~str,
                                   cfg: ast::CrateConfig,
-                                  attrs: ~[ast::Attribute],
+                                  attrs: Vec<ast::Attribute> ,
                                   sess: @ParseSess)
                                   -> @ast::Stmt {
     let mut p = new_parser_from_source_str(
@@ -160,7 +161,7 @@ pub fn parse_tts_from_source_str(name: ~str,
                                  source: ~str,
                                  cfg: ast::CrateConfig,
                                  sess: @ParseSess)
-                                 -> ~[ast::TokenTree] {
+                                 -> Vec<ast::TokenTree> {
     let mut p = new_parser_from_source_str(
         sess,
         cfg,
@@ -214,7 +215,7 @@ pub fn filemap_to_parser(sess: @ParseSess,
 // compiler expands into it
 pub fn new_parser_from_tts(sess: @ParseSess,
                      cfg: ast::CrateConfig,
-                     tts: ~[ast::TokenTree]) -> Parser {
+                     tts: Vec<ast::TokenTree> ) -> Parser {
     tts_to_parser(sess,tts,cfg)
 }
 
@@ -256,10 +257,10 @@ pub fn string_to_filemap(sess: @ParseSess, source: ~str, path: ~str)
 
 // given a filemap, produce a sequence of token-trees
 pub fn filemap_to_tts(sess: @ParseSess, filemap: @FileMap)
-    -> ~[ast::TokenTree] {
+    -> Vec<ast::TokenTree> {
     // it appears to me that the cfg doesn't matter here... indeed,
     // parsing tt's probably shouldn't require a parser at all.
-    let cfg = ~[];
+    let cfg = Vec::new();
     let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap);
     let mut p1 = Parser(sess, cfg, ~srdr);
     p1.parse_all_token_trees()
@@ -267,7 +268,7 @@ pub fn filemap_to_tts(sess: @ParseSess, filemap: @FileMap)
 
 // given tts and cfg, produce a parser
 pub fn tts_to_parser(sess: @ParseSess,
-                     tts: ~[ast::TokenTree],
+                     tts: Vec<ast::TokenTree> ,
                      cfg: ast::CrateConfig) -> Parser {
     let trdr = lexer::new_tt_reader(sess.span_diagnostic, None, tts);
     Parser(sess, cfg, ~trdr)
@@ -288,6 +289,7 @@ mod test {
     use std::io;
     use std::io::MemWriter;
     use std::str;
+    use std::vec_ng::Vec;
     use codemap::{Span, BytePos, Spanned};
     use opt_vec;
     use ast;
@@ -318,13 +320,13 @@ mod test {
                     node: ast::ExprPath(ast::Path {
                         span: sp(0, 1),
                         global: false,
-                        segments: ~[
+                        segments: vec!(
                             ast::PathSegment {
                                 identifier: str_to_ident("a"),
                                 lifetimes: opt_vec::Empty,
                                 types: opt_vec::Empty,
                             }
-                        ],
+                        ),
                     }),
                     span: sp(0, 1)
                    })
@@ -337,7 +339,7 @@ mod test {
                     node: ast::ExprPath(ast::Path {
                             span: sp(0, 6),
                             global: true,
-                            segments: ~[
+                            segments: vec!(
                                 ast::PathSegment {
                                     identifier: str_to_ident("a"),
                                     lifetimes: opt_vec::Empty,
@@ -348,7 +350,7 @@ mod test {
                                     lifetimes: opt_vec::Empty,
                                     types: opt_vec::Empty,
                                 }
-                            ]
+                            )
                         }),
                     span: sp(0, 6)
                    })
@@ -362,27 +364,28 @@ mod test {
     // check the token-tree-ization of macros
     #[test] fn string_to_tts_macro () {
         let tts = string_to_tts(~"macro_rules! zip (($a)=>($a))");
-        let tts: &[ast::TokenTree] = tts;
+        let tts: &[ast::TokenTree] = tts.as_slice();
         match tts {
             [ast::TTTok(_,_),
              ast::TTTok(_,token::NOT),
              ast::TTTok(_,_),
              ast::TTDelim(delim_elts)] => {
-                let delim_elts: &[ast::TokenTree] = *delim_elts;
+                let delim_elts: &[ast::TokenTree] = delim_elts.as_slice();
                 match delim_elts {
                     [ast::TTTok(_,token::LPAREN),
                      ast::TTDelim(first_set),
                      ast::TTTok(_,token::FAT_ARROW),
                      ast::TTDelim(second_set),
                      ast::TTTok(_,token::RPAREN)] => {
-                        let first_set: &[ast::TokenTree] = *first_set;
+                        let first_set: &[ast::TokenTree] =
+                            first_set.as_slice();
                         match first_set {
                             [ast::TTTok(_,token::LPAREN),
                              ast::TTTok(_,token::DOLLAR),
                              ast::TTTok(_,_),
                              ast::TTTok(_,token::RPAREN)] => {
                                 let second_set: &[ast::TokenTree] =
-                                    *second_set;
+                                    second_set.as_slice();
                                 match second_set {
                                     [ast::TTTok(_,token::LPAREN),
                                      ast::TTTok(_,token::DOLLAR),
@@ -550,13 +553,13 @@ mod test {
                         node:ast::ExprPath(ast::Path{
                             span: sp(7, 8),
                             global: false,
-                            segments: ~[
+                            segments: vec!(
                                 ast::PathSegment {
                                     identifier: str_to_ident("d"),
                                     lifetimes: opt_vec::Empty,
                                     types: opt_vec::Empty,
                                 }
-                            ],
+                            ),
                         }),
                         span:sp(7,8)
                     })),
@@ -572,13 +575,13 @@ mod test {
                            node: ast::ExprPath(ast::Path {
                                span:sp(0,1),
                                global:false,
-                               segments: ~[
+                               segments: vec!(
                                 ast::PathSegment {
                                     identifier: str_to_ident("b"),
                                     lifetimes: opt_vec::Empty,
                                     types: opt_vec::Empty,
                                 }
-                               ],
+                               ),
                             }),
                            span: sp(0,1)},
                                            ast::DUMMY_NODE_ID),
@@ -599,13 +602,13 @@ mod test {
                                 ast::Path {
                                     span:sp(0,1),
                                     global:false,
-                                    segments: ~[
+                                    segments: vec!(
                                         ast::PathSegment {
                                             identifier: str_to_ident("b"),
                                             lifetimes: opt_vec::Empty,
                                             types: opt_vec::Empty,
                                         }
-                                    ],
+                                    ),
                                 },
                                 None /* no idea */),
                              span: sp(0,1)});
@@ -618,22 +621,22 @@ mod test {
         assert!(string_to_item(~"fn a (b : int) { b; }") ==
                   Some(
                       @ast::Item{ident:str_to_ident("a"),
-                            attrs:~[],
+                            attrs:Vec::new(),
                             id: ast::DUMMY_NODE_ID,
                             node: ast::ItemFn(ast::P(ast::FnDecl {
-                                inputs: ~[ast::Arg{
+                                inputs: vec!(ast::Arg{
                                     ty: ast::P(ast::Ty{id: ast::DUMMY_NODE_ID,
                                                        node: ast::TyPath(ast::Path{
                                         span:sp(10,13),
                                         global:false,
-                                        segments: ~[
+                                        segments: vec!(
                                             ast::PathSegment {
                                                 identifier:
                                                     str_to_ident("int"),
                                                 lifetimes: opt_vec::Empty,
                                                 types: opt_vec::Empty,
                                             }
-                                        ],
+                                        ),
                                         }, None, ast::DUMMY_NODE_ID),
                                         span:sp(10,13)
                                     }),
@@ -644,21 +647,21 @@ mod test {
                                             ast::Path {
                                                 span:sp(6,7),
                                                 global:false,
-                                                segments: ~[
+                                                segments: vec!(
                                                     ast::PathSegment {
                                                         identifier:
                                                             str_to_ident("b"),
                                                         lifetimes: opt_vec::Empty,
                                                         types: opt_vec::Empty,
                                                     }
-                                                ],
+                                                ),
                                             },
                                             None // no idea
                                         ),
                                         span: sp(6,7)
                                     },
                                     id: ast::DUMMY_NODE_ID
-                                }],
+                                }),
                                 output: ast::P(ast::Ty{id: ast::DUMMY_NODE_ID,
                                                        node: ast::TyNil,
                                                        span:sp(15,15)}), // not sure
@@ -672,15 +675,15 @@ mod test {
                                         ty_params: opt_vec::Empty,
                                     },
                                     ast::P(ast::Block {
-                                        view_items: ~[],
-                                        stmts: ~[@Spanned{
+                                        view_items: Vec::new(),
+                                        stmts: vec!(@Spanned{
                                             node: ast::StmtSemi(@ast::Expr{
                                                 id: ast::DUMMY_NODE_ID,
                                                 node: ast::ExprPath(
                                                       ast::Path{
                                                         span:sp(17,18),
                                                         global:false,
-                                                        segments: ~[
+                                                        segments: vec!(
                                                             ast::PathSegment {
                                                                 identifier:
                                                                 str_to_ident(
@@ -690,11 +693,11 @@ mod test {
                                                                 types:
                                                                 opt_vec::Empty
                                                             }
-                                                        ],
+                                                        ),
                                                       }),
                                                 span: sp(17,18)},
                                                 ast::DUMMY_NODE_ID),
-                                            span: sp(17,18)}],
+                                            span: sp(17,18)}),
                                         expr: None,
                                         id: ast::DUMMY_NODE_ID,
                                         rules: ast::DefaultBlock, // no idea
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 2fd6d34adf1..9b209aadf19 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -82,7 +82,8 @@ use std::cell::Cell;
 use collections::HashSet;
 use std::kinds::marker;
 use std::mem::replace;
-use std::vec;
+use std::vec_ng::Vec;
+use std::vec_ng;
 
 #[allow(non_camel_case_types)]
 #[deriving(Eq)]
@@ -93,7 +94,7 @@ enum restriction {
     RESTRICT_NO_BAR_OR_DOUBLEBAR_OP,
 }
 
-type ItemInfo = (Ident, Item_, Option<~[Attribute]>);
+type ItemInfo = (Ident, Item_, Option<Vec<Attribute> >);
 
 /// How to parse a path. There are four different kinds of paths, all of which
 /// are parsed somewhat differently.
@@ -129,7 +130,7 @@ pub struct PathAndBounds {
 enum ItemOrViewItem {
     // Indicates a failure to parse any kind of item. The attributes are
     // returned.
-    IoviNone(~[Attribute]),
+    IoviNone(Vec<Attribute> ),
     IoviItem(@Item),
     IoviForeignItem(@ForeignItem),
     IoviViewItem(ViewItem)
@@ -257,7 +258,7 @@ macro_rules! maybe_whole (
             };
             match __found__ {
                 Some(INTERPOLATED(token::$constructor(x))) => {
-                    return (~[], x)
+                    return (Vec::new(), x)
                 }
                 _ => {}
             }
@@ -266,21 +267,20 @@ macro_rules! maybe_whole (
 )
 
 
-fn maybe_append(lhs: ~[Attribute], rhs: Option<~[Attribute]>)
-             -> ~[Attribute] {
+fn maybe_append(lhs: Vec<Attribute> , rhs: Option<Vec<Attribute> >)
+             -> Vec<Attribute> {
     match rhs {
         None => lhs,
-        Some(ref attrs) => vec::append(lhs, (*attrs))
+        Some(ref attrs) => vec_ng::append(lhs, attrs.as_slice())
     }
 }
 
 
 struct ParsedItemsAndViewItems {
-    attrs_remaining: ~[Attribute],
-    view_items: ~[ViewItem],
-    items: ~[@Item],
-    foreign_items: ~[@ForeignItem]
-}
+    attrs_remaining: Vec<Attribute> ,
+    view_items: Vec<ViewItem> ,
+    items: Vec<@Item> ,
+    foreign_items: Vec<@ForeignItem> }
 
 /* ident is handled by common.rs */
 
@@ -314,8 +314,8 @@ pub fn Parser(sess: @ParseSess, cfg: ast::CrateConfig, rdr: ~Reader:)
         restriction: UNRESTRICTED,
         quote_depth: 0,
         obsolete_set: HashSet::new(),
-        mod_path_stack: ~[],
-        open_braces: ~[],
+        mod_path_stack: Vec::new(),
+        open_braces: Vec::new(),
         nopod: marker::NoPod
     }
 }
@@ -343,9 +343,9 @@ pub struct Parser {
     /// extra detail when the same error is seen twice
     obsolete_set: HashSet<ObsoleteSyntax>,
     /// Used to determine the path to externally loaded source files
-    mod_path_stack: ~[InternedString],
+    mod_path_stack: Vec<InternedString> ,
     /// Stack of spans of open delimiters. Used for error message.
-    open_braces: ~[Span],
+    open_braces: Vec<Span> ,
     /* do not copy the parser; its state is tied to outside state */
     priv nopod: marker::NoPod
 }
@@ -407,8 +407,11 @@ impl Parser {
         } else if inedible.contains(&self.token) {
             // leave it in the input
         } else {
-            let expected = vec::append(edible.to_owned(), inedible);
-            let expect = tokens_to_str(expected);
+            let expected = vec_ng::append(edible.iter()
+                                                .map(|x| (*x).clone())
+                                                .collect(),
+                                          inedible);
+            let expect = tokens_to_str(expected.as_slice());
             let actual = self.this_token_to_str();
             self.fatal(
                 if expected.len() != 1 {
@@ -446,8 +449,12 @@ impl Parser {
         match e.node {
             ExprPath(..) => {
                 // might be unit-struct construction; check for recoverableinput error.
-                let expected = vec::append(edible.to_owned(), inedible);
-                self.check_for_erroneous_unit_struct_expecting(expected);
+                let expected = vec_ng::append(edible.iter()
+                                                    .map(|x| (*x).clone())
+                                                    .collect(),
+                                              inedible);
+                self.check_for_erroneous_unit_struct_expecting(
+                    expected.as_slice());
             }
             _ => {}
         }
@@ -465,8 +472,12 @@ impl Parser {
         debug!("commit_stmt {:?}", s);
         let _s = s; // unused, but future checks might want to inspect `s`.
         if self.last_token.as_ref().map_or(false, |t| is_ident_or_path(*t)) {
-            let expected = vec::append(edible.to_owned(), inedible);
-            self.check_for_erroneous_unit_struct_expecting(expected);
+            let expected = vec_ng::append(edible.iter()
+                                                .map(|x| (*x).clone())
+                                                .collect(),
+                                          inedible.as_slice());
+            self.check_for_erroneous_unit_struct_expecting(
+                expected.as_slice());
         }
         self.expect_one_of(edible, inedible)
     }
@@ -578,9 +589,9 @@ impl Parser {
                               &mut self,
                               sep: &token::Token,
                               f: |&mut Parser| -> T)
-                              -> ~[T] {
+                              -> Vec<T> {
         let mut first = true;
-        let mut vector = ~[];
+        let mut vector = Vec::new();
         while self.token != token::BINOP(token::OR) &&
                 self.token != token::OROR {
             if first {
@@ -655,7 +666,7 @@ impl Parser {
                             ket: &token::Token,
                             sep: SeqSep,
                             f: |&mut Parser| -> T)
-                            -> ~[T] {
+                            -> Vec<T> {
         let val = self.parse_seq_to_before_end(ket, sep, f);
         self.bump();
         val
@@ -669,9 +680,9 @@ impl Parser {
                                    ket: &token::Token,
                                    sep: SeqSep,
                                    f: |&mut Parser| -> T)
-                                   -> ~[T] {
+                                   -> Vec<T> {
         let mut first: bool = true;
-        let mut v: ~[T] = ~[];
+        let mut v: Vec<T> = Vec::new();
         while self.token != *ket {
             match sep.sep {
               Some(ref t) => {
@@ -695,7 +706,7 @@ impl Parser {
                                ket: &token::Token,
                                sep: SeqSep,
                                f: |&mut Parser| -> T)
-                               -> ~[T] {
+                               -> Vec<T> {
         self.expect(bra);
         let result = self.parse_seq_to_before_end(ket, sep, f);
         self.bump();
@@ -710,7 +721,7 @@ impl Parser {
                      ket: &token::Token,
                      sep: SeqSep,
                      f: |&mut Parser| -> T)
-                     -> Spanned<~[T]> {
+                     -> Spanned<Vec<T> > {
         let lo = self.span.lo;
         self.expect(bra);
         let result = self.parse_seq_to_before_end(ket, sep, f);
@@ -950,7 +961,7 @@ impl Parser {
                 };
 
                 let inputs = if self.eat(&token::OROR) {
-                    ~[]
+                    Vec::new()
                 } else {
                     self.expect_or();
                     let inputs = self.parse_seq_to_before_or(
@@ -1034,7 +1045,7 @@ impl Parser {
     }
 
     // parse the methods in a trait declaration
-    pub fn parse_trait_methods(&mut self) -> ~[TraitMethod] {
+    pub fn parse_trait_methods(&mut self) -> Vec<TraitMethod> {
         self.parse_unspanned_seq(
             &token::LBRACE,
             &token::RBRACE,
@@ -1083,7 +1094,7 @@ impl Parser {
                 debug!("parse_trait_methods(): parsing provided method");
                 let (inner_attrs, body) =
                     p.parse_inner_attrs_and_block();
-                let attrs = vec::append(attrs, inner_attrs);
+                let attrs = vec_ng::append(attrs, inner_attrs.as_slice());
                 Provided(@ast::Method {
                     ident: ident,
                     attrs: attrs,
@@ -1176,7 +1187,7 @@ impl Parser {
                 // (t) is a parenthesized ty
                 // (t,) is the type of a tuple with only one field,
                 // of type t
-                let mut ts = ~[self.parse_ty(false)];
+                let mut ts = vec!(self.parse_ty(false));
                 let mut one_tuple = false;
                 while self.token == token::COMMA {
                     self.bump();
@@ -1190,7 +1201,7 @@ impl Parser {
 
                 if ts.len() == 1 && !one_tuple {
                     self.expect(&token::RPAREN);
-                    return ts[0]
+                    return *ts.get(0)
                 }
 
                 let t = TyTup(ts);
@@ -1479,7 +1490,7 @@ impl Parser {
         // Parse any number of segments and bound sets. A segment is an
         // identifier followed by an optional lifetime and a set of types.
         // A bound set is a set of type parameter bounds.
-        let mut segments = ~[];
+        let mut segments = Vec::new();
         loop {
             // First, parse an identifier.
             let identifier = self.parse_ident();
@@ -1541,7 +1552,7 @@ impl Parser {
         let span = mk_sp(lo, self.last_span.hi);
 
         // Assemble the path segments.
-        let mut path_segments = ~[];
+        let mut path_segments = Vec::new();
         let mut bounds = None;
         let last_segment_index = segments.len() - 1;
         for (i, segment_and_bounds) in segments.move_iter().enumerate() {
@@ -1690,11 +1701,11 @@ impl Parser {
         ExprBinary(binop, lhs, rhs)
     }
 
-    pub fn mk_call(&mut self, f: @Expr, args: ~[@Expr]) -> ast::Expr_ {
+    pub fn mk_call(&mut self, f: @Expr, args: Vec<@Expr> ) -> ast::Expr_ {
         ExprCall(f, args)
     }
 
-    fn mk_method_call(&mut self, ident: Ident, tps: ~[P<Ty>], args: ~[@Expr]) -> ast::Expr_ {
+    fn mk_method_call(&mut self, ident: Ident, tps: Vec<P<Ty>> , args: Vec<@Expr> ) -> ast::Expr_ {
         ExprMethodCall(ident, tps, args)
     }
 
@@ -1702,7 +1713,7 @@ impl Parser {
         ExprIndex(expr, idx)
     }
 
-    pub fn mk_field(&mut self, expr: @Expr, ident: Ident, tys: ~[P<Ty>]) -> ast::Expr_ {
+    pub fn mk_field(&mut self, expr: @Expr, ident: Ident, tys: Vec<P<Ty>> ) -> ast::Expr_ {
         ExprField(expr, ident, tys)
     }
 
@@ -1754,7 +1765,7 @@ impl Parser {
                 let lit = @spanned(lo, hi, LitNil);
                 return self.mk_expr(lo, hi, ExprLit(lit));
             }
-            let mut es = ~[self.parse_expr()];
+            let mut es = vec!(self.parse_expr());
             self.commit_expr(*es.last().unwrap(), &[], &[token::COMMA, token::RPAREN]);
             while self.token == token::COMMA {
                 self.bump();
@@ -1770,7 +1781,7 @@ impl Parser {
             self.commit_expr_expecting(*es.last().unwrap(), token::RPAREN);
 
             return if es.len() == 1 && !trailing_comma {
-                self.mk_expr(lo, hi, ExprParen(es[0]))
+                self.mk_expr(lo, hi, ExprParen(*es.get(0)))
             }
             else {
                 self.mk_expr(lo, hi, ExprTup(es))
@@ -1786,8 +1797,8 @@ impl Parser {
             let decl = self.parse_proc_decl();
             let body = self.parse_expr();
             let fakeblock = P(ast::Block {
-                view_items: ~[],
-                stmts: ~[],
+                view_items: Vec::new(),
+                stmts: Vec::new(),
                 expr: Some(body),
                 id: ast::DUMMY_NODE_ID,
                 rules: DefaultBlock,
@@ -1840,7 +1851,7 @@ impl Parser {
             if self.token == token::RBRACKET {
                 // Empty vector.
                 self.bump();
-                ex = ExprVec(~[], mutbl);
+                ex = ExprVec(Vec::new(), mutbl);
             } else {
                 // Nonempty vector.
                 let first_expr = self.parse_expr();
@@ -1860,11 +1871,13 @@ impl Parser {
                         seq_sep_trailing_allowed(token::COMMA),
                         |p| p.parse_expr()
                     );
-                    ex = ExprVec(~[first_expr] + remaining_exprs, mutbl);
+                    let mut exprs = vec!(first_expr);
+                    exprs.push_all_move(remaining_exprs);
+                    ex = ExprVec(exprs, mutbl);
                 } else {
                     // Vector with one element.
                     self.expect(&token::RBRACKET);
-                    ex = ExprVec(~[first_expr], mutbl);
+                    ex = ExprVec(vec!(first_expr), mutbl);
                 }
             }
             hi = self.last_span.hi;
@@ -1919,7 +1932,7 @@ impl Parser {
                 if self.looking_at_struct_literal() {
                     // It's a struct literal.
                     self.bump();
-                    let mut fields = ~[];
+                    let mut fields = Vec::new();
                     let mut base = None;
 
                     while self.token != token::RBRACE {
@@ -1981,7 +1994,7 @@ impl Parser {
                         self.expect(&token::LT);
                         self.parse_generic_values_after_lt()
                     } else {
-                        (opt_vec::Empty, ~[])
+                        (opt_vec::Empty, Vec::new())
                     };
 
                     // expr.f() method call
@@ -2143,7 +2156,7 @@ impl Parser {
 
                 // Parse the open delimiter.
                 self.open_braces.push(self.span);
-                let mut result = ~[parse_any_tt_tok(self)];
+                let mut result = vec!(parse_any_tt_tok(self));
 
                 let trees =
                     self.parse_seq_to_before_end(&close_delim,
@@ -2163,15 +2176,15 @@ impl Parser {
 
     // parse a stream of tokens into a list of TokenTree's,
     // up to EOF.
-    pub fn parse_all_token_trees(&mut self) -> ~[TokenTree] {
-        let mut tts = ~[];
+    pub fn parse_all_token_trees(&mut self) -> Vec<TokenTree> {
+        let mut tts = Vec::new();
         while self.token != token::EOF {
             tts.push(self.parse_token_tree());
         }
         tts
     }
 
-    pub fn parse_matchers(&mut self) -> ~[Matcher] {
+    pub fn parse_matchers(&mut self) -> Vec<Matcher> {
         // unification of Matcher's and TokenTree's would vastly improve
         // the interpolation of Matcher's
         maybe_whole!(self, NtMatchers);
@@ -2192,8 +2205,8 @@ impl Parser {
     pub fn parse_matcher_subseq_upto(&mut self,
                                      name_idx: @Cell<uint>,
                                      ket: &token::Token)
-                                     -> ~[Matcher] {
-        let mut ret_val = ~[];
+                                     -> Vec<Matcher> {
+        let mut ret_val = Vec::new();
         let mut lparens = 0u;
 
         while self.token != *ket || lparens > 0u {
@@ -2478,7 +2491,7 @@ impl Parser {
                     _ => {
                         // No argument list - `do foo {`
                         P(FnDecl {
-                            inputs: ~[],
+                            inputs: Vec::new(),
                             output: P(Ty {
                                 id: ast::DUMMY_NODE_ID,
                                 node: TyInfer,
@@ -2513,8 +2526,8 @@ impl Parser {
         let decl = parse_decl(self);
         let body = parse_body(self);
         let fakeblock = P(ast::Block {
-            view_items: ~[],
-            stmts: ~[],
+            view_items: Vec::new(),
+            stmts: Vec::new(),
             expr: Some(body),
             id: ast::DUMMY_NODE_ID,
             rules: DefaultBlock,
@@ -2601,7 +2614,7 @@ impl Parser {
         let lo = self.last_span.lo;
         let discriminant = self.parse_expr();
         self.commit_expr_expecting(discriminant, token::LBRACE);
-        let mut arms: ~[Arm] = ~[];
+        let mut arms: Vec<Arm> = Vec::new();
         while self.token != token::RBRACE {
             let pats = self.parse_pats();
             let mut guard = None;
@@ -2622,8 +2635,8 @@ impl Parser {
             }
 
             let blk = P(ast::Block {
-                view_items: ~[],
-                stmts: ~[],
+                view_items: Vec::new(),
+                stmts: Vec::new(),
                 expr: Some(expr),
                 id: ast::DUMMY_NODE_ID,
                 rules: DefaultBlock,
@@ -2662,8 +2675,8 @@ impl Parser {
     }
 
     // parse patterns, separated by '|' s
-    fn parse_pats(&mut self) -> ~[@Pat] {
-        let mut pats = ~[];
+    fn parse_pats(&mut self) -> Vec<@Pat> {
+        let mut pats = Vec::new();
         loop {
             pats.push(self.parse_pat());
             if self.token == token::BINOP(token::OR) { self.bump(); }
@@ -2673,10 +2686,10 @@ impl Parser {
 
     fn parse_pat_vec_elements(
         &mut self,
-    ) -> (~[@Pat], Option<@Pat>, ~[@Pat]) {
-        let mut before = ~[];
+    ) -> (Vec<@Pat> , Option<@Pat>, Vec<@Pat> ) {
+        let mut before = Vec::new();
         let mut slice = None;
-        let mut after = ~[];
+        let mut after = Vec::new();
         let mut first = true;
         let mut before_slice = true;
 
@@ -2733,8 +2746,8 @@ impl Parser {
     }
 
     // parse the fields of a struct-like pattern
-    fn parse_pat_fields(&mut self) -> (~[ast::FieldPat], bool) {
-        let mut fields = ~[];
+    fn parse_pat_fields(&mut self) -> (Vec<ast::FieldPat> , bool) {
+        let mut fields = Vec::new();
         let mut etc = false;
         let mut first = true;
         while self.token != token::RBRACE {
@@ -2900,7 +2913,7 @@ impl Parser {
                 let expr = self.mk_expr(lo, hi, ExprLit(lit));
                 pat = PatLit(expr);
             } else {
-                let mut fields = ~[self.parse_pat()];
+                let mut fields = vec!(self.parse_pat());
                 if self.look_ahead(1, |t| *t != token::RPAREN) {
                     while self.token == token::COMMA {
                         self.bump();
@@ -3002,7 +3015,7 @@ impl Parser {
                         pat = PatStruct(enum_path, fields, etc);
                     }
                     _ => {
-                        let mut args: ~[@Pat] = ~[];
+                        let mut args: Vec<@Pat> = Vec::new();
                         match self.token {
                           token::LPAREN => {
                             let is_star = self.look_ahead(1, |t| {
@@ -3128,7 +3141,7 @@ impl Parser {
 
     // parse a structure field
     fn parse_name_and_ty(&mut self, pr: Visibility,
-                         attrs: ~[Attribute]) -> StructField {
+                         attrs: Vec<Attribute> ) -> StructField {
         let lo = self.span.lo;
         if !is_plain_ident(&self.token) {
             self.fatal("expected ident");
@@ -3146,7 +3159,7 @@ impl Parser {
 
     // parse a statement. may include decl.
     // precondition: any attributes are parsed already
-    pub fn parse_stmt(&mut self, item_attrs: ~[Attribute]) -> @Stmt {
+    pub fn parse_stmt(&mut self, item_attrs: Vec<Attribute> ) -> @Stmt {
         maybe_whole!(self, NtStmt);
 
         fn check_expected_item(p: &mut Parser, found_attrs: bool) {
@@ -3229,7 +3242,7 @@ impl Parser {
                         self.mk_item(
                             lo, hi, id /*id is good here*/,
                             ItemMac(spanned(lo, hi, MacInvocTT(pth, tts, EMPTY_CTXT))),
-                            Inherited, ~[/*no attrs*/]))),
+                            Inherited, Vec::new(/*no attrs*/)))),
                     ast::DUMMY_NODE_ID));
             }
 
@@ -3275,12 +3288,12 @@ impl Parser {
         }
         self.expect(&token::LBRACE);
 
-        return self.parse_block_tail_(lo, DefaultBlock, ~[]);
+        return self.parse_block_tail_(lo, DefaultBlock, Vec::new());
     }
 
     // parse a block. Inner attrs are allowed.
     fn parse_inner_attrs_and_block(&mut self)
-        -> (~[Attribute], P<Block>) {
+        -> (Vec<Attribute> , P<Block>) {
 
         maybe_whole!(pair_empty self, NtBlock);
 
@@ -3299,13 +3312,13 @@ impl Parser {
     // necessary, and this should take a qualifier.
     // some blocks start with "#{"...
     fn parse_block_tail(&mut self, lo: BytePos, s: BlockCheckMode) -> P<Block> {
-        self.parse_block_tail_(lo, s, ~[])
+        self.parse_block_tail_(lo, s, Vec::new())
     }
 
     // parse the rest of a block expression or function body
     fn parse_block_tail_(&mut self, lo: BytePos, s: BlockCheckMode,
-                         first_item_attrs: ~[Attribute]) -> P<Block> {
-        let mut stmts = ~[];
+                         first_item_attrs: Vec<Attribute> ) -> P<Block> {
+        let mut stmts = Vec::new();
         let mut expr = None;
 
         // wouldn't it be more uniform to parse view items only, here?
@@ -3328,12 +3341,12 @@ impl Parser {
         while self.token != token::RBRACE {
             // parsing items even when they're not allowed lets us give
             // better error messages and recover more gracefully.
-            attributes_box.push_all(self.parse_outer_attributes());
+            attributes_box.push_all(self.parse_outer_attributes().as_slice());
             match self.token {
                 token::SEMI => {
                     if !attributes_box.is_empty() {
                         self.span_err(self.last_span, "expected item after attributes");
-                        attributes_box = ~[];
+                        attributes_box = Vec::new();
                     }
                     self.bump(); // empty
                 }
@@ -3342,7 +3355,7 @@ impl Parser {
                 }
                 _ => {
                     let stmt = self.parse_stmt(attributes_box);
-                    attributes_box = ~[];
+                    attributes_box = Vec::new();
                     match stmt.node {
                         StmtExpr(e, stmt_id) => {
                             // expression without semicolon
@@ -3510,7 +3523,7 @@ impl Parser {
         }
     }
 
-    fn parse_generic_values_after_lt(&mut self) -> (OptVec<ast::Lifetime>, ~[P<Ty>]) {
+    fn parse_generic_values_after_lt(&mut self) -> (OptVec<ast::Lifetime>, Vec<P<Ty>> ) {
         let lifetimes = self.parse_lifetimes();
         let result = self.parse_seq_to_gt(
             Some(token::COMMA),
@@ -3519,9 +3532,9 @@ impl Parser {
     }
 
     fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
-                     -> (~[Arg], bool) {
+                     -> (Vec<Arg> , bool) {
         let sp = self.span;
-        let mut args: ~[Option<Arg>] =
+        let mut args: Vec<Option<Arg>> =
             self.parse_unspanned_seq(
                 &token::LPAREN,
                 &token::RPAREN,
@@ -3716,7 +3729,7 @@ impl Parser {
                     fn_inputs
                 }
                 token::RPAREN => {
-                    ~[Arg::new_self(explicit_self_sp, mutbl_self)]
+                    vec!(Arg::new_self(explicit_self_sp, mutbl_self))
                 }
                 _ => {
                     let token_str = self.this_token_to_str();
@@ -3749,7 +3762,7 @@ impl Parser {
     fn parse_fn_block_decl(&mut self) -> P<FnDecl> {
         let inputs_captures = {
             if self.eat(&token::OROR) {
-                ~[]
+                Vec::new()
             } else {
                 self.parse_unspanned_seq(
                     &token::BINOP(token::OR),
@@ -3812,7 +3825,7 @@ impl Parser {
 
     fn mk_item(&mut self, lo: BytePos, hi: BytePos, ident: Ident,
                node: Item_, vis: Visibility,
-               attrs: ~[Attribute]) -> @Item {
+               attrs: Vec<Attribute> ) -> @Item {
         @Item {
             ident: ident,
             attrs: attrs,
@@ -3832,7 +3845,7 @@ impl Parser {
     }
 
     // parse a method in a trait impl, starting with `attrs` attributes.
-    fn parse_method(&mut self, already_parsed_attrs: Option<~[Attribute]>) -> @Method {
+    fn parse_method(&mut self, already_parsed_attrs: Option<Vec<Attribute> >) -> @Method {
         let next_attrs = self.parse_outer_attributes();
         let attrs = match already_parsed_attrs {
             Some(mut a) => { a.push_all_move(next_attrs); a }
@@ -3851,7 +3864,7 @@ impl Parser {
 
         let (inner_attrs, body) = self.parse_inner_attrs_and_block();
         let hi = body.span.hi;
-        let attrs = vec::append(attrs, inner_attrs);
+        let attrs = vec_ng::append(attrs, inner_attrs.as_slice());
         @ast::Method {
             ident: ident,
             attrs: attrs,
@@ -3877,7 +3890,7 @@ impl Parser {
             self.bump();
             traits = self.parse_trait_ref_list(&token::LBRACE);
         } else {
-            traits = ~[];
+            traits = Vec::new();
         }
 
         let meths = self.parse_trait_methods();
@@ -3925,7 +3938,7 @@ impl Parser {
             None
         };
 
-        let mut meths = ~[];
+        let mut meths = Vec::new();
         self.expect(&token::LBRACE);
         let (inner_attrs, next) = self.parse_inner_attrs_and_next();
         let mut method_attrs = Some(next);
@@ -3948,7 +3961,7 @@ impl Parser {
     }
 
     // parse B + C<~str,int> + D
-    fn parse_trait_ref_list(&mut self, ket: &token::Token) -> ~[TraitRef] {
+    fn parse_trait_ref_list(&mut self, ket: &token::Token) -> Vec<TraitRef> {
         self.parse_seq_to_before_end(
             ket,
             seq_sep_trailing_disallowed(token::BINOP(token::PLUS)),
@@ -3961,13 +3974,13 @@ impl Parser {
         let class_name = self.parse_ident();
         let generics = self.parse_generics();
 
-        let mut fields: ~[StructField];
+        let mut fields: Vec<StructField> ;
         let is_tuple_like;
 
         if self.eat(&token::LBRACE) {
             // It's a record-like struct.
             is_tuple_like = false;
-            fields = ~[];
+            fields = Vec::new();
             while self.token != token::RBRACE {
                 fields.push(self.parse_struct_decl_field());
             }
@@ -3998,7 +4011,7 @@ impl Parser {
         } else if self.eat(&token::SEMI) {
             // It's a unit-like struct.
             is_tuple_like = true;
-            fields = ~[];
+            fields = Vec::new();
         } else {
             let token_str = self.this_token_to_str();
             self.fatal(format!("expected `\\{`, `(`, or `;` after struct \
@@ -4019,7 +4032,7 @@ impl Parser {
     // parse a structure field declaration
     pub fn parse_single_struct_field(&mut self,
                                      vis: Visibility,
-                                     attrs: ~[Attribute])
+                                     attrs: Vec<Attribute> )
                                      -> StructField {
         let a_var = self.parse_name_and_ty(vis, attrs);
         match self.token {
@@ -4064,7 +4077,7 @@ impl Parser {
     // attributes (of length 0 or 1), parse all of the items in a module
     fn parse_mod_items(&mut self,
                        term: token::Token,
-                       first_item_attrs: ~[Attribute])
+                       first_item_attrs: Vec<Attribute> )
                        -> Mod {
         // parse all of the items up to closing or an attribute.
         // view items are legal here.
@@ -4074,7 +4087,7 @@ impl Parser {
             items: starting_items,
             ..
         } = self.parse_items_and_view_items(first_item_attrs, true, true);
-        let mut items: ~[@Item] = starting_items;
+        let mut items: Vec<@Item> = starting_items;
         let attrs_remaining_len = attrs_remaining.len();
 
         // don't think this other loop is even necessary....
@@ -4083,7 +4096,8 @@ impl Parser {
         while self.token != term {
             let mut attrs = self.parse_outer_attributes();
             if first {
-                attrs = attrs_remaining + attrs;
+                attrs = vec_ng::append(attrs_remaining.clone(),
+                                       attrs.as_slice());
                 first = false;
             }
             debug!("parse_mod_items: parse_item_or_view_item(attrs={:?})",
@@ -4162,10 +4176,10 @@ impl Parser {
                     id: ast::Ident,
                     outer_attrs: &[ast::Attribute],
                     id_sp: Span)
-                    -> (ast::Item_, ~[ast::Attribute]) {
+                    -> (ast::Item_, Vec<ast::Attribute> ) {
         let mut prefix = Path::new(self.sess.cm.span_to_filename(self.span));
         prefix.pop();
-        let mod_path = Path::new(".").join_many(self.mod_path_stack);
+        let mod_path = Path::new(".").join_many(self.mod_path_stack.as_slice());
         let dir_path = prefix.join(&mod_path);
         let file_path = match ::attr::first_attr_value_str_by_name(
                 outer_attrs, "path") {
@@ -4195,14 +4209,14 @@ impl Parser {
         };
 
         self.eval_src_mod_from_path(file_path,
-                                    outer_attrs.to_owned(),
+                                    outer_attrs.iter().map(|x| *x).collect(),
                                     id_sp)
     }
 
     fn eval_src_mod_from_path(&mut self,
                               path: Path,
-                              outer_attrs: ~[ast::Attribute],
-                              id_sp: Span) -> (ast::Item_, ~[ast::Attribute]) {
+                              outer_attrs: Vec<ast::Attribute> ,
+                              id_sp: Span) -> (ast::Item_, Vec<ast::Attribute> ) {
         {
             let mut included_mod_stack = self.sess
                                              .included_mod_stack
@@ -4232,7 +4246,7 @@ impl Parser {
                                      &path,
                                      id_sp);
         let (inner, next) = p0.parse_inner_attrs_and_next();
-        let mod_attrs = vec::append(outer_attrs, inner);
+        let mod_attrs = vec_ng::append(outer_attrs, inner.as_slice());
         let first_item_outer_attrs = next;
         let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
         {
@@ -4246,7 +4260,7 @@ impl Parser {
 
     // parse a function declaration from a foreign module
     fn parse_item_foreign_fn(&mut self, vis: ast::Visibility,
-                             attrs: ~[Attribute]) -> @ForeignItem {
+                             attrs: Vec<Attribute> ) -> @ForeignItem {
         let lo = self.span.lo;
 
         // Parse obsolete purity.
@@ -4269,7 +4283,7 @@ impl Parser {
 
     // parse a static item from a foreign module
     fn parse_item_foreign_static(&mut self, vis: ast::Visibility,
-                                 attrs: ~[Attribute]) -> @ForeignItem {
+                                 attrs: Vec<Attribute> ) -> @ForeignItem {
         let lo = self.span.lo;
 
         self.expect_keyword(keywords::Static);
@@ -4303,7 +4317,7 @@ impl Parser {
     // parse_foreign_items.
     fn parse_foreign_mod_items(&mut self,
                                abis: AbiSet,
-                               first_item_attrs: ~[Attribute])
+                               first_item_attrs: Vec<Attribute> )
                                -> ForeignMod {
         let ParsedItemsAndViewItems {
             attrs_remaining: attrs_remaining,
@@ -4332,7 +4346,7 @@ impl Parser {
     fn parse_item_extern_crate(&mut self,
                                 lo: BytePos,
                                 visibility: Visibility,
-                                attrs: ~[Attribute])
+                                attrs: Vec<Attribute> )
                                 -> ItemOrViewItem {
 
         let (maybe_path, ident) = match self.token {
@@ -4377,7 +4391,7 @@ impl Parser {
                               lo: BytePos,
                               opt_abis: Option<AbiSet>,
                               visibility: Visibility,
-                              attrs: ~[Attribute])
+                              attrs: Vec<Attribute> )
                               -> ItemOrViewItem {
 
         self.expect(&token::LBRACE);
@@ -4410,7 +4424,7 @@ impl Parser {
     // parse a structure-like enum variant definition
     // this should probably be renamed or refactored...
     fn parse_struct_def(&mut self) -> @StructDef {
-        let mut fields: ~[StructField] = ~[];
+        let mut fields: Vec<StructField> = Vec::new();
         while self.token != token::RBRACE {
             fields.push(self.parse_struct_decl_field());
         }
@@ -4424,7 +4438,7 @@ impl Parser {
 
     // parse the part of an "enum" decl following the '{'
     fn parse_enum_def(&mut self, _generics: &ast::Generics) -> EnumDef {
-        let mut variants = ~[];
+        let mut variants = Vec::new();
         let mut all_nullary = true;
         let mut have_disr = false;
         while self.token != token::RBRACE {
@@ -4435,7 +4449,7 @@ impl Parser {
 
             let ident;
             let kind;
-            let mut args = ~[];
+            let mut args = Vec::new();
             let mut disr_expr = None;
             ident = self.parse_ident();
             if self.eat(&token::LBRACE) {
@@ -4462,7 +4476,7 @@ impl Parser {
                 disr_expr = Some(self.parse_expr());
                 kind = TupleVariantKind(args);
             } else {
-                kind = TupleVariantKind(~[]);
+                kind = TupleVariantKind(Vec::new());
             }
 
             let vr = ast::Variant_ {
@@ -4551,13 +4565,13 @@ impl Parser {
     // NB: this function no longer parses the items inside an
     // extern crate.
     fn parse_item_or_view_item(&mut self,
-                               attrs: ~[Attribute],
+                               attrs: Vec<Attribute> ,
                                macros_allowed: bool)
                                -> ItemOrViewItem {
         match self.token {
             INTERPOLATED(token::NtItem(item)) => {
                 self.bump();
-                let new_attrs = vec::append(attrs, item.attrs);
+                let new_attrs = vec_ng::append(attrs, item.attrs.as_slice());
                 return IoviItem(@Item {
                     attrs: new_attrs,
                     ..(*item).clone()
@@ -4663,7 +4677,8 @@ impl Parser {
         }
         if self.eat_keyword(keywords::Mod) {
             // MODULE ITEM
-            let (ident, item_, extra_attrs) = self.parse_item_mod(attrs);
+            let (ident, item_, extra_attrs) =
+                self.parse_item_mod(attrs.as_slice());
             let item = self.mk_item(lo,
                                     self.last_span.hi,
                                     ident,
@@ -4732,7 +4747,7 @@ impl Parser {
 
     // parse a foreign item; on failure, return IoviNone.
     fn parse_foreign_item(&mut self,
-                          attrs: ~[Attribute],
+                          attrs: Vec<Attribute> ,
                           macros_allowed: bool)
                           -> ItemOrViewItem {
         maybe_whole!(iovi self, NtItem);
@@ -4756,7 +4771,7 @@ impl Parser {
     // this is the fall-through for parsing items.
     fn parse_macro_use_or_failure(
         &mut self,
-        attrs: ~[Attribute],
+        attrs: Vec<Attribute> ,
         macros_allowed: bool,
         lo: BytePos,
         visibility: Visibility
@@ -4820,7 +4835,7 @@ impl Parser {
         return IoviNone(attrs);
     }
 
-    pub fn parse_item(&mut self, attrs: ~[Attribute]) -> Option<@Item> {
+    pub fn parse_item(&mut self, attrs: Vec<Attribute> ) -> Option<@Item> {
         match self.parse_item_or_view_item(attrs, true) {
             IoviNone(_) => None,
             IoviViewItem(_) =>
@@ -4854,20 +4869,20 @@ impl Parser {
             let path = ast::Path {
                 span: mk_sp(lo, self.span.hi),
                 global: false,
-                segments: ~[]
+                segments: Vec::new()
             };
             return @spanned(lo, self.span.hi,
                             ViewPathList(path, idents, ast::DUMMY_NODE_ID));
         }
 
         let first_ident = self.parse_ident();
-        let mut path = ~[first_ident];
+        let mut path = vec!(first_ident);
         match self.token {
           token::EQ => {
             // x = foo::bar
             self.bump();
             let path_lo = self.span.lo;
-            path = ~[self.parse_ident()];
+            path = vec!(self.parse_ident());
             while self.token == token::MOD_SEP {
                 self.bump();
                 let id = self.parse_ident();
@@ -4947,7 +4962,7 @@ impl Parser {
           }
           _ => ()
         }
-        let last = path[path.len() - 1u];
+        let last = *path.get(path.len() - 1u);
         let path = ast::Path {
             span: mk_sp(lo, self.span.hi),
             global: false,
@@ -4965,8 +4980,8 @@ impl Parser {
     }
 
     // matches view_paths = view_path | view_path , view_paths
-    fn parse_view_paths(&mut self) -> ~[@ViewPath] {
-        let mut vp = ~[self.parse_view_path()];
+    fn parse_view_paths(&mut self) -> Vec<@ViewPath> {
+        let mut vp = vec!(self.parse_view_path());
         while self.token == token::COMMA {
             self.bump();
             self.obsolete(self.last_span, ObsoleteMultipleImport);
@@ -4980,15 +4995,16 @@ impl Parser {
     // - mod_items uses extern_mod_allowed = true
     // - block_tail_ uses extern_mod_allowed = false
     fn parse_items_and_view_items(&mut self,
-                                  first_item_attrs: ~[Attribute],
+                                  first_item_attrs: Vec<Attribute> ,
                                   mut extern_mod_allowed: bool,
                                   macros_allowed: bool)
                                   -> ParsedItemsAndViewItems {
-        let mut attrs = vec::append(first_item_attrs,
-                                    self.parse_outer_attributes());
+        let mut attrs = vec_ng::append(first_item_attrs,
+                                       self.parse_outer_attributes()
+                                           .as_slice());
         // First, parse view items.
-        let mut view_items : ~[ast::ViewItem] = ~[];
-        let mut items = ~[];
+        let mut view_items : Vec<ast::ViewItem> = Vec::new();
+        let mut items = Vec::new();
 
         // I think this code would probably read better as a single
         // loop with a mutable three-state-variable (for extern crates,
@@ -5001,7 +5017,7 @@ impl Parser {
                         attrs_remaining: attrs,
                         view_items: view_items,
                         items: items,
-                        foreign_items: ~[]
+                        foreign_items: Vec::new()
                     }
                 }
                 IoviViewItem(view_item) => {
@@ -5056,18 +5072,19 @@ impl Parser {
             attrs_remaining: attrs,
             view_items: view_items,
             items: items,
-            foreign_items: ~[]
+            foreign_items: Vec::new()
         }
     }
 
     // Parses a sequence of foreign items. Stops when it finds program
     // text that can't be parsed as an item
-    fn parse_foreign_items(&mut self, first_item_attrs: ~[Attribute],
+    fn parse_foreign_items(&mut self, first_item_attrs: Vec<Attribute> ,
                            macros_allowed: bool)
         -> ParsedItemsAndViewItems {
-        let mut attrs = vec::append(first_item_attrs,
-                                    self.parse_outer_attributes());
-        let mut foreign_items = ~[];
+        let mut attrs = vec_ng::append(first_item_attrs,
+                                       self.parse_outer_attributes()
+                                           .as_slice());
+        let mut foreign_items = Vec::new();
         loop {
             match self.parse_foreign_item(attrs, macros_allowed) {
                 IoviNone(returned_attrs) => {
@@ -5095,8 +5112,8 @@ impl Parser {
 
         ParsedItemsAndViewItems {
             attrs_remaining: attrs,
-            view_items: ~[],
-            items: ~[],
+            view_items: Vec::new(),
+            items: Vec::new(),
             foreign_items: foreign_items
         }
     }
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index edc5e613f91..1499a1b4c19 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -21,6 +21,7 @@ use std::char;
 use std::fmt;
 use std::local_data;
 use std::path::BytesContainer;
+use std::vec_ng::Vec;
 
 #[allow(non_camel_case_types)]
 #[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
@@ -115,7 +116,7 @@ pub enum Nonterminal {
     NtAttr(@ast::Attribute), // #[foo]
     NtPath(~ast::Path),
     NtTT(  @ast::TokenTree), // needs @ed to break a circularity
-    NtMatchers(~[ast::Matcher])
+    NtMatchers(Vec<ast::Matcher> )
 }
 
 impl fmt::Show for Nonterminal {
@@ -412,13 +413,11 @@ macro_rules! declare_special_idents_and_keywords {(
         // The indices here must correspond to the numbers in
         // special_idents, in Keyword to_ident(), and in static
         // constants below.
-        let init_vec = ~[
-            $( $si_str, )*
-            $( $sk_str, )*
-            $( $rk_str, )*
-        ];
-
-        interner::StrInterner::prefill(init_vec)
+        let mut init_vec = Vec::new();
+        $(init_vec.push($si_str);)*
+        $(init_vec.push($sk_str);)*
+        $(init_vec.push($rk_str);)*
+        interner::StrInterner::prefill(init_vec.as_slice())
     }
 }}