2017-12-31 20:30:13 -06:00
|
|
|
// aux-build:parent-source-spans.rs
|
2020-01-31 16:02:31 -06:00
|
|
|
|
|
|
|
#![feature(decl_macro)]
|
2017-12-31 20:30:13 -06:00
|
|
|
|
|
|
|
extern crate parent_source_spans;
|
|
|
|
|
|
|
|
use parent_source_spans::parent_source_spans;
|
|
|
|
|
|
|
|
macro one($a:expr, $b:expr) {
|
|
|
|
two!($a, $b);
|
2022-06-01 19:49:22 -05:00
|
|
|
//~^ ERROR first parent: "hello"
|
|
|
|
//~| ERROR second parent: "world"
|
2017-12-31 20:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
macro two($a:expr, $b:expr) {
|
|
|
|
three!($a, $b);
|
2022-06-01 19:49:22 -05:00
|
|
|
//~^ ERROR first final: "hello"
|
|
|
|
//~| ERROR second final: "world"
|
|
|
|
//~| ERROR first final: "yay"
|
|
|
|
//~| ERROR second final: "rust"
|
2017-12-31 20:30:13 -06: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 11:23:27 -06: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
|
2017-12-31 20:30:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
one!("hello", "world");
|
2022-06-01 19:49:22 -05:00
|
|
|
//~^ ERROR first grandparent: "hello"
|
|
|
|
//~| ERROR second grandparent: "world"
|
|
|
|
//~| ERROR first source: "hello"
|
|
|
|
//~| ERROR second source: "world"
|
2017-12-31 20:30:13 -06:00
|
|
|
|
|
|
|
two!("yay", "rust");
|
2022-06-01 19:49:22 -05:00
|
|
|
//~^ ERROR first parent: "yay"
|
|
|
|
//~| ERROR second parent: "rust"
|
|
|
|
//~| ERROR first source: "yay"
|
|
|
|
//~| ERROR second source: "rust"
|
2017-12-31 20:30:13 -06:00
|
|
|
|
|
|
|
three!("hip", "hop");
|
|
|
|
//~^ ERROR first final: "hip"
|
|
|
|
//~| ERROR second final: "hop"
|
|
|
|
//~| ERROR first source: "hip"
|
|
|
|
//~| ERROR second source: "hop"
|
|
|
|
}
|