mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
refactor: Avoid implicit precondition
This commit is contained in:
parent
ac6c3affdd
commit
fa191cceeb
2 changed files with 3 additions and 5 deletions
|
@ -64,9 +64,8 @@ pub fn define_rule_mapping(mapping: &Mapping) -> proc_macro2::TokenStream {
|
|||
let rule_code_prefix = super::rule_code_prefix::expand(
|
||||
&Ident::new("Rule", Span::call_site()),
|
||||
&Ident::new("RuleCodePrefix", Span::call_site()),
|
||||
mapping.entries.iter().map(|(code, ..)| code),
|
||||
mapping.entries.iter().map(|(code, .., attr)| (code, attr)),
|
||||
|code| code_to_name[code],
|
||||
mapping.entries.iter().map(|(.., attr)| attr),
|
||||
);
|
||||
|
||||
quote! {
|
||||
|
|
|
@ -7,9 +7,8 @@ use syn::{Attribute, Ident};
|
|||
pub fn expand<'a>(
|
||||
rule_type: &Ident,
|
||||
prefix_ident: &Ident,
|
||||
variants: impl Iterator<Item = &'a Ident>,
|
||||
variants: impl Iterator<Item = (&'a Ident, &'a Vec<Attribute>)>,
|
||||
variant_name: impl Fn(&str) -> &'a Ident,
|
||||
attr: impl Iterator<Item = &'a Vec<Attribute>>,
|
||||
) -> proc_macro2::TokenStream {
|
||||
// Build up a map from prefix to matching RuleCodes.
|
||||
let mut prefix_to_codes: BTreeMap<String, BTreeMap<String, Vec<Attribute>>> =
|
||||
|
@ -17,7 +16,7 @@ pub fn expand<'a>(
|
|||
|
||||
let mut pl_codes = BTreeMap::new();
|
||||
|
||||
for (variant, attr) in variants.zip(attr) {
|
||||
for (variant, attr) in variants {
|
||||
let code_str = variant.to_string();
|
||||
let code_prefix_len = code_str
|
||||
.chars()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue