Skip to content

Commit

Permalink
Rollup merge of rust-lang#50979 - Manishearth:type-only, r=estebank
Browse files Browse the repository at this point in the history
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 rust-lang#48309

r? @estebank
  • Loading branch information
kennytm authored May 24, 2018
2 parents e14bc2d + d7086ca commit 6441ebe
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down

0 comments on commit 6441ebe

Please sign in to comment.