mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-18 16:20:06 +00:00
Remove old define_violation!
(in favor of #[violation]
) (#3310)
This commit is contained in:
parent
d1c48016eb
commit
709dba2e71
7 changed files with 59 additions and 119 deletions
|
@ -6,12 +6,12 @@ use syn::{parse_macro_input, DeriveInput, ItemFn, ItemStruct};
|
|||
|
||||
mod cache_key;
|
||||
mod config;
|
||||
mod define_violation;
|
||||
mod derive_message_formats;
|
||||
mod map_codes;
|
||||
mod register_rules;
|
||||
mod rule_code_prefix;
|
||||
mod rule_namespace;
|
||||
mod violation;
|
||||
|
||||
#[proc_macro_derive(ConfigurationOptions, attributes(option, doc, option_group))]
|
||||
pub fn derive_config(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
|
@ -38,19 +38,12 @@ pub fn register_rules(item: proc_macro::TokenStream) -> proc_macro::TokenStream
|
|||
register_rules::register_rules(&mapping).into()
|
||||
}
|
||||
|
||||
#[proc_macro]
|
||||
pub fn define_violation(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let cloned = item.clone();
|
||||
let meta = parse_macro_input!(cloned as define_violation::LintMeta);
|
||||
define_violation::define_violation(&item.into(), meta).into()
|
||||
}
|
||||
|
||||
/// Adds an `explanation()` method from the doc comment and
|
||||
/// `#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]`
|
||||
#[proc_macro_attribute]
|
||||
pub fn violation(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let violation = parse_macro_input!(item as ItemStruct);
|
||||
define_violation::violation(&violation)
|
||||
violation::violation(&violation)
|
||||
.unwrap_or_else(syn::Error::into_compile_error)
|
||||
.into()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue