Closed
Description
In the following proc macro invocation the compiler passes in the input $crate
as a TokenStream but panics when iterating over that TokenStream. Specifically the panic happens in next()
.
rustc 1.31.0-nightly (de9666f 2018-10-31)
repro/src/lib.rs
extern crate proc_macro;
use self::proc_macro::TokenStream;
#[proc_macro]
pub fn repro(input: TokenStream) -> TokenStream {
input.into_iter().next();
unimplemented!()
}
testing/src/lib.rs
macro_rules! m {
() => {
repro::repro!($crate);
};
}
m!();
error: proc macro panicked
--> src/main.rs:3:9
|
3 | repro::repro!($crate);
| ^^^^^^^^^^^^^^^^^^^^^^
...
7 | m!();
| ----- in this macro invocation
|
= help: message: `"$crate"` is not a valid identifier
Originally reported in dtolnay/paste#3. Mentioning @softprops.