diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index c183160168f8..a6694cea7313 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1031,13 +1031,10 @@ impl<'a> Parser<'a> {
let pat = self.mk_pat_ident(ty.span, bm, ident);
(pat, ty)
}
+ // If this is a C-variadic argument and we hit an error, return the error.
+ Err(err) if self.token == token::DotDotDot => return Err(err),
+ // Recover from attempting to parse the argument as a type without pattern.
Err(mut err) => {
- // If this is a C-variadic argument and we hit an error, return the
- // error.
- if self.token == token::DotDotDot {
- return Err(err);
- }
- // Recover from attempting to parse the argument as a type without pattern.
err.cancel();
mem::replace(self, parser_snapshot_before_ty);
self.recover_arg_parse()?
@@ -1200,42 +1197,44 @@ impl<'a> Parser<'a> {
}
- fn parse_fn_params(&mut self, named_params: bool, allow_c_variadic: bool)
- -> PResult<'a, Vec> {
+ fn parse_fn_params(
+ &mut self,
+ named_params: bool,
+ allow_c_variadic: bool,
+ ) -> PResult<'a, Vec> {
let sp = self.token.span;
+ let do_not_enforce_named_params_for_c_variadic = |token: &token::Token| {
+ match token.kind {
+ token::DotDotDot => false,
+ _ => named_params,
+ }
+ };
let mut c_variadic = false;
- let (params, _): (Vec