From 8a9d775888f6d413c10a823751bc14794a5a0c6d Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 10 Aug 2019 13:29:39 +0300 Subject: syntax: don't keep a redundant c_variadic flag in the AST. --- src/libsyntax/parse/parser.rs | 7 ++++--- src/libsyntax/parse/parser/expr.rs | 1 - src/libsyntax/parse/parser/item.rs | 3 +-- src/libsyntax/parse/parser/ty.rs | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index cc582819b6b..f22fd5ad703 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1194,7 +1194,7 @@ impl<'a> Parser<'a> { } fn parse_fn_params(&mut self, named_params: bool, allow_c_variadic: bool) - -> PResult<'a, (Vec , bool)> { + -> PResult<'a, Vec> { let sp = self.token.span; let mut c_variadic = false; let (params, _): (Vec>, _) = self.parse_paren_comma_seq(|p| { @@ -1218,6 +1218,8 @@ impl<'a> Parser<'a> { let span = p.token.span; p.span_err(span, "`...` must be the last argument of a C-variadic function"); + // FIXME(eddyb) this should probably still push `CVarArgs`. + // Maybe AST validation/HIR lowering should emit the above error? Ok(None) } else { Ok(Some(param)) @@ -1245,7 +1247,7 @@ impl<'a> Parser<'a> { "C-variadic function must be declared with at least one named argument"); } - Ok((params, c_variadic)) + Ok(params) } /// Returns the parsed optional self parameter and whether a self shortcut was used. @@ -1414,7 +1416,6 @@ impl<'a> Parser<'a> { Ok(P(FnDecl { inputs: fn_inputs, output: self.parse_ret_ty(true)?, - c_variadic: false })) } diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index c776704b285..23674ad589d 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -1176,7 +1176,6 @@ impl<'a> Parser<'a> { Ok(P(FnDecl { inputs: inputs_captures, output, - c_variadic: false })) } diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index 370030d02c7..92b19b73e57 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -1292,13 +1292,12 @@ impl<'a> Parser<'a> { /// Parses the argument list and result type of a function declaration. fn parse_fn_decl(&mut self, allow_c_variadic: bool) -> PResult<'a, P> { - let (args, c_variadic) = self.parse_fn_params(true, allow_c_variadic)?; + let args = self.parse_fn_params(true, allow_c_variadic)?; let ret_ty = self.parse_ret_ty(true)?; Ok(P(FnDecl { inputs: args, output: ret_ty, - c_variadic, })) } diff --git a/src/libsyntax/parse/parser/ty.rs b/src/libsyntax/parse/parser/ty.rs index b4c006ca2b1..c52d3733b5e 100644 --- a/src/libsyntax/parse/parser/ty.rs +++ b/src/libsyntax/parse/parser/ty.rs @@ -292,12 +292,11 @@ impl<'a> Parser<'a> { }; self.expect_keyword(kw::Fn)?; - let (inputs, c_variadic) = self.parse_fn_params(false, true)?; + let inputs = self.parse_fn_params(false, true)?; let ret_ty = self.parse_ret_ty(false)?; let decl = P(FnDecl { inputs, output: ret_ty, - c_variadic, }); Ok(TyKind::BareFn(P(BareFnTy { abi, -- cgit 1.4.1-3-g733a5