libsyntax: Mechanically change ~[T] to Vec<T>
This commit is contained in:
parent
df40aeccdb
commit
58fd6ab90d
48 changed files with 934 additions and 979 deletions
|
|
@ -17,19 +17,19 @@ use parse::token::INTERPOLATED;
|
|||
|
||||
// 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 +116,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 +188,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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ pub enum CommentStyle {
|
|||
#[deriving(Clone)]
|
||||
pub struct Comment {
|
||||
style: CommentStyle,
|
||||
lines: ~[~str],
|
||||
lines: Vec<~str> ,
|
||||
pos: BytePos
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ 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
|
||||
|
|
@ -75,7 +75,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
|
|||
}
|
||||
|
||||
/// 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 +122,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 +157,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 +168,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 +179,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 +232,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 +249,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 +324,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 +348,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 {
|
||||
|
|
|
|||
|
|
@ -1048,7 +1048,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 +1064,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() {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,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 +50,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 +60,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 +82,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 +104,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 +144,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 +160,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 +214,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 +256,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 +267,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)
|
||||
|
|
@ -318,13 +318,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 +337,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 +348,7 @@ mod test {
|
|||
lifetimes: opt_vec::Empty,
|
||||
types: opt_vec::Empty,
|
||||
}
|
||||
]
|
||||
)
|
||||
}),
|
||||
span: sp(0, 6)
|
||||
})
|
||||
|
|
@ -550,13 +550,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 +572,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 +599,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 +618,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 +644,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 +672,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 +690,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
|
||||
|
|
|
|||
|
|
@ -93,7 +93,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 +129,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 +257,7 @@ macro_rules! maybe_whole (
|
|||
};
|
||||
match __found__ {
|
||||
Some(INTERPOLATED(token::$constructor(x))) => {
|
||||
return (~[], x)
|
||||
return (Vec::new(), x)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -266,21 +266,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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 +313,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 +342,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,7 +406,7 @@ impl Parser {
|
|||
} else if inedible.contains(&self.token) {
|
||||
// leave it in the input
|
||||
} else {
|
||||
let expected = vec::append(edible.to_owned(), inedible);
|
||||
let expected = vec_ng::append(edible.to_owned(), inedible);
|
||||
let expect = tokens_to_str(expected);
|
||||
let actual = self.this_token_to_str();
|
||||
self.fatal(
|
||||
|
|
@ -446,7 +445,7 @@ impl Parser {
|
|||
match e.node {
|
||||
ExprPath(..) => {
|
||||
// might be unit-struct construction; check for recoverableinput error.
|
||||
let expected = vec::append(edible.to_owned(), inedible);
|
||||
let expected = vec_ng::append(edible.to_owned(), inedible);
|
||||
self.check_for_erroneous_unit_struct_expecting(expected);
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -465,7 +464,7 @@ 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);
|
||||
let expected = vec_ng::append(edible.to_owned(), inedible);
|
||||
self.check_for_erroneous_unit_struct_expecting(expected);
|
||||
}
|
||||
self.expect_one_of(edible, inedible)
|
||||
|
|
@ -578,9 +577,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 +654,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 +668,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 +694,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 +709,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 +949,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 +1033,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 +1082,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);
|
||||
Provided(@ast::Method {
|
||||
ident: ident,
|
||||
attrs: attrs,
|
||||
|
|
@ -1176,7 +1175,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();
|
||||
|
|
@ -1479,7 +1478,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 +1540,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 +1689,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 +1701,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 +1753,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();
|
||||
|
|
@ -1786,8 +1785,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 +1839,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 +1859,11 @@ impl Parser {
|
|||
seq_sep_trailing_allowed(token::COMMA),
|
||||
|p| p.parse_expr()
|
||||
);
|
||||
ex = ExprVec(~[first_expr] + remaining_exprs, mutbl);
|
||||
ex = ExprVec(vec!(first_expr) + remaining_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 +1918,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 +1980,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 +2142,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 +2162,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 +2191,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 +2477,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 +2512,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 +2600,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 +2621,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 +2661,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 +2672,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 +2732,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 +2899,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 +3001,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 +3127,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 +3145,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 +3228,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 +3274,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 +3298,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?
|
||||
|
|
@ -3333,7 +3332,7 @@ impl Parser {
|
|||
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 +3341,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 +3509,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 +3518,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 +3715,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 +3748,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 +3811,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 +3831,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 +3850,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);
|
||||
@ast::Method {
|
||||
ident: ident,
|
||||
attrs: attrs,
|
||||
|
|
@ -3877,7 +3876,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 +3924,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 +3947,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 +3960,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 +3997,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 +4018,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 +4063,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 +4073,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....
|
||||
|
|
@ -4162,7 +4161,7 @@ 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);
|
||||
|
|
@ -4201,8 +4200,8 @@ impl Parser {
|
|||
|
||||
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 +4231,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);
|
||||
let first_item_outer_attrs = next;
|
||||
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
|
||||
{
|
||||
|
|
@ -4246,7 +4245,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 +4268,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 +4302,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 +4331,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 +4376,7 @@ impl Parser {
|
|||
lo: BytePos,
|
||||
opt_abis: Option<AbiSet>,
|
||||
visibility: Visibility,
|
||||
attrs: ~[Attribute])
|
||||
attrs: Vec<Attribute> )
|
||||
-> ItemOrViewItem {
|
||||
|
||||
self.expect(&token::LBRACE);
|
||||
|
|
@ -4410,7 +4409,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 +4423,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 +4434,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 +4461,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 +4550,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);
|
||||
return IoviItem(@Item {
|
||||
attrs: new_attrs,
|
||||
..(*item).clone()
|
||||
|
|
@ -4732,7 +4731,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 +4755,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 +4819,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 +4853,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();
|
||||
|
|
@ -4965,8 +4964,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 +4979,15 @@ 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,
|
||||
let mut attrs = vec_ng::append(first_item_attrs,
|
||||
self.parse_outer_attributes());
|
||||
// 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 +5000,7 @@ impl Parser {
|
|||
attrs_remaining: attrs,
|
||||
view_items: view_items,
|
||||
items: items,
|
||||
foreign_items: ~[]
|
||||
foreign_items: Vec::new()
|
||||
}
|
||||
}
|
||||
IoviViewItem(view_item) => {
|
||||
|
|
@ -5056,18 +5055,18 @@ 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,
|
||||
let mut attrs = vec_ng::append(first_item_attrs,
|
||||
self.parse_outer_attributes());
|
||||
let mut foreign_items = ~[];
|
||||
let mut foreign_items = Vec::new();
|
||||
loop {
|
||||
match self.parse_foreign_item(attrs, macros_allowed) {
|
||||
IoviNone(returned_attrs) => {
|
||||
|
|
@ -5095,8 +5094,8 @@ impl Parser {
|
|||
|
||||
ParsedItemsAndViewItems {
|
||||
attrs_remaining: attrs,
|
||||
view_items: ~[],
|
||||
items: ~[],
|
||||
view_items: Vec::new(),
|
||||
items: Vec::new(),
|
||||
foreign_items: foreign_items
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,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,11 +412,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 = ~[
|
||||
let init_vec = vec!(
|
||||
$( $si_str, )*
|
||||
$( $sk_str, )*
|
||||
$( $rk_str, )*
|
||||
];
|
||||
);
|
||||
|
||||
interner::StrInterner::prefill(init_vec)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue