summaryrefslogtreecommitdiff
path: root/engine-macros/src/reflection/struct_impl.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-06-12 22:13:14 +0200
committerHampusM <hampus@hampusmat.com>2026-06-12 22:13:14 +0200
commitcd4219fae7f29b9c3d96aee640cefb6b2639e1a8 (patch)
tree0ec6967f9d077458f3c05985371f358ee13eaaa9 /engine-macros/src/reflection/struct_impl.rs
parent52e42bfdb3d56644da03e60969b1a2bedac8efc2 (diff)
fix(engine): make Reflection derive macro add Reflection type param boundsHEADmaster
Diffstat (limited to 'engine-macros/src/reflection/struct_impl.rs')
-rw-r--r--engine-macros/src/reflection/struct_impl.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/engine-macros/src/reflection/struct_impl.rs b/engine-macros/src/reflection/struct_impl.rs
index 2a271e0..b1adea5 100644
--- a/engine-macros/src/reflection/struct_impl.rs
+++ b/engine-macros/src/reflection/struct_impl.rs
@@ -1,7 +1,7 @@
use quote::quote;
use crate::reflection::field::{generate as generate_field, ReflectionFieldGenOptions};
-use crate::util::find_engine_crate_path;
+use crate::util::{find_engine_crate_path, syn_path, SynPathExt};
pub fn generate(input: syn::ItemStruct) -> proc_macro2::TokenStream
{
@@ -9,7 +9,22 @@ pub fn generate(input: syn::ItemStruct) -> proc_macro2::TokenStream
let input_ident = input.ident;
- let (impl_generics, type_generics, where_clause) = input.generics.split_for_impl();
+ let type_reflection_optional = input.generics.params.is_empty();
+
+ let mut generics = input.generics;
+
+ for type_param in generics.type_params_mut() {
+ type_param
+ .bounds
+ .push(syn::TypeParamBound::Trait(syn::TraitBound {
+ paren_token: None,
+ modifier: syn::TraitBoundModifier::None,
+ lifetimes: None,
+ path: engine_crate_path.join(syn_path!(reflection::Reflection)),
+ }));
+ }
+
+ let (impl_generics, type_generics, where_clause) = generics.split_for_impl();
let fields = input
.fields
@@ -29,7 +44,7 @@ pub fn generate(input: syn::ItemStruct) -> proc_macro2::TokenStream
quote! { std::mem::offset_of!(Self, #field_index) }
}
},
- type_reflection_optional: input.generics.params.is_empty(),
+ type_reflection_optional,
},
)
});