Closed
Description
(demo: https://github.com/HMPerson1/rustc-macros-span-bug)
If we have a proc_macro
like this:
#[proc_macro_attribute]
pub fn reforest(_attr: TokenStream, item: TokenStream) -> TokenStream {
item.into_iter().collect()
}
And we invoke it like this:
#![feature(proc_macro_hygiene)]
#[reforest]
fn foo() {
macro_rules! m {()=>()}
}
All the tokens processed by reforest
have their spans set to 0.
You can see this in the warning messages:
warning: unused macro definition
|
= note: #[warn(unused_macros)] on by default
warning: function is never used: `foo`
|
= note: #[warn(dead_code)] on by default
Note that everything is fine we do any of the following:
- Change the proc_macro body to
item
- Change the proc_macro body to
TokenStream::from_str(&item.to_string())
- Comment out/delete
macro_rules! m {()=>()}
Metadata
Metadata
Assignees
Labels
No labels