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

Compiler error when using iter_combinations with filtered query #3651

Closed
rparrett opened this issue Jan 12, 2022 · 2 comments
Closed

Compiler error when using iter_combinations with filtered query #3651

rparrett opened this issue Jan 12, 2022 · 2 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@rparrett
Copy link
Contributor

rparrett commented Jan 12, 2022

Bevy version

0.6
main

What you did

use bevy::prelude::*;

#[derive(Component)]
struct A;
#[derive(Component)]
struct B;

fn test(query: Query<&A, With<B>>) {
    for _ in query.iter_combinations() {}
}

fn main() {}

What actually happened

error[E0277]: the trait bound `WithFetch<B>: Clone` is not satisfied
   --> src/main.rs:8:14
    |
8   |     for _ in query.iter_combinations() {}
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `WithFetch<B>`
    |
    = note: required because of the requirements on the impl of `Iterator` for `QueryCombinationIter<'_, '_, &A, ReadFetch<A>, bevy::prelude::With<B>, {_: usize}>`
    = note: required because of the requirements on the impl of `IntoIterator` for `QueryCombinationIter<'_, '_, &A, ReadFetch<A>, bevy::prelude::With<B>, {_: usize}>`
note: required by `into_iter`
   --> /Users/me/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/collect.rs:234:5
    |
234 |     fn into_iter(self) -> Self::IntoIter;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What you expected to happen

No compiler error.

Or if this is a known limitation or intended or something special needs to be done to make this work, some documentation pointing that out.

@rparrett rparrett added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 12, 2022
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Jan 12, 2022
@alice-i-cecile
Copy link
Member

This is just a bug, rather than a known limitation. I suspect that just adding the appropriate Clone derives on all the filters + adding some tests will be enough to fix this.

@alice-i-cecile alice-i-cecile added the D-Trivial Nice and easy! A great choice to get started with Bevy label Jan 12, 2022
@rparrett
Copy link
Contributor Author

rparrett commented Jan 12, 2022

Yep, seems like adding a Clone impl (deriving doesn't seem to work here?) to WithFetch at least makes things compile.

If nobody else gets to this in the next couple weeks I'll pick it up.

harudagondi added a commit to harudagondi/bevy that referenced this issue Jan 13, 2022
harudagondi added a commit to harudagondi/bevy that referenced this issue Jan 13, 2022
harudagondi added a commit to harudagondi/bevy that referenced this issue Jan 13, 2022
@bors bors bot closed this as completed in 64d2178 Apr 8, 2022
aevyrie pushed a commit to aevyrie/bevy that referenced this issue Jun 7, 2022
# Objective

- Previously, `iter_combinations()` does not work on queries that have filters.
- Fixes bevyengine#3651

## Solution

- Derived Copy on all `*Fetch<T>` structs, and manually implemented `Clone` to allow the test to pass (`.count()` does not work on `QueryCombinationIter` when `Clone` is derived)


Co-authored-by: Carter Anderson <[email protected]>
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Previously, `iter_combinations()` does not work on queries that have filters.
- Fixes bevyengine#3651

## Solution

- Derived Copy on all `*Fetch<T>` structs, and manually implemented `Clone` to allow the test to pass (`.count()` does not work on `QueryCombinationIter` when `Clone` is derived)


Co-authored-by: Carter Anderson <[email protected]>
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-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants