Closed
Description
I have the following proc macro called from the following crate. It is intended to display an error pointing to the first >
of a >>
joint op. Instead the error points to the whole >>
pair of tokens.
#![feature(proc_macro)]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro]
pub fn antoyo(input: TokenStream) -> TokenStream {
let mut iter = input.into_iter();
let tt = iter.next().unwrap();
tt.span.error("first angle bracket").emit();
assert!(iter.next().is_some());
assert!(iter.next().is_none());
TokenStream::empty()
}
#![feature(proc_macro)]
extern crate mac;
mac::antoyo!(>>);
fn main() {}
error: first angle bracket
--> src/main.rs:5:14
|
5 | mac::antoyo!(>>);
| ^^
This makes it impossible to show correct error messages on something like Option<Option<String>>
for example where you want the span to point out the inner Option<String>
, as reported in dtolnay/syn#296.
Mentioning @antoyo who noticed this.
Mentioning @jseyfried @abonander who are involved with this code.