1
Fork 0

Point to macro def span instead of whole body

This commit is contained in:
Esteban Küber 2018-10-24 11:34:23 -07:00
parent 8227a938a4
commit 1ab45ec7e3
11 changed files with 107 additions and 179 deletions

View file

@ -187,7 +187,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
err.span_label(span, best_fail_msg); err.span_label(span, best_fail_msg);
if let Some(sp) = def_span { if let Some(sp) = def_span {
if cx.source_map().span_to_filename(sp).is_real() && !sp.is_dummy() { if cx.source_map().span_to_filename(sp).is_real() && !sp.is_dummy() {
err.span_label(sp, "when calling this macro"); err.span_label(cx.source_map().def_span(sp), "when calling this macro");
} }
} }

View file

@ -1,10 +1,8 @@
error: unexpected end of macro invocation error: unexpected end of macro invocation
--> $DIR/empty-comment.rs:20:5 --> $DIR/empty-comment.rs:20:5
| |
LL | / macro_rules! one_arg_macro { LL | macro_rules! one_arg_macro {
LL | | ($fmt:expr) => (print!(concat!($fmt, "/n"))); | -------------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | one_arg_macro!(/**/); //~ ERROR unexpected end LL | one_arg_macro!(/**/); //~ ERROR unexpected end
| ^^^^^^^^^^^^^^^^^^^^^ unexpected end of macro invocation | ^^^^^^^^^^^^^^^^^^^^^ unexpected end of macro invocation

View file

@ -1,10 +1,8 @@
error: unexpected end of macro invocation error: unexpected end of macro invocation
--> $DIR/issue-7970a.rs:16:5 --> $DIR/issue-7970a.rs:16:5
| |
LL | / macro_rules! one_arg_macro { LL | macro_rules! one_arg_macro {
LL | | ($fmt:expr) => (print!(concat!($fmt, "/n"))); | -------------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | one_arg_macro!(); LL | one_arg_macro!();
| ^^^^^^^^^^^^^^^^^ unexpected end of macro invocation | ^^^^^^^^^^^^^^^^^ unexpected end of macro invocation

View file

@ -51,12 +51,8 @@ LL | ($(a)?*) => {}
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:41:11 --> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:41:11
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($(a)?) => {} | ---------------- when calling this macro
LL | | //~^ERROR using the `?` macro Kleene operator for
LL | | //~|ERROR expected `*` or `+`
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a?); //~ ERROR no rules expected the token `?` LL | foo!(a?); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`
@ -64,12 +60,8 @@ LL | foo!(a?); //~ ERROR no rules expected the token `?`
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:42:11 --> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:42:11
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($(a)?) => {} | ---------------- when calling this macro
LL | | //~^ERROR using the `?` macro Kleene operator for
LL | | //~|ERROR expected `*` or `+`
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a?a); //~ ERROR no rules expected the token `?` LL | foo!(a?a); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`
@ -77,12 +69,8 @@ LL | foo!(a?a); //~ ERROR no rules expected the token `?`
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:43:11 --> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:43:11
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($(a)?) => {} | ---------------- when calling this macro
LL | | //~^ERROR using the `?` macro Kleene operator for
LL | | //~|ERROR expected `*` or `+`
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`

View file

@ -7,10 +7,8 @@ LL | ($(a),?) => {} //~ERROR the `?` macro repetition operator
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018.rs:36:11 --> $DIR/macro-at-most-once-rep-2018.rs:36:11
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($(a)?) => {} | ---------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a?); //~ ERROR no rules expected the token `?` LL | foo!(a?); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`
@ -18,10 +16,8 @@ LL | foo!(a?); //~ ERROR no rules expected the token `?`
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018.rs:37:11 --> $DIR/macro-at-most-once-rep-2018.rs:37:11
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($(a)?) => {} | ---------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a?a); //~ ERROR no rules expected the token `?` LL | foo!(a?a); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`
@ -29,10 +25,8 @@ LL | foo!(a?a); //~ ERROR no rules expected the token `?`
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018.rs:38:11 --> $DIR/macro-at-most-once-rep-2018.rs:38:11
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($(a)?) => {} | ---------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`
@ -40,10 +34,8 @@ LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
error: unexpected end of macro invocation error: unexpected end of macro invocation
--> $DIR/macro-at-most-once-rep-2018.rs:40:5 --> $DIR/macro-at-most-once-rep-2018.rs:40:5
| |
LL | / macro_rules! barplus { LL | macro_rules! barplus {
LL | | ($(a)?+) => {} // ok. matches "a+" and "+" | -------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | barplus!(); //~ERROR unexpected end of macro invocation LL | barplus!(); //~ERROR unexpected end of macro invocation
| ^^^^^^^^^^^ unexpected end of macro invocation | ^^^^^^^^^^^ unexpected end of macro invocation
@ -51,10 +43,8 @@ LL | barplus!(); //~ERROR unexpected end of macro invocation
error: unexpected end of macro invocation error: unexpected end of macro invocation
--> $DIR/macro-at-most-once-rep-2018.rs:41:14 --> $DIR/macro-at-most-once-rep-2018.rs:41:14
| |
LL | / macro_rules! barplus { LL | macro_rules! barplus {
LL | | ($(a)?+) => {} // ok. matches "a+" and "+" | -------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | barplus!(a); //~ERROR unexpected end of macro invocation LL | barplus!(a); //~ERROR unexpected end of macro invocation
| ^ unexpected end of macro invocation | ^ unexpected end of macro invocation
@ -62,10 +52,8 @@ LL | barplus!(a); //~ERROR unexpected end of macro invocation
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018.rs:42:15 --> $DIR/macro-at-most-once-rep-2018.rs:42:15
| |
LL | / macro_rules! barplus { LL | macro_rules! barplus {
LL | | ($(a)?+) => {} // ok. matches "a+" and "+" | -------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | barplus!(a?); //~ ERROR no rules expected the token `?` LL | barplus!(a?); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`
@ -73,10 +61,8 @@ LL | barplus!(a?); //~ ERROR no rules expected the token `?`
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018.rs:43:15 --> $DIR/macro-at-most-once-rep-2018.rs:43:15
| |
LL | / macro_rules! barplus { LL | macro_rules! barplus {
LL | | ($(a)?+) => {} // ok. matches "a+" and "+" | -------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | barplus!(a?a); //~ ERROR no rules expected the token `?` LL | barplus!(a?a); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`
@ -84,10 +70,8 @@ LL | barplus!(a?a); //~ ERROR no rules expected the token `?`
error: unexpected end of macro invocation error: unexpected end of macro invocation
--> $DIR/macro-at-most-once-rep-2018.rs:47:5 --> $DIR/macro-at-most-once-rep-2018.rs:47:5
| |
LL | / macro_rules! barstar { LL | macro_rules! barstar {
LL | | ($(a)?*) => {} // ok. matches "a*" and "*" | -------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | barstar!(); //~ERROR unexpected end of macro invocation LL | barstar!(); //~ERROR unexpected end of macro invocation
| ^^^^^^^^^^^ unexpected end of macro invocation | ^^^^^^^^^^^ unexpected end of macro invocation
@ -95,10 +79,8 @@ LL | barstar!(); //~ERROR unexpected end of macro invocation
error: unexpected end of macro invocation error: unexpected end of macro invocation
--> $DIR/macro-at-most-once-rep-2018.rs:48:14 --> $DIR/macro-at-most-once-rep-2018.rs:48:14
| |
LL | / macro_rules! barstar { LL | macro_rules! barstar {
LL | | ($(a)?*) => {} // ok. matches "a*" and "*" | -------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | barstar!(a); //~ERROR unexpected end of macro invocation LL | barstar!(a); //~ERROR unexpected end of macro invocation
| ^ unexpected end of macro invocation | ^ unexpected end of macro invocation
@ -106,10 +88,8 @@ LL | barstar!(a); //~ERROR unexpected end of macro invocation
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018.rs:49:15 --> $DIR/macro-at-most-once-rep-2018.rs:49:15
| |
LL | / macro_rules! barstar { LL | macro_rules! barstar {
LL | | ($(a)?*) => {} // ok. matches "a*" and "*" | -------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | barstar!(a?); //~ ERROR no rules expected the token `?` LL | barstar!(a?); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`
@ -117,10 +97,8 @@ LL | barstar!(a?); //~ ERROR no rules expected the token `?`
error: no rules expected the token `?` error: no rules expected the token `?`
--> $DIR/macro-at-most-once-rep-2018.rs:50:15 --> $DIR/macro-at-most-once-rep-2018.rs:50:15
| |
LL | / macro_rules! barstar { LL | macro_rules! barstar {
LL | | ($(a)?*) => {} // ok. matches "a*" and "*" | -------------------- when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | barstar!(a?a); //~ ERROR no rules expected the token `?` LL | barstar!(a?a); //~ ERROR no rules expected the token `?`
| ^ no rules expected the token `?` | ^ no rules expected the token `?`

View file

@ -2,7 +2,7 @@ error: no rules expected the token `a`
--> $DIR/macro-non-lifetime.rs:18:8 --> $DIR/macro-non-lifetime.rs:18:8
| |
LL | macro_rules! m { ($x:lifetime) => { } } LL | macro_rules! m { ($x:lifetime) => { } }
| --------------------------------------- when calling this macro | -------------- when calling this macro
... ...
LL | m!(a); LL | m!(a);
| ^ no rules expected the token `a` | ^ no rules expected the token `a`

View file

@ -7,14 +7,8 @@ LL | println!("{}" a);
error: no rules expected the token `b` error: no rules expected the token `b`
--> $DIR/missing-comma.rs:22:12 --> $DIR/missing-comma.rs:22:12
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($a:ident) => (); | ---------------- when calling this macro
LL | | ($a:ident, $b:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => ();
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a b); LL | foo!(a b);
| -^ no rules expected the token `b` | -^ no rules expected the token `b`
@ -24,14 +18,8 @@ LL | foo!(a b);
error: no rules expected the token `e` error: no rules expected the token `e`
--> $DIR/missing-comma.rs:24:21 --> $DIR/missing-comma.rs:24:21
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($a:ident) => (); | ---------------- when calling this macro
LL | | ($a:ident, $b:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => ();
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a, b, c, d e); LL | foo!(a, b, c, d e);
| -^ no rules expected the token `e` | -^ no rules expected the token `e`
@ -41,14 +29,8 @@ LL | foo!(a, b, c, d e);
error: no rules expected the token `d` error: no rules expected the token `d`
--> $DIR/missing-comma.rs:26:18 --> $DIR/missing-comma.rs:26:18
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($a:ident) => (); | ---------------- when calling this macro
LL | | ($a:ident, $b:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => ();
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a, b, c d, e); LL | foo!(a, b, c d, e);
| -^ no rules expected the token `d` | -^ no rules expected the token `d`
@ -58,14 +40,8 @@ LL | foo!(a, b, c d, e);
error: no rules expected the token `d` error: no rules expected the token `d`
--> $DIR/missing-comma.rs:28:18 --> $DIR/missing-comma.rs:28:18
| |
LL | / macro_rules! foo { LL | macro_rules! foo {
LL | | ($a:ident) => (); | ---------------- when calling this macro
LL | | ($a:ident, $b:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident, $d:ident) => ();
LL | | ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => ();
LL | | }
| |_- when calling this macro
... ...
LL | foo!(a, b, c d e); LL | foo!(a, b, c d e);
| ^ no rules expected the token `d` | ^ no rules expected the token `d`

View file

@ -1,13 +1,11 @@
error: no rules expected the token `bcd` error: no rules expected the token `bcd`
--> $DIR/trace_faulty_macros.rs:17:26 --> $DIR/trace_faulty_macros.rs:17:26
| |
LL | / macro_rules! my_faulty_macro { LL | macro_rules! my_faulty_macro {
LL | | () => { | ---------------------------- when calling this macro
LL | | my_faulty_macro!(bcd); //~ ERROR no rules LL | () => {
| | ^^^ no rules expected the token `bcd` LL | my_faulty_macro!(bcd); //~ ERROR no rules
LL | | }; | ^^^ no rules expected the token `bcd`
LL | | }
| |_- when calling this macro
... ...
LL | my_faulty_macro!(); LL | my_faulty_macro!();
| ------------------- in this macro invocation | ------------------- in this macro invocation

View file

@ -1,10 +1,8 @@
error: no rules expected the token `!` error: no rules expected the token `!`
--> $DIR/macro-doc-comments-1.rs:16:5 --> $DIR/macro-doc-comments-1.rs:16:5
| |
LL | / macro_rules! outer { LL | macro_rules! outer {
LL | | (#[$outer:meta]) => () | ------------------ when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | //! Inner LL | //! Inner
| ^^^^^^^^^ no rules expected the token `!` | ^^^^^^^^^ no rules expected the token `!`

View file

@ -1,10 +1,8 @@
error: no rules expected the token `[` error: no rules expected the token `[`
--> $DIR/macro-doc-comments-2.rs:16:5 --> $DIR/macro-doc-comments-2.rs:16:5
| |
LL | / macro_rules! inner { LL | macro_rules! inner {
LL | | (#![$inner:meta]) => () | ------------------ when calling this macro
LL | | }
| |_- when calling this macro
... ...
LL | /// Outer LL | /// Outer
| ^ no rules expected the token `[` | ^ no rules expected the token `[`

View file

@ -1,12 +1,8 @@
error: no rules expected the token `_` error: no rules expected the token `_`
--> $DIR/underscore-ident-matcher.rs:18:19 --> $DIR/underscore-ident-matcher.rs:18:19
| |
LL | / macro_rules! identity { LL | macro_rules! identity {
LL | | ($i: ident) => ( | --------------------- when calling this macro
LL | | $i
LL | | )
LL | | }
| |_- when calling this macro
... ...
LL | let identity!(_) = 10; //~ ERROR no rules expected the token `_` LL | let identity!(_) = 10; //~ ERROR no rules expected the token `_`
| ^ no rules expected the token `_` | ^ no rules expected the token `_`