1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // aux-build:parent-source-spans.rs
14 #![feature(use_extern_macros, decl_macro, proc_macro_non_items)]
16 extern crate parent_source_spans;
18 use parent_source_spans::parent_source_spans;
20 macro one($a:expr, $b:expr) {
22 //~^ ERROR first parent: "hello"
23 //~| ERROR second parent: "world"
26 macro two($a:expr, $b:expr) {
28 //~^ ERROR first final: "hello"
29 //~| ERROR second final: "world"
30 //~| ERROR first final: "yay"
31 //~| ERROR second final: "rust"
34 // forwarding tokens directly doesn't create a new source chain
35 macro three($($tokens:tt)*) {
39 macro four($($tokens:tt)*) {
40 parent_source_spans!($($tokens)*);
44 one!("hello", "world");
45 //~^ ERROR first grandparent: "hello"
46 //~| ERROR second grandparent: "world"
47 //~| ERROR first source: "hello"
48 //~| ERROR second source: "world"
51 //~^ ERROR first parent: "yay"
52 //~| ERROR second parent: "rust"
53 //~| ERROR first source: "yay"
54 //~| ERROR second source: "rust"
57 //~^ ERROR first final: "hip"
58 //~| ERROR second final: "hop"
59 //~| ERROR first source: "hip"
60 //~| ERROR second source: "hop"