Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Compile Time Query checking and System Parameters #17837
base: main
Are you sure you want to change the base?
Compile Time Query checking and System Parameters #17837
Changes from 14 commits
b374ef0
20f086a
f2d8a31
214e84c
a99b68c
7b1e737
747b881
e9866ad
c81744b
44aa6fb
d00b235
a556045
e1a20c6
7517ac8
47e4414
bd6b324
1cd9270
ad0b84e
148a1f3
5d2cb10
8f798a4
48a92ac
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 293 in crates/bevy_ecs/src/query/fetch.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these bounds need to be higher-ranked, and not just
Self: AccessTreeContainer
? It looks like they are only used forSelf::COMPONENT_ACCESS_TREE
.For that matter, do you need
AccessTreeContainer
at all? Given thatUNSTABLE_TYPE_ID
andSTRUCT_NAME
are already onComponent
, it looks like all it does is share a bit of code between&T
andRef<T>
and between&mut T
andMut<T>
. It might be simpler to remove the trait and doto share the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this works? We have an implementation ON &mut T where T is component because we wanna be able to tell if a component access is a ref or a mut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing
where Self: AccessTreeContainer
seems to compile when I try it.And copy-pasting the definition from
impl<T: Component> AccessTreeContainer for &T
tounsafe impl<T: Component> QueryData for &T
works other than privacy, which should let you get rid ofAccessTreeContainer
completely. If you want to leave them private then I expect you could make aconst fn new
, although I didn't try that.... And I don't see a definition of
COMPONENT_ACCESS_TREE
at all inQueryData
forRef
orMut
? Well, if I addto
unsafe impl<'__w, T: Component> QueryData for Ref<'__w, T> {
then it seems to work, so you could still share the definitions between&T
andRef<T>
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need separate cases for two and three items? It seems like you could make the two-item case take
(@tree $t0:ident, $($rest:ident),+)
and do the induction there.Alternately, I think you can do this without recursion. It might be simpler as something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly it seems like this doesn't work. But if you could elaborate on how to do the two item case instead I would like to switch to that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. I was expecting it to do static promotion... but that's only possible if the inner values are themselves
const
, andtree
isn'tconst
. And if you try to make a bunch of nestedconst TREE =
then it complains that they "can't use generic parameters from outer item". Yuck.The simplest change is
But you could go one further with
for the cost of an extra
combine(Empty)
.... and for that matter, since we're already generating that same code for smaller tuples, you could use their trees rather than doing a second recursion:
That should generate a little less code.