From d7086cac3dd8647d6d8043fc1662fb5fbb895df3 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 22 May 2018 13:29:28 -0700 Subject: [PATCH] Fix span for type-only arguments --- src/libsyntax/parse/parser.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 49b30c6f460fe..15ae0198e6811 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1761,27 +1761,27 @@ impl<'a> Parser<'a> { pub fn parse_arg_general(&mut self, require_name: bool) -> PResult<'a, Arg> { maybe_whole!(self, NtArg, |x| x); - let pat = if require_name || self.is_named_argument() { + let (pat, ty) = if require_name || self.is_named_argument() { debug!("parse_arg_general parse_pat (require_name:{})", require_name); let pat = self.parse_pat()?; self.expect(&token::Colon)?; - pat + (pat, self.parse_ty()?) } else { debug!("parse_arg_general ident_to_pat"); let ident = Ident::new(keywords::Invalid.name(), self.prev_span); - P(Pat { + let ty = self.parse_ty()?; + let pat = P(Pat { id: ast::DUMMY_NODE_ID, node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None), - span: ident.span, - }) + span: ty.span, + }); + (pat, ty) }; - let t = self.parse_ty()?; - Ok(Arg { - ty: t, + ty, pat, id: ast::DUMMY_NODE_ID, })