about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2018-08-06 20:54:51 -0700
committerEsteban Küber <esteban@kuber.com.ar>2018-08-06 20:54:51 -0700
commitcce4ea5149e28b938d0af8466dd9af1e489f1b55 (patch)
tree11b8991ea7a384365d36a228dc8f2e3d4e3c7ec0
parent4862eee8b762257cf28bddc41d9bb709d1fb9359 (diff)
downloadrust-cce4ea5149e28b938d0af8466dd9af1e489f1b55.tar.gz
rust-cce4ea5149e28b938d0af8466dd9af1e489f1b55.zip
Point at correct span when missing comma in `println`
-rw-r--r--src/libsyntax_ext/format.rs2
-rw-r--r--src/test/ui/codemap_tests/bad-format-args.stderr12
-rw-r--r--src/test/ui/macros/missing-comma.rs8
-rw-r--r--src/test/ui/macros/missing-comma.stderr18
4 files changed, 24 insertions, 16 deletions
diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs
index 46c85497ee7..53f8fe2b0c2 100644
--- a/src/libsyntax_ext/format.rs
+++ b/src/libsyntax_ext/format.rs
@@ -147,7 +147,7 @@ fn parse_args(ecx: &mut ExtCtxt,
     let mut named = false;
     while p.token != token::Eof {
         if !p.eat(&token::Comma) {
-            ecx.span_err(sp, "expected token: `,`");
+            ecx.span_err(p.span, "expected token: `,`");
             return None;
         }
         if p.token == token::Eof {
diff --git a/src/test/ui/codemap_tests/bad-format-args.stderr b/src/test/ui/codemap_tests/bad-format-args.stderr
index d0cdeb2178f..1c801f2a790 100644
--- a/src/test/ui/codemap_tests/bad-format-args.stderr
+++ b/src/test/ui/codemap_tests/bad-format-args.stderr
@@ -7,20 +7,16 @@ LL |     format!(); //~ ERROR requires at least a format string argument
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
 
 error: expected token: `,`
-  --> $DIR/bad-format-args.rs:13:5
+  --> $DIR/bad-format-args.rs:13:16
    |
 LL |     format!("" 1); //~ ERROR expected token: `,`
-   |     ^^^^^^^^^^^^^^
-   |
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+   |                ^
 
 error: expected token: `,`
-  --> $DIR/bad-format-args.rs:14:5
+  --> $DIR/bad-format-args.rs:14:19
    |
 LL |     format!("", 1 1); //~ ERROR expected token: `,`
-   |     ^^^^^^^^^^^^^^^^^
-   |
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+   |                   ^
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/macros/missing-comma.rs b/src/test/ui/macros/missing-comma.rs
index e69b1ff5a4d..ac82171a4e8 100644
--- a/src/test/ui/macros/missing-comma.rs
+++ b/src/test/ui/macros/missing-comma.rs
@@ -8,7 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+macro_rules! foo {
+    ($a:ident, $b:ident) => ()
+}
+
 fn main() {
     println!("{}" a);
-    //~^ ERROR no rules expected the token `a`
+    //~^ ERROR expected token: `,`
+    foo!(a b);
+    //~^ ERROR no rules expected the token `b`
 }
diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr
index cc12e43fc27..3467032d9b5 100644
--- a/src/test/ui/macros/missing-comma.stderr
+++ b/src/test/ui/macros/missing-comma.stderr
@@ -1,10 +1,16 @@
-error: no rules expected the token `a`
-  --> $DIR/missing-comma.rs:12:19
+error: expected token: `,`
+  --> $DIR/missing-comma.rs:16:19
    |
 LL |     println!("{}" a);
-   |                  -^
-   |                  |
-   |                  help: missing comma here
+   |                   ^
 
-error: aborting due to previous error
+error: no rules expected the token `b`
+  --> $DIR/missing-comma.rs:18:12
+   |
+LL |     foo!(a b);
+   |           -^
+   |           |
+   |           help: missing comma here
+
+error: aborting due to 2 previous errors