File tree Expand file tree Collapse file tree 7 files changed +13
-17
lines changed
crates/bevy_reflect/bevy_reflect_derive/src Expand file tree Collapse file tree 7 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ pub(crate) fn impl_enum(reflect_enum: &ReflectEnum) -> proc_macro2::TokenStream
8383 } ,
8484 ) ;
8585
86- let type_path_impl = impl_type_path ( reflect_enum. meta ( ) , & where_clause_options ) ;
86+ let type_path_impl = impl_type_path ( reflect_enum. meta ( ) ) ;
8787
8888 let get_type_registration_impl = reflect_enum
8989 . meta ( )
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> proc_macro2::TokenS
8989 } ,
9090 ) ;
9191
92- let type_path_impl = impl_type_path ( reflect_struct. meta ( ) , & where_clause_options ) ;
92+ let type_path_impl = impl_type_path ( reflect_struct. meta ( ) ) ;
9393
9494 let get_type_registration_impl = reflect_struct. get_type_registration ( & where_clause_options) ;
9595
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> proc_macro2::
8282 } ,
8383 ) ;
8484
85- let type_path_impl = impl_type_path ( reflect_struct. meta ( ) , & where_clause_options ) ;
85+ let type_path_impl = impl_type_path ( reflect_struct. meta ( ) ) ;
8686
8787 let ( impl_generics, ty_generics, where_clause) = reflect_struct
8888 . meta ( )
Original file line number Diff line number Diff line change @@ -48,10 +48,11 @@ pub(crate) enum TypedProperty {
4848 TypePath ,
4949}
5050
51- pub ( crate ) fn impl_type_path (
52- meta : & ReflectMeta ,
53- where_clause_options : & WhereClauseOptions ,
54- ) -> proc_macro2:: TokenStream {
51+ pub ( crate ) fn impl_type_path ( meta : & ReflectMeta ) -> proc_macro2:: TokenStream {
52+ // Use `WhereClauseOptions::new_value` here so we don't enforce reflection bounds,
53+ // ensuring the impl applies in the most cases possible.
54+ let where_clause_options = & WhereClauseOptions :: new_value ( meta) ;
55+
5556 if !meta. traits ( ) . type_path_attrs ( ) . should_auto_derive ( ) {
5657 return proc_macro2:: TokenStream :: new ( ) ;
5758 }
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ pub(crate) fn impl_value(meta: &ReflectMeta) -> proc_macro2::TokenStream {
3131 } ,
3232 ) ;
3333
34- let type_path_impl = impl_type_path ( meta, & where_clause_options ) ;
34+ let type_path_impl = impl_type_path ( meta) ;
3535
3636 let ( impl_generics, ty_generics, where_clause) = type_path. generics ( ) . split_for_impl ( ) ;
3737 let where_reflect_clause = extend_where_clause ( where_clause, & where_clause_options) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ use reflect_value::ReflectValueDef;
3939use syn:: spanned:: Spanned ;
4040use syn:: { parse_macro_input, DeriveInput } ;
4141use type_path:: NamedTypePathDef ;
42- use utility:: WhereClauseOptions ;
4342
4443pub ( crate ) static REFLECT_ATTRIBUTE_NAME : & str = "reflect" ;
4544pub ( crate ) static REFLECT_VALUE_ATTRIBUTE_NAME : & str = "reflect_value" ;
@@ -283,11 +282,7 @@ pub fn derive_type_path(input: TokenStream) -> TokenStream {
283282 Err ( err) => return err. into_compile_error ( ) . into ( ) ,
284283 } ;
285284
286- let type_path_impl = impls:: impl_type_path (
287- derive_data. meta ( ) ,
288- // Use `WhereClauseOptions::new_value` here so we don't enforce reflection bounds
289- & WhereClauseOptions :: new_value ( derive_data. meta ( ) ) ,
290- ) ;
285+ let type_path_impl = impls:: impl_type_path ( derive_data. meta ( ) ) ;
291286
292287 TokenStream :: from ( quote ! {
293288 const _: ( ) = {
@@ -613,7 +608,7 @@ pub fn impl_type_path(input: TokenStream) -> TokenStream {
613608
614609 let meta = ReflectMeta :: new ( type_path, ReflectTraits :: default ( ) ) ;
615610
616- let type_path_impl = impls:: impl_type_path ( & meta, & WhereClauseOptions :: new_value ( & meta ) ) ;
611+ let type_path_impl = impls:: impl_type_path ( & meta) ;
617612
618613 TokenStream :: from ( quote ! {
619614 const _: ( ) = {
Original file line number Diff line number Diff line change @@ -132,9 +132,9 @@ impl WhereClauseOptions {
132132 let custom_bounds = active_bounds ( field) . map ( |bounds| quote ! ( + #bounds) ) ;
133133
134134 let bounds = if is_from_reflect {
135- quote ! ( #bevy_reflect_path:: FromReflect + #bevy_reflect_path :: TypePath #custom_bounds)
135+ quote ! ( #bevy_reflect_path:: FromReflect #custom_bounds)
136136 } else {
137- quote ! ( #bevy_reflect_path:: Reflect + #bevy_reflect_path :: TypePath #custom_bounds)
137+ quote ! ( #bevy_reflect_path:: Reflect #custom_bounds)
138138 } ;
139139
140140 ( ty, bounds)
You can’t perform that action at this time.
0 commit comments