libsyntax: Mechanically change ~[T] to Vec<T>

This commit is contained in:
Patrick Walton
2014-02-28 13:09:09 -08:00
parent df40aeccdb
commit 58fd6ab90d
48 changed files with 934 additions and 979 deletions

View File

@@ -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
}
}