Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - WorldQuery derive macro now respects visibility #4125

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions crates/bevy_ecs/macros/src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ mod field_attr_keywords {
pub static WORLD_QUERY_ATTRIBUTE_NAME: &str = "world_query";

pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
let visibility = ast.vis;

let mut fetch_struct_attributes = FetchStructAttributes::default();
for attr in &ast.attrs {
if !attr
Expand Down Expand Up @@ -233,7 +235,8 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
item_struct_name: Ident| {
if is_filter {
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,)*
#(#ignored_field_idents: #ignored_field_types,)*
}
Expand Down Expand Up @@ -276,13 +279,15 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
}
} else {
quote! {
#[doc(hidden)]
cart marked this conversation as resolved.
Show resolved Hide resolved
#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,)*
#(#(#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,)*
#(#ignored_field_idents: #ignored_field_types,)*
}
Expand Down Expand Up @@ -342,7 +347,8 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
);

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,)*
#(#ignored_field_idents: #ignored_field_types,)*
}
Expand Down