2018-01-01 02:30:13 +00:00
|
|
|
//@ aux-build:parent-source-spans.rs
|
2020-01-31 22:02:31 +00:00
|
|
|
|
|
|
|
#![feature(decl_macro)]
|
2018-01-01 02:30:13 +00:00
|
|
|
|
|
|
|
extern crate parent_source_spans;
|
|
|
|
|
|
|
|
use parent_source_spans::parent_source_spans;
|
|
|
|
|
|
|
|
macro one($a:expr, $b:expr) {
|
|
|
|
two!($a, $b);
|
2022-06-02 00:49:22 +00:00
|
|
|
//~^ ERROR first parent: "hello"
|
|
|
|
//~| ERROR second parent: "world"
|
2018-01-01 02:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro two($a:expr, $b:expr) {
|
|
|
|
three!($a, $b);
|
2022-06-02 00:49:22 +00:00
|
|
|
//~^ ERROR first final: "hello"
|
|
|
|
//~| ERROR second final: "world"
|
|
|
|
//~| ERROR first final: "yay"
|
|
|
|
//~| ERROR second final: "rust"
|
2018-01-01 02:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// forwarding tokens directly doesn't create a new source chain
|
|
|
|
macro three($($tokens:tt)*) {
|
|
|
|
four!($($tokens)*);
|
|
|
|
}
|
|
|
|
|
|
|
|
macro four($($tokens:tt)*) {
|
|
|
|
parent_source_spans!($($tokens)*);
|
2018-12-16 17:23:27 +00:00
|
|
|
//~^ ERROR cannot find value `ok` in this scope
|
|
|
|
//~| ERROR cannot find value `ok` in this scope
|
|
|
|
//~| ERROR cannot find value `ok` in this scope
|
2018-01-01 02:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
one!("hello", "world");
|
2022-06-02 00:49:22 +00:00
|
|
|
//~^ ERROR first grandparent: "hello"
|
|
|
|
//~| ERROR second grandparent: "world"
|
|
|
|
//~| ERROR first source: "hello"
|
|
|
|
//~| ERROR second source: "world"
|
2018-01-01 02:30:13 +00:00
|
|
|
|
|
|
|
two!("yay", "rust");
|
2022-06-02 00:49:22 +00:00
|
|
|
//~^ ERROR first parent: "yay"
|
|
|
|
//~| ERROR second parent: "rust"
|
|
|
|
//~| ERROR first source: "yay"
|
|
|
|
//~| ERROR second source: "rust"
|
2018-01-01 02:30:13 +00:00
|
|
|
|
|
|
|
three!("hip", "hop");
|
|
|
|
//~^ ERROR first final: "hip"
|
|
|
|
//~| ERROR second final: "hop"
|
|
|
|
//~| ERROR first source: "hip"
|
|
|
|
//~| ERROR second source: "hop"
|
|
|
|
}
|