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

Make WorldQuery meta types unnameable #7964

Merged
merged 4 commits into from
Mar 9, 2023

Conversation

JoJoJet
Copy link
Member

@JoJoJet JoJoJet commented Mar 8, 2023

Objective

The WorldQuery derive macro can generate three hidden types: QueryState, QueryFetch, and QueryReadOnlyFetch. These are only #[doc(hidden)] though, and are still publicly accessible and can potentially conflict with user-defined types.

Fixes #6264.

Solution

Move the definitions of these types into an anonymous scope, so that are unnamable outside of the derive macro. The QueryItem and QueryReadOnlyItem structs are still nameable, as they are a part of the public API for world query structs.


Changelog

Internal types generated by the WorldQuery derive macro are now unnameable.

Migration Guide

The State and Fetch types for types created using #[derive(WorldQuery)] are now unnameable. If you need to refer to them, use the syntax <T as WorldQuery>::State, <T as WorldQuery>::Fetch.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Mar 8, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever, if mildly cursed. Good choice.

Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should add Fixes #6264 to the PR description.

@james7132 james7132 added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 8, 2023
@james7132 james7132 added this pull request to the merge queue Mar 9, 2023
Merged via the queue into bevyengine:main with commit 5459650 Mar 9, 2023
@JoJoJet JoJoJet deleted the hide-world-query-meta branch March 9, 2023 18:17
Shfty pushed a commit to shfty-rust/bevy that referenced this pull request Mar 19, 2023
Shfty pushed a commit to shfty-rust/bevy that referenced this pull request Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#[derive(WorldQuery)] on Foo produces FooState which docs don't really mention
3 participants