third_party_rust_syn/dev/parse.rs
David Tolnay 5b351e5a82
Emit main in dev crate whether or not there is error
Hides an unnecessary extra error:

    error[E0601]: `main` function not found in crate `syn_dev`
      |
      = note: consider adding a `main` function to `dev/main.rs`
2019-06-08 06:11:12 -07:00

19 lines
396 B
Rust

extern crate proc_macro;
use proc_macro::TokenStream;
use quote::quote;
use syn::File;
#[proc_macro]
pub fn r#mod(input: TokenStream) -> TokenStream {
let compile_error = syn::parse::<File>(input)
.map(|file| println!("{:#?}", file))
.map_err(|err| err.to_compile_error())
.err();
TokenStream::from(quote! {
#compile_error
fn main() {}
})
}