Skip to content

Commit

Permalink
fix(stackable-versioned): Remove type comparison and use into() on al…
Browse files Browse the repository at this point in the history
…l field conversions

Note: the from/to type comparison was semantically invalid as we have no information of the actual type which might still be an equivalent string (eg: foo::TypeA could be defined in two versions of a crate).
  • Loading branch information
NickLarsenNZ committed Nov 29, 2024
1 parent 5dcb07b commit 82fac6e
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions crates/stackable-versioned-macros/src/codegen/item/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,26 +168,19 @@ impl VersionedField {
ItemStatus::Change {
from_ident: old_field_ident,
to_ident,
from_type,
to_type,
..
},
) => {
if from_type == to_type {
quote! {
#to_ident: #from_struct_ident.#old_field_ident,
}
} else {
quote! {
#to_ident: #from_struct_ident.#old_field_ident.into(),
}
quote! {
#to_ident: #from_struct_ident.#old_field_ident.into(),
}
}
(old, next) => {
let next_field_ident = next.get_ident();
let old_field_ident = old.get_ident();

quote! {
#next_field_ident: #from_struct_ident.#old_field_ident,
#next_field_ident: #from_struct_ident.#old_field_ident.into(),
}
}
}
Expand All @@ -196,7 +189,7 @@ impl VersionedField {
let field_ident = &*self.ident;

quote! {
#field_ident: #from_struct_ident.#field_ident,
#field_ident: #from_struct_ident.#field_ident.into(),
}
}
}
Expand Down

0 comments on commit 82fac6e

Please sign in to comment.