utils_macros/
linters.rs

1//! Macros that automatically apply or silence lints.
2//! The goal is to minimise the amount of lint configuration littered through the codebase.
3#![allow(clippy::missing_docs_in_private_items)]
4
5use proc_macro::TokenStream;
6use quote::quote;
7use syn::{Attribute, ItemFn, parse_macro_input};
8
9pub fn bevy_system(_attr: TokenStream, item: TokenStream) -> TokenStream {
10    // Parse the input tokens into a function AST
11    let mut input = parse_macro_input!(item as ItemFn);
12
13    // Be careful when adding new lints to this list!
14    // All systems in the application will have these `allow`s applied, silencing lints.
15    // Ensure that the lints are *globally* applicable.
16    let allow_attribute: Attribute = syn::parse_quote! {
17        #[allow(
18            clippy::missing_errors_doc,
19            clippy::needless_pass_by_value
20        )]
21    };
22
23    input.attrs.splice(0..0, std::iter::once(allow_attribute));
24    TokenStream::from(quote!(#input))
25}