1fad3a1d3Sopenharmony_ciuse proc_macro2::{Delimiter, Group}; 2fad3a1d3Sopenharmony_ciuse quote::quote; 3fad3a1d3Sopenharmony_ci 4fad3a1d3Sopenharmony_ci#[test] 5fad3a1d3Sopenharmony_cifn main() { 6fad3a1d3Sopenharmony_ci // Okay. Rustc allows top-level `static` with no value syntactically, but 7fad3a1d3Sopenharmony_ci // not semantically. Syn parses as Item::Verbatim. 8fad3a1d3Sopenharmony_ci let tokens = quote! { 9fad3a1d3Sopenharmony_ci pub static FOO: usize; 10fad3a1d3Sopenharmony_ci pub static BAR: usize; 11fad3a1d3Sopenharmony_ci }; 12fad3a1d3Sopenharmony_ci let file = syn::parse2::<syn::File>(tokens).unwrap(); 13fad3a1d3Sopenharmony_ci println!("{:#?}", file); 14fad3a1d3Sopenharmony_ci 15fad3a1d3Sopenharmony_ci // Okay. 16fad3a1d3Sopenharmony_ci let inner = Group::new( 17fad3a1d3Sopenharmony_ci Delimiter::None, 18fad3a1d3Sopenharmony_ci quote!(static FOO: usize = 0; pub static BAR: usize = 0), 19fad3a1d3Sopenharmony_ci ); 20fad3a1d3Sopenharmony_ci let tokens = quote!(pub #inner;); 21fad3a1d3Sopenharmony_ci let file = syn::parse2::<syn::File>(tokens).unwrap(); 22fad3a1d3Sopenharmony_ci println!("{:#?}", file); 23fad3a1d3Sopenharmony_ci 24fad3a1d3Sopenharmony_ci // Formerly parser crash. 25fad3a1d3Sopenharmony_ci let inner = Group::new( 26fad3a1d3Sopenharmony_ci Delimiter::None, 27fad3a1d3Sopenharmony_ci quote!(static FOO: usize; pub static BAR: usize), 28fad3a1d3Sopenharmony_ci ); 29fad3a1d3Sopenharmony_ci let tokens = quote!(pub #inner;); 30fad3a1d3Sopenharmony_ci let file = syn::parse2::<syn::File>(tokens).unwrap(); 31fad3a1d3Sopenharmony_ci println!("{:#?}", file); 32fad3a1d3Sopenharmony_ci} 33