Changed lists of lifetimes in ast and ty to use Vec instead of OptVec.

There is a broader revision (that does this across the board) pending
in #12675, but that is awaiting the arrival of more data (to decide
whether to keep OptVec alive by using a non-Vec internally).

For this code, the representation of lifetime lists needs to be the
same in both ScopeChain and in the ast and ty structures.  So it
seemed cleanest to just use `vec_ng::Vec`, now that it has a cheaper
empty representation than the current `vec` code.
This commit is contained in:
Felix S. Klock II 2014-03-07 16:50:40 +01:00
parent 28ebec5160
commit 586b619c76
19 changed files with 72 additions and 71 deletions

View file

@ -958,7 +958,7 @@ impl Parser {
lifetimes
} else {
opt_vec::Empty
Vec::new()
};
let inputs = if self.eat(&token::OROR) {
@ -1015,7 +1015,7 @@ impl Parser {
// parse a function type (following the 'fn')
pub fn parse_ty_fn_decl(&mut self, allow_variadic: bool)
-> (P<FnDecl>, OptVec<ast::Lifetime>) {
-> (P<FnDecl>, Vec<ast::Lifetime>) {
/*
(fn) <'lt> (S) -> T
@ -1031,7 +1031,7 @@ impl Parser {
self.expect_gt();
lifetimes
} else {
opt_vec::Empty
Vec::new()
};
let (inputs, variadic) = self.parse_fn_args(false, allow_variadic);
@ -1510,7 +1510,7 @@ impl Parser {
segments.push(PathSegmentAndBoundSet {
segment: ast::PathSegment {
identifier: identifier,
lifetimes: opt_vec::Empty,
lifetimes: Vec::new(),
types: opt_vec::Empty,
},
bound_set: bound_set
@ -1525,7 +1525,7 @@ impl Parser {
self.parse_generic_values_after_lt();
(true, lifetimes, opt_vec::from(types))
} else {
(false, opt_vec::Empty, opt_vec::Empty)
(false, Vec::new(), opt_vec::Empty)
}
};
@ -1621,7 +1621,7 @@ impl Parser {
// matches lifetimes = ( lifetime ) | ( lifetime , lifetimes )
// actually, it matches the empty one too, but putting that in there
// messes up the grammar....
pub fn parse_lifetimes(&mut self) -> OptVec<ast::Lifetime> {
pub fn parse_lifetimes(&mut self) -> Vec<ast::Lifetime> {
/*!
*
* Parses zero or more comma separated lifetimes.
@ -1630,7 +1630,7 @@ impl Parser {
* lists, where we expect something like `<'a, 'b, T>`.
*/
let mut res = opt_vec::Empty;
let mut res = Vec::new();
loop {
match self.token {
token::LIFETIME(_) => {
@ -1995,7 +1995,7 @@ impl Parser {
self.expect(&token::LT);
self.parse_generic_values_after_lt()
} else {
(opt_vec::Empty, Vec::new())
(Vec::new(), Vec::new())
};
// expr.f() method call
@ -3515,7 +3515,7 @@ impl Parser {
}
}
fn parse_generic_values_after_lt(&mut self) -> (OptVec<ast::Lifetime>, Vec<P<Ty>> ) {
fn parse_generic_values_after_lt(&mut self) -> (Vec<ast::Lifetime>, Vec<P<Ty>> ) {
let lifetimes = self.parse_lifetimes();
let result = self.parse_seq_to_gt(
Some(token::COMMA),
@ -4886,7 +4886,7 @@ impl Parser {
segments: path.move_iter().map(|identifier| {
ast::PathSegment {
identifier: identifier,
lifetimes: opt_vec::Empty,
lifetimes: Vec::new(),
types: opt_vec::Empty,
}
}).collect()
@ -4921,7 +4921,7 @@ impl Parser {
segments: path.move_iter().map(|identifier| {
ast::PathSegment {
identifier: identifier,
lifetimes: opt_vec::Empty,
lifetimes: Vec::new(),
types: opt_vec::Empty,
}
}).collect()
@ -4939,7 +4939,7 @@ impl Parser {
segments: path.move_iter().map(|identifier| {
ast::PathSegment {
identifier: identifier,
lifetimes: opt_vec::Empty,
lifetimes: Vec::new(),
types: opt_vec::Empty,
}
}).collect()
@ -4961,7 +4961,7 @@ impl Parser {
segments: path.move_iter().map(|identifier| {
ast::PathSegment {
identifier: identifier,
lifetimes: opt_vec::Empty,
lifetimes: Vec::new(),
types: opt_vec::Empty,
}
}).collect()