Skip to content

Commit cce4ea5

Browse files
committed
Point at correct span when missing comma in println
1 parent 4862eee commit cce4ea5

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

src/libsyntax_ext/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn parse_args(ecx: &mut ExtCtxt,
147147
let mut named = false;
148148
while p.token != token::Eof {
149149
if !p.eat(&token::Comma) {
150-
ecx.span_err(sp, "expected token: `,`");
150+
ecx.span_err(p.span, "expected token: `,`");
151151
return None;
152152
}
153153
if p.token == token::Eof {

src/test/ui/codemap_tests/bad-format-args.stderr

+4-8
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@ LL | format!(); //~ ERROR requires at least a format string argument
77
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
88

99
error: expected token: `,`
10-
--> $DIR/bad-format-args.rs:13:5
10+
--> $DIR/bad-format-args.rs:13:16
1111
|
1212
LL | format!("" 1); //~ ERROR expected token: `,`
13-
| ^^^^^^^^^^^^^^
14-
|
15-
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
13+
| ^
1614

1715
error: expected token: `,`
18-
--> $DIR/bad-format-args.rs:14:5
16+
--> $DIR/bad-format-args.rs:14:19
1917
|
2018
LL | format!("", 1 1); //~ ERROR expected token: `,`
21-
| ^^^^^^^^^^^^^^^^^
22-
|
23-
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
19+
| ^
2420

2521
error: aborting due to 3 previous errors
2622

src/test/ui/macros/missing-comma.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
macro_rules! foo {
12+
($a:ident, $b:ident) => ()
13+
}
14+
1115
fn main() {
1216
println!("{}" a);
13-
//~^ ERROR no rules expected the token `a`
17+
//~^ ERROR expected token: `,`
18+
foo!(a b);
19+
//~^ ERROR no rules expected the token `b`
1420
}
+12-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
error: no rules expected the token `a`
2-
--> $DIR/missing-comma.rs:12:19
1+
error: expected token: `,`
2+
--> $DIR/missing-comma.rs:16:19
33
|
44
LL | println!("{}" a);
5-
| -^
6-
| |
7-
| help: missing comma here
5+
| ^
86

9-
error: aborting due to previous error
7+
error: no rules expected the token `b`
8+
--> $DIR/missing-comma.rs:18:12
9+
|
10+
LL | foo!(a b);
11+
| -^
12+
| |
13+
| help: missing comma here
14+
15+
error: aborting due to 2 previous errors
1016

0 commit comments

Comments
 (0)