]> git.lizzy.rs Git - rust.git/blob - tests/ui/proc-macro/parent-source-spans.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / proc-macro / parent-source-spans.rs
1 // aux-build:parent-source-spans.rs
2
3 #![feature(decl_macro)]
4
5 extern crate parent_source_spans;
6
7 use parent_source_spans::parent_source_spans;
8
9 macro one($a:expr, $b:expr) {
10     two!($a, $b);
11     //~^ ERROR first parent: "hello"
12     //~| ERROR second parent: "world"
13 }
14
15 macro two($a:expr, $b:expr) {
16     three!($a, $b);
17     //~^ ERROR first final: "hello"
18     //~| ERROR second final: "world"
19     //~| ERROR first final: "yay"
20     //~| ERROR second final: "rust"
21 }
22
23 // forwarding tokens directly doesn't create a new source chain
24 macro three($($tokens:tt)*) {
25     four!($($tokens)*);
26 }
27
28 macro four($($tokens:tt)*) {
29     parent_source_spans!($($tokens)*);
30     //~^ ERROR cannot find value `ok` in this scope
31     //~| ERROR cannot find value `ok` in this scope
32     //~| ERROR cannot find value `ok` in this scope
33 }
34
35 fn main() {
36     one!("hello", "world");
37     //~^ ERROR first grandparent: "hello"
38     //~| ERROR second grandparent: "world"
39     //~| ERROR first source: "hello"
40     //~| ERROR second source: "world"
41
42     two!("yay", "rust");
43     //~^ ERROR first parent: "yay"
44     //~| ERROR second parent: "rust"
45     //~| ERROR first source: "yay"
46     //~| ERROR second source: "rust"
47
48     three!("hip", "hop");
49     //~^ ERROR first final: "hip"
50     //~| ERROR second final: "hop"
51     //~| ERROR first source: "hip"
52     //~| ERROR second source: "hop"
53 }