Skip to content

Commit 6441ebe

Browse files
authored
Rollup merge of rust-lang#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 rust-lang#48309 r? @estebank
2 parents e14bc2d + d7086ca commit 6441ebe

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/libsyntax/parse/parser.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1771,27 +1771,27 @@ impl<'a> Parser<'a> {
17711771
pub fn parse_arg_general(&mut self, require_name: bool) -> PResult<'a, Arg> {
17721772
maybe_whole!(self, NtArg, |x| x);
17731773

1774-
let pat = if require_name || self.is_named_argument() {
1774+
let (pat, ty) = if require_name || self.is_named_argument() {
17751775
debug!("parse_arg_general parse_pat (require_name:{})",
17761776
require_name);
17771777
let pat = self.parse_pat()?;
17781778

17791779
self.expect(&token::Colon)?;
1780-
pat
1780+
(pat, self.parse_ty()?)
17811781
} else {
17821782
debug!("parse_arg_general ident_to_pat");
17831783
let ident = Ident::new(keywords::Invalid.name(), self.prev_span);
1784-
P(Pat {
1784+
let ty = self.parse_ty()?;
1785+
let pat = P(Pat {
17851786
id: ast::DUMMY_NODE_ID,
17861787
node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None),
1787-
span: ident.span,
1788-
})
1788+
span: ty.span,
1789+
});
1790+
(pat, ty)
17891791
};
17901792

1791-
let t = self.parse_ty()?;
1792-
17931793
Ok(Arg {
1794-
ty: t,
1794+
ty,
17951795
pat,
17961796
id: ast::DUMMY_NODE_ID,
17971797
})

0 commit comments

Comments
 (0)