mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Decouple Diagnostic
from "all violations" enumeration (#3352)
This commit is contained in:
parent
bc869d4f52
commit
ffad0bcdaa
804 changed files with 14764 additions and 6792 deletions
|
@ -46,6 +46,19 @@ pub fn violation(violation: &ItemStruct) -> Result<TokenStream> {
|
|||
quote! {
|
||||
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#violation
|
||||
|
||||
impl From<#ident> for crate::registry::DiagnosticKind {
|
||||
fn from(value: #ident) -> Self {
|
||||
use crate::violation::Violation;
|
||||
|
||||
Self {
|
||||
body: Violation::message(&value),
|
||||
fixable: value.autofix_title_formatter().is_some(),
|
||||
commit: value.autofix_title_formatter().map(|f| f(&value)),
|
||||
name: stringify!(#ident).to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
|
@ -57,6 +70,19 @@ pub fn violation(violation: &ItemStruct) -> Result<TokenStream> {
|
|||
Some(#explanation)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<#ident> for crate::registry::DiagnosticKind {
|
||||
fn from(value: #ident) -> Self {
|
||||
use crate::violation::Violation;
|
||||
|
||||
Self {
|
||||
body: Violation::message(&value),
|
||||
fixable: value.autofix_title_formatter().is_some(),
|
||||
commit: value.autofix_title_formatter().map(|f| f(&value)),
|
||||
name: stringify!(#ident).to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Ok(violation)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue