4 #![feature(proc_macro_def_site)]
5 #![feature(proc_macro_diagnostic)]
6 #![feature(proc_macro_quote)]
7 #![crate_type = "proc-macro"]
9 extern crate proc_macro;
13 pub fn resolve_located_at(input: TokenStream) -> TokenStream {
14 match &*input.into_iter().collect::<Vec<_>>() {
16 // The error is reported at input `a`.
17 let mut diag = Diagnostic::new(Level::Error, "expected error");
18 diag.set_spans(Span::def_site().located_at(a.span()));
21 // Resolves to `struct S;` at def site, but the error is reported at input `b`.
22 let s = TokenTree::Ident(Ident::new("S", b.span().resolved_at(Span::def_site())));
29 _ => panic!("unexpected input"),