Skip to content

Commit a55a69b

Browse files
committed
primitive fix
1 parent 21681d7 commit a55a69b

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

crates/bevy_reflect/bevy_reflect_derive/src/derive_data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::field_attributes::{parse_field_attrs, ReflectFieldAttr};
33
use crate::type_path::parse_path_no_leading_colon;
44
use crate::utility::members_to_serialization_denylist;
55
use bit_set::BitSet;
6-
use quote::{quote, ToTokens, TokenStreamExt};
6+
use quote::{quote, ToTokens};
77

88
use crate::{
99
utility, REFLECT_ATTRIBUTE_NAME, REFLECT_VALUE_ATTRIBUTE_NAME, TYPE_NAME_ATTRIBUTE_NAME,

crates/bevy_reflect/bevy_reflect_derive/src/impls/typed.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ pub(crate) fn type_path_generator(meta: &ReflectMeta) -> proc_macro2::TokenStrea
88
let path_to_type = meta.path_to_type();
99
let generics = meta.generics();
1010
let bevy_reflect_path = meta.bevy_reflect_path();
11+
12+
if let PathToType::Primitive(name) = path_to_type {
13+
let name = LitStr::new(&name.to_string(), name.span());
14+
return quote! {
15+
#bevy_reflect_path::utility::TypePathStorage::new_primitive(#name)
16+
};
17+
}
18+
1119
// Whether to use `GenericTypedCell` is not dependent on lifetimes
1220
// (which all have to be 'static anyway).
1321
let is_generic = !generics
@@ -65,15 +73,7 @@ pub(crate) fn type_path_generator(meta: &ReflectMeta) -> proc_macro2::TokenStrea
6573
}
6674
};
6775

68-
if let PathToType::Primitive(name) = path_to_type {
69-
quote! {
70-
#bevy_reflect_path::utility::TypePathStorage::new_primitive(
71-
#path,
72-
#short_path,
73-
#name,
74-
)
75-
}
76-
} else if !path_to_type.is_named() {
76+
if !path_to_type.is_named() {
7777
quote! {
7878
#bevy_reflect_path::utility::TypePathStorage::new_anonymous(
7979
#path,
@@ -147,12 +147,10 @@ pub(crate) fn impl_type_path(meta: &ReflectMeta) -> proc_macro2::TokenStream {
147147

148148
let primitive_assert = if let PathToType::Primitive(_) = path_to_type {
149149
Some(quote! {
150-
const _: () = {
151-
mod private_scope {
152-
// Compiles if it can be named with its ident when there are no imports.
153-
type AssertIsPrimitive = #path_to_type;
154-
}
155-
};
150+
mod private_scope {
151+
// Compiles if it can be named with its ident when there are no imports.
152+
type AssertIsPrimitive = #path_to_type;
153+
}
156154
})
157155
} else {
158156
None

0 commit comments

Comments
 (0)