I would like to test some functionality of the syn
crate outside of a proc macro, but am getting a panic whenever I create a proc_macro::TokenStream
.
use quote::quote;
use syn::parse::Parser;
use syn::punctuated::Punctuated;
fn main(){
let foo: proc_macro::TokenStream = quote!(Bar, Bazz).into();
let parsed = Punctuated::<syn::Ident, syn::Token![,]>::parse_terminated.parse(foo);
}
// procedural macro API is used outside of a procedural macro
syn
and other crates haveparse2
and equivelant functions that allow us to use aproc_macro2::TokenStream
instead: