hermit_macro/
lib.rs

1use proc_macro::TokenStream;
2use quote::ToTokens;
3use syn::parse::Nothing;
4use syn::parse_macro_input;
5
6macro_rules! bail {
7    ($span:expr, $($tt:tt)*) => {
8        return Err(syn::Error::new_spanned($span, format!($($tt)*)))
9    };
10}
11
12mod system;
13
14// The structure of this implementation is inspired by Amanieu's excellent naked-function crate.
15#[proc_macro_attribute]
16pub fn system(attr: TokenStream, item: TokenStream) -> TokenStream {
17	parse_macro_input!(attr as Nothing);
18	match system::system_attribute(parse_macro_input!(item)) {
19		Ok(item) => item.into_token_stream().into(),
20		Err(e) => e.to_compile_error().into(),
21	}
22}