WorldQuery derive macro now respects visibility (#4125)
## Objective Fixes #4122. ## Solution Inherit the visibility of the struct being derived for the `xxItem`, `xxFetch`, `xxState` structs. Co-authored-by: Carter Anderson <mcanders1@gmail.com>
This commit is contained in:
		
							parent
							
								
									995f85e157
								
							
						
					
					
						commit
						16133de8cd
					
				| @ -28,6 +28,8 @@ mod field_attr_keywords { | |||||||
| pub static WORLD_QUERY_ATTRIBUTE_NAME: &str = "world_query"; | pub static WORLD_QUERY_ATTRIBUTE_NAME: &str = "world_query"; | ||||||
| 
 | 
 | ||||||
| pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { | pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { | ||||||
|  |     let visibility = ast.vis; | ||||||
|  | 
 | ||||||
|     let mut fetch_struct_attributes = FetchStructAttributes::default(); |     let mut fetch_struct_attributes = FetchStructAttributes::default(); | ||||||
|     for attr in &ast.attrs { |     for attr in &ast.attrs { | ||||||
|         if !attr |         if !attr | ||||||
| @ -233,7 +235,8 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { | |||||||
|                       item_struct_name: Ident| { |                       item_struct_name: Ident| { | ||||||
|         if is_filter { |         if is_filter { | ||||||
|             quote! { |             quote! { | ||||||
|                 struct #fetch_struct_name #impl_generics #where_clause { |                 #[doc(hidden)] | ||||||
|  |                 #visibility struct #fetch_struct_name #impl_generics #where_clause { | ||||||
|                     #(#field_idents: <#field_types as #path::query::WorldQuery>::#fetch_associated_type,)* |                     #(#field_idents: <#field_types as #path::query::WorldQuery>::#fetch_associated_type,)* | ||||||
|                     #(#ignored_field_idents: #ignored_field_types,)* |                     #(#ignored_field_idents: #ignored_field_types,)* | ||||||
|                 } |                 } | ||||||
| @ -277,12 +280,13 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { | |||||||
|         } else { |         } else { | ||||||
|             quote! { |             quote! { | ||||||
|                 #derive_macro_call |                 #derive_macro_call | ||||||
|                 struct #item_struct_name #impl_generics #where_clause { |                 #visibility struct #item_struct_name #impl_generics #where_clause { | ||||||
|                     #(#(#field_attrs)* #field_visibilities #field_idents: <<#field_types as #path::query::WorldQuery>::#fetch_associated_type as #path::query::Fetch<#world_lifetime, #world_lifetime>>::Item,)* |                     #(#(#field_attrs)* #field_visibilities #field_idents: <<#field_types as #path::query::WorldQuery>::#fetch_associated_type as #path::query::Fetch<#world_lifetime, #world_lifetime>>::Item,)* | ||||||
|                     #(#(#ignored_field_attrs)* #ignored_field_visibilities #ignored_field_idents: #ignored_field_types,)* |                     #(#(#ignored_field_attrs)* #ignored_field_visibilities #ignored_field_idents: #ignored_field_types,)* | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 struct #fetch_struct_name #impl_generics #where_clause { |                 #[doc(hidden)] | ||||||
|  |                 #visibility struct #fetch_struct_name #impl_generics #where_clause { | ||||||
|                     #(#field_idents: <#field_types as #path::query::WorldQuery>::#fetch_associated_type,)* |                     #(#field_idents: <#field_types as #path::query::WorldQuery>::#fetch_associated_type,)* | ||||||
|                     #(#ignored_field_idents: #ignored_field_types,)* |                     #(#ignored_field_idents: #ignored_field_types,)* | ||||||
|                 } |                 } | ||||||
| @ -342,7 +346,8 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { | |||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     let state_impl = quote! { |     let state_impl = quote! { | ||||||
|         struct #state_struct_name #impl_generics #where_clause { |         #[doc(hidden)] | ||||||
|  |         #visibility struct #state_struct_name #impl_generics #where_clause { | ||||||
|             #(#field_idents: <#field_types as #path::query::WorldQuery>::State,)* |             #(#field_idents: <#field_types as #path::query::WorldQuery>::State,)* | ||||||
|             #(#ignored_field_idents: #ignored_field_types,)* |             #(#ignored_field_idents: #ignored_field_types,)* | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Christian Hughes
						Christian Hughes