diff options
| author | kennytm <kennytm@gmail.com> | 2018-05-24 16:02:42 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-24 16:02:42 +0800 |
| commit | 6441ebe5a7e7d5274136b81d8c6cc037b37e9aeb (patch) | |
| tree | a9d4fa0e7a13f2fe8f56ca29f3adffb5d8c803e7 /src/libsyntax/parse | |
| parent | e14bc2d3d4fa637044446880bbd0e17d265670f9 (diff) | |
| parent | d7086cac3dd8647d6d8043fc1662fb5fbb895df3 (diff) | |
| download | rust-6441ebe5a7e7d5274136b81d8c6cc037b37e9aeb.tar.gz rust-6441ebe5a7e7d5274136b81d8c6cc037b37e9aeb.zip | |
Rollup merge of #50979 - Manishearth:type-only, r=estebank
Fix span for type-only arguments Currently it points to the comma or parenthesis before the type, which is broken cc @mark-i-m this is what broke #48309 r? @estebank
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1429d881fe9..2e668963240 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1771,27 +1771,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, }) |
