about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-12-14 07:06:02 +0000
committerbors <bors@rust-lang.org>2017-12-14 07:06:02 +0000
commit8954b16beb844fcac0cefe229e1c714a17de16e5 (patch)
tree07e11d44c2885af6b96cf276f5c62d9d3ad4acaf /src/test
parentf03e06762ea6c4116c360185c0e9b6f209b76959 (diff)
parentd4b8e99540ed815f7c0187cf2db8a2e4c0a61d8f (diff)
downloadrust-8954b16beb844fcac0cefe229e1c714a17de16e5.tar.gz
rust-8954b16beb844fcac0cefe229e1c714a17de16e5.zip
Auto merge of #46605 - estebank:macro-backtrace-spans, r=pnkfelix
Use spans for -Z external-macro-backtrace

```
% rustc ui/type-check/cannot_infer_local_or_vec.rs -Z external-macro-backtrace
error[E0282]: type annotations needed
  --> <vec macros>:3:1
   |
1  | / ( $ elem : expr ; $ n : expr ) => (
2  | | $ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (
3  | | < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ) ) ; ( $ ( $ x : expr , ) * )
   | | ^^^^^^^^^^^^^^^^^^^^^
   | | |
   | | cannot infer type for `T`
4  | | => ( vec ! [ $ ( $ x ) , * ] )
   | |______________________________- in this expansion of `vec!`
   |
  ::: ui/type-check/cannot_infer_local_or_vec.rs
   |
12 |       let x = vec![];
   |           -   ------ in this macro invocation
   |           |
   |           consider giving `x` a type

error: aborting due to previous error
```
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/macro_backtrace/auxiliary/ping.rs21
-rw-r--r--src/test/ui/macro_backtrace/main.rs7
-rw-r--r--src/test/ui/macro_backtrace/main.stderr77
3 files changed, 95 insertions, 10 deletions
diff --git a/src/test/ui/macro_backtrace/auxiliary/ping.rs b/src/test/ui/macro_backtrace/auxiliary/ping.rs
index eeed0d78158..e4131dde8f7 100644
--- a/src/test/ui/macro_backtrace/auxiliary/ping.rs
+++ b/src/test/ui/macro_backtrace/auxiliary/ping.rs
@@ -18,3 +18,24 @@ macro_rules! ping {
     }
 }
 
+#[macro_export]
+macro_rules! deep {
+    () => {
+        foo!();
+    }
+}
+
+#[macro_export]
+macro_rules! foo {
+    () => {
+        bar!();
+    }
+}
+
+#[macro_export]
+macro_rules! bar {
+    () => {
+        ping!();
+    }
+}
+
diff --git a/src/test/ui/macro_backtrace/main.rs b/src/test/ui/macro_backtrace/main.rs
index ec9218e3ec0..72a5c0d5e37 100644
--- a/src/test/ui/macro_backtrace/main.rs
+++ b/src/test/ui/macro_backtrace/main.rs
@@ -16,11 +16,14 @@
 
 // a local macro
 macro_rules! pong {
-    () => { syntax error }; //~ ERROR expected one of
-    //~^ ERROR expected one of
+    () => { syntax error };
 }
+//~^^ ERROR expected one of
+//~| ERROR expected one of
+//~| ERROR expected one of
 
 fn main() {
     pong!();
     ping!();
+    deep!();
 }
diff --git a/src/test/ui/macro_backtrace/main.stderr b/src/test/ui/macro_backtrace/main.stderr
index 4b10e5e19a3..5990f71b3ca 100644
--- a/src/test/ui/macro_backtrace/main.stderr
+++ b/src/test/ui/macro_backtrace/main.stderr
@@ -1,17 +1,78 @@
 error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
   --> $DIR/main.rs:19:20
    |
-19 |     () => { syntax error }; //~ ERROR expected one of
-   |                    ^^^^^ expected one of 8 possible tokens here
-$DIR/main.rs:24:5: 24:13 note: in this expansion of pong! (defined in $DIR/main.rs)
+18 | / macro_rules! pong {
+19 | |     () => { syntax error };
+   | |                    ^^^^^ expected one of 8 possible tokens here
+20 | | }
+   | |_- in this expansion of `pong!`
+...
+26 |       pong!();
+   |       -------- in this macro invocation
 
 error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
   --> $DIR/main.rs:19:20
    |
-19 |     () => { syntax error }; //~ ERROR expected one of
-   |                    ^^^^^ expected one of 8 possible tokens here
-$DIR/main.rs:25:5: 25:13 note: in this expansion of ping! (defined in <ping macros>)
-<ping macros>:1:11: 1:24 note: in this expansion of pong! (defined in $DIR/main.rs)
+18 | / macro_rules! pong {
+19 | |     () => { syntax error };
+   | |                    ^^^^^ expected one of 8 possible tokens here
+20 | | }
+   | |_- in this expansion of `pong!`
+...
+27 |       ping!();
+   |       -------- in this macro invocation
+   | 
+  ::: <ping macros>
+   |
+1  |   (  ) => { pong ! (  ) ; }
+   |   -------------------------
+   |   |         |
+   |   |         in this macro invocation
+   |   in this expansion of `ping!`
+
+error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
+  --> $DIR/main.rs:19:20
+   |
+18 | / macro_rules! pong {
+19 | |     () => { syntax error };
+   | |                    ^^^^^ expected one of 8 possible tokens here
+20 | | }
+   | |_- in this expansion of `pong!` (#5)
+...
+28 |       deep!();
+   |       -------- in this macro invocation (#1)
+   | 
+  ::: <deep macros>
+   |
+1  |   (  ) => { foo ! (  ) ; }
+   |   ------------------------
+   |   |         |
+   |   |         in this macro invocation (#2)
+   |   in this expansion of `deep!` (#1)
+   | 
+  ::: <foo macros>
+   |
+1  |   (  ) => { bar ! (  ) ; }
+   |   ------------------------
+   |   |         |
+   |   |         in this macro invocation (#3)
+   |   in this expansion of `foo!` (#2)
+   | 
+  ::: <bar macros>
+   |
+1  |   (  ) => { ping ! (  ) ; }
+   |   -------------------------
+   |   |         |
+   |   |         in this macro invocation (#4)
+   |   in this expansion of `bar!` (#3)
+   | 
+  ::: <ping macros>
+   |
+1  |   (  ) => { pong ! (  ) ; }
+   |   -------------------------
+   |   |         |
+   |   |         in this macro invocation (#5)
+   |   in this expansion of `ping!` (#4)
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors