From 82fac6e4de34838bcf5d623d34f3013a3c7a33c9 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Fri, 29 Nov 2024 12:11:14 +0100 Subject: [PATCH] fix(stackable-versioned): Remove type comparison and use into() on all 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). --- .../src/codegen/item/field.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/crates/stackable-versioned-macros/src/codegen/item/field.rs b/crates/stackable-versioned-macros/src/codegen/item/field.rs index 77a55503..97190ba2 100644 --- a/crates/stackable-versioned-macros/src/codegen/item/field.rs +++ b/crates/stackable-versioned-macros/src/codegen/item/field.rs @@ -168,18 +168,11 @@ 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) => { @@ -187,7 +180,7 @@ impl VersionedField { 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(), } } } @@ -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(), } } }