Skip to content

Commit 121778e

Browse files
committed
syntax: replace Vec::push_all with stable Vec::extend
1 parent ff71207 commit 121778e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,11 @@ impl<'a> Parser<'a> {
436436
// leave it in the input
437437
Ok(())
438438
} else {
439-
let mut expected = edible.iter().map(|x| TokenType::Token(x.clone()))
440-
.collect::<Vec<_>>();
441-
expected.extend(inedible.iter().map(|x| TokenType::Token(x.clone())));
442-
expected.push_all(&*self.expected_tokens);
439+
let mut expected = edible.iter()
440+
.map(|x| TokenType::Token(x.clone()))
441+
.chain(inedible.iter().map(|x| TokenType::Token(x.clone())))
442+
.chain(self.expected_tokens.iter().cloned())
443+
.collect::<Vec<_>>();
443444
expected.sort_by(|a, b| a.to_string().cmp(&b.to_string()));
444445
expected.dedup();
445446
let expect = tokens_to_string(&expected[..]);
@@ -490,8 +491,10 @@ impl<'a> Parser<'a> {
490491
debug!("commit_expr {:?}", e);
491492
if let ExprPath(..) = e.node {
492493
// might be unit-struct construction; check for recoverableinput error.
493-
let mut expected = edible.iter().cloned().collect::<Vec<_>>();
494-
expected.push_all(inedible);
494+
let expected = edible.iter()
495+
.cloned()
496+
.chain(inedible.iter().cloned())
497+
.collect::<Vec<_>>();
495498
try!(self.check_for_erroneous_unit_struct_expecting(&expected[..]));
496499
}
497500
self.expect_one_of(edible, inedible)
@@ -509,8 +512,10 @@ impl<'a> Parser<'a> {
509512
if self.last_token
510513
.as_ref()
511514
.map_or(false, |t| t.is_ident() || t.is_path()) {
512-
let mut expected = edible.iter().cloned().collect::<Vec<_>>();
513-
expected.push_all(&inedible);
515+
let expected = edible.iter()
516+
.cloned()
517+
.chain(inedible.iter().cloned())
518+
.collect::<Vec<_>>();
514519
try!(self.check_for_erroneous_unit_struct_expecting(&expected));
515520
}
516521
self.expect_one_of(edible, inedible)
@@ -1187,7 +1192,7 @@ impl<'a> Parser<'a> {
11871192
debug!("parse_trait_methods(): parsing provided method");
11881193
let (inner_attrs, body) =
11891194
try!(p.parse_inner_attrs_and_block());
1190-
attrs.push_all(&inner_attrs[..]);
1195+
attrs.extend(inner_attrs.iter().cloned());
11911196
Some(body)
11921197
}
11931198

0 commit comments

Comments
 (0)