4 #![crate_type = "proc-macro"]
5 #![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)]
7 extern crate proc_macro
;
9 use proc_macro
::{TokenStream, TokenTree, Span, Diagnostic}
;
11 fn parse(input
: TokenStream
) -> Result
<(), Diagnostic
> {
12 let mut hi_spans
= vec
![];
14 if let TokenTree
::Ident(ref ident
) = tree
{
15 if ident
.to_string() == "hi" {
16 hi_spans
.push(ident
.span());
21 if !hi_spans
.is_empty() {
22 return Err(Span
::def_site()
23 .error("hello to you, too!")
24 .span_note(hi_spans
, "found these 'hi's"));
31 pub fn hello(input
: TokenStream
) -> TokenStream
{
32 if let Err(diag
) = parse(input
) {