Skip to content

Commit

Permalink
Merge pull request #25 from lanastara/fix/duplicate_cfg
Browse files Browse the repository at this point in the history
fix: changed all_cfg_attributes to a HashSet ...
  • Loading branch information
mcmah309 authored Dec 25, 2024
2 parents f517a87 + dabea29 commit b422e74
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions error_set_impl/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ fn impl_froms(
if froms_to_disable_idents.contains(&&from_error_enum.error_name) {
continue;
}
let mut all_cfg_attributes = Vec::new();
let mut all_cfg_attributes = HashSet::new();
let mut error_branch_tokens = TokenStream::new();
let from_error_enum_name = &from_error_enum.error_name;
for (from_error_enum_variant, error_enum_variant) in variant_mappings {
Expand All @@ -363,8 +363,8 @@ fn impl_froms(
"Not a valid conversion target\n\nfrom:\n\n{from}\n\nto:\n\n{to}"
);
}
all_cfg_attributes.append(&mut from_error_enum_variant.cfg_attributes().clone());
all_cfg_attributes.append(&mut error_enum_variant.cfg_attributes().clone());
all_cfg_attributes.extend(from_error_enum_variant.cfg_attributes().clone());
all_cfg_attributes.extend(error_enum_variant.cfg_attributes().clone());
let arm: Option<TokenStream> = match (from_error_enum_variant, error_enum_variant) {
(ErrorVariant::Named(this), ErrorVariant::Named(that)) => Some(name_to_name(
from_error_enum_name,
Expand Down Expand Up @@ -446,6 +446,7 @@ fn impl_froms(
}
let (impl_generics, ty_generics) = generic_tokens(&error_enum.generics);
let (from_impl_generics, from_ty_generics) = generic_tokens(&from_error_enum.generics);
let all_cfg_attributes = all_cfg_attributes.iter();
token_stream.append_all(quote::quote! {
#(#all_cfg_attributes)*
impl #impl_generics From<#from_error_enum_name #from_ty_generics> for #error_enum_name #ty_generics {
Expand Down

0 comments on commit b422e74

Please sign in to comment.