xref: /third_party/rust/crates/syn/dev/parse.rs
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/rust/crates/syn/dev/
1fad3a1d3Sopenharmony_ciuse proc_macro::TokenStream;
2fad3a1d3Sopenharmony_ciuse quote::quote;
3fad3a1d3Sopenharmony_ciuse syn::File;
4fad3a1d3Sopenharmony_ci
5fad3a1d3Sopenharmony_ci#[proc_macro]
6fad3a1d3Sopenharmony_cipub fn r#mod(input: TokenStream) -> TokenStream {
7fad3a1d3Sopenharmony_ci    let compile_error = syn::parse::<File>(input)
8fad3a1d3Sopenharmony_ci        .map(|file| println!("{:#?}", file))
9fad3a1d3Sopenharmony_ci        .map_err(|err| err.to_compile_error())
10fad3a1d3Sopenharmony_ci        .err();
11fad3a1d3Sopenharmony_ci
12fad3a1d3Sopenharmony_ci    TokenStream::from(quote! {
13fad3a1d3Sopenharmony_ci        #compile_error
14fad3a1d3Sopenharmony_ci        fn main() {}
15fad3a1d3Sopenharmony_ci    })
16fad3a1d3Sopenharmony_ci}
17

Indexes created Thu Nov 07 10:32:03 CST 2024