diff options
| author | bors <bors@rust-lang.org> | 2014-04-24 07:06:26 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-04-24 07:06:26 -0700 |
| commit | 70647ccc6de1c319de647a2b8d75b667e88fbfd0 (patch) | |
| tree | 716d2ba3a2b8791d5a782bee9726aacad92cd135 /src/libsyntax | |
| parent | f5a5d7c32ca863533e53175da8afab6ba8d20f30 (diff) | |
| parent | 899f22238669bade874f29f784cdffba28ff0982 (diff) | |
| download | rust-70647ccc6de1c319de647a2b8d75b667e88fbfd0.tar.gz rust-70647ccc6de1c319de647a2b8d75b667e88fbfd0.zip | |
auto merge of #13713 : edwardw/rust/methodcall-span, r=alexcrichton
Specifically, the method parameter cardinality mismatch or missing method error message span now gets method itself exactly. It was the whole expression. Closes #9390 Closes #13684 Closes #13709
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 2 |
5 files changed, 14 insertions, 7 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4a93fed8d03..ccb25239f6c 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -481,7 +481,7 @@ pub enum Expr_ { ExprBox(@Expr, @Expr), ExprVec(Vec<@Expr>), ExprCall(@Expr, Vec<@Expr>), - ExprMethodCall(Ident, Vec<P<Ty>>, Vec<@Expr>), + ExprMethodCall(SpannedIdent, Vec<P<Ty>>, Vec<@Expr>), ExprTup(Vec<@Expr>), ExprBinary(BinOp, @Expr, @Expr), ExprUnary(UnOp, @Expr), diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index b0dbd8b635a..1a160cb33aa 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -12,7 +12,7 @@ use abi; use ast::{P, Ident}; use ast; use ast_util; -use codemap::{Span, respan, DUMMY_SP}; +use codemap::{Span, respan, Spanned, DUMMY_SP}; use ext::base::ExtCtxt; use ext::quote::rt::*; use fold::Folder; @@ -548,8 +548,9 @@ impl<'a> AstBuilder for ExtCtxt<'a> { expr: @ast::Expr, ident: ast::Ident, mut args: Vec<@ast::Expr> ) -> @ast::Expr { + let id = Spanned { node: ident, span: span }; args.unshift(expr); - self.expr(span, ast::ExprMethodCall(ident, Vec::new(), args)) + self.expr(span, ast::ExprMethodCall(id, Vec::new(), args)) } fn expr_block(&self, b: P<ast::Block>) -> @ast::Expr { self.expr(b.span, ast::ExprBlock(b)) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 9f05db5f807..ae82a07601b 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -798,7 +798,7 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { } ExprMethodCall(i, ref tps, ref args) => { ExprMethodCall( - folder.fold_ident(i), + respan(i.span, folder.fold_ident(i.node)), tps.iter().map(|&x| folder.fold_ty(x)).collect(), args.iter().map(|&x| folder.fold_expr(x)).collect()) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f30d756d854..974077956d1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1646,7 +1646,11 @@ impl<'a> Parser<'a> { ExprCall(f, args) } - fn mk_method_call(&mut self, ident: Ident, tps: Vec<P<Ty>> , args: Vec<@Expr> ) -> ast::Expr_ { + fn mk_method_call(&mut self, + ident: ast::SpannedIdent, + tps: Vec<P<Ty>>, + args: Vec<@Expr>) + -> ast::Expr_ { ExprMethodCall(ident, tps, args) } @@ -1919,6 +1923,7 @@ impl<'a> Parser<'a> { if self.eat(&token::DOT) { match self.token { token::IDENT(i, _) => { + let dot = self.last_span.hi; hi = self.span.hi; self.bump(); let (_, tys) = if self.eat(&token::MOD_SEP) { @@ -1940,7 +1945,8 @@ impl<'a> Parser<'a> { hi = self.last_span.hi; es.unshift(e); - let nd = self.mk_method_call(i, tys, es); + let id = spanned(dot, hi, i); + let nd = self.mk_method_call(id, tys, es); e = self.mk_expr(lo, hi, nd); } _ => { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index b0130f127a3..9d3f7cbc69a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1208,7 +1208,7 @@ impl<'a> State<'a> { let base_args = args.slice_from(1); try!(self.print_expr(*args.get(0))); try!(word(&mut self.s, ".")); - try!(self.print_ident(ident)); + try!(self.print_ident(ident.node)); if tys.len() > 0u { try!(word(&mut self.s, "::<")); try!(self.commasep(Inconsistent, tys.as_slice(), |
