From 2cd3d8fece9e2582abc6b6e70d94f28e3e0921bf Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 11 Jun 2026 18:07:35 +0200 Subject: fix(engine): use std::any::type_name for field type name reflection --- engine-macros/src/reflection/field.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'engine-macros') diff --git a/engine-macros/src/reflection/field.rs b/engine-macros/src/reflection/field.rs index 8572875..7d4e301 100644 --- a/engine-macros/src/reflection/field.rs +++ b/engine-macros/src/reflection/field.rs @@ -1,4 +1,4 @@ -use quote::{quote, ToTokens}; +use quote::quote; use crate::reflection::visibility::generate as generate_visibility; @@ -29,9 +29,6 @@ pub fn generate( let field_byte_offset = (options.gen_get_byte_offset)(field); - // since std::any::type_name as const is not stable yet - let field_type_name = field_type.to_token_stream().to_string(); - let field_vis = options.field_vis_override.as_ref().unwrap_or(&field.vis); let field_reflection_vis = generate_visibility(field_vis, &engine_crate_path); @@ -43,7 +40,9 @@ pub fn generate( layout: std::alloc::Layout::new::<#field_type>(), byte_offset: #field_byte_offset, type_id: std::any::TypeId::of::<#field_type>(), - type_name: #field_type_name, + get_type_name: #engine_crate_path::reflection::FnWithDebug::new(|| { + std::any::type_name::<#field_type>() + }), get_type: #engine_crate_path::reflection::FnWithDebug::new(|| { struct SpecializationTarget(std::marker::PhantomData); -- cgit v1.2.3-18-g5258