34 lines
954 B
Rust
34 lines
954 B
Rust
#![forbid(unsafe_code)]
|
|
// Rustc lint groups
|
|
#![warn(future_incompatible)]
|
|
#![warn(rust_2018_idioms)]
|
|
#![warn(unused)]
|
|
// Rustc lints
|
|
#![warn(noop_method_call)]
|
|
#![warn(single_use_lifetimes)]
|
|
// Clippy lints
|
|
#![warn(clippy::use_self)]
|
|
|
|
use syn::{parse_macro_input, DeriveInput};
|
|
|
|
mod document;
|
|
mod group;
|
|
mod util;
|
|
|
|
#[proc_macro_derive(Document, attributes(document))]
|
|
pub fn derive_document(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
|
let input = parse_macro_input!(input as DeriveInput);
|
|
match document::derive_impl(input) {
|
|
Ok(tokens) => tokens.into(),
|
|
Err(err) => err.into_compile_error().into(),
|
|
}
|
|
}
|
|
|
|
#[proc_macro_derive(Group)]
|
|
pub fn derive_group(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
|
let input = parse_macro_input!(input as DeriveInput);
|
|
match group::derive_impl(input) {
|
|
Ok(tokens) => tokens.into(),
|
|
Err(err) => err.into_compile_error().into(),
|
|
}
|
|
}
|