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

SystemParam derive inconsistent with where clauses. #7103

Closed
iiYese opened this issue Jan 6, 2023 · 0 comments
Closed

SystemParam derive inconsistent with where clauses. #7103

iiYese opened this issue Jan 6, 2023 · 0 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior

Comments

@iiYese
Copy link
Contributor

iiYese commented Jan 6, 2023

Bevy version

329b71f

What you did

Pulled latest bevy main changes to get the SystemParam private field changes.
Attempted to use it on a generic system param that used a where clause to constrain generics.

use crate as bevy_ecs;
use crate::query::WorldQuery;
use crate::system::{Query, SystemParam};

// ...

#[derive(SystemParam)]
pub struct Foo<'w, 's, Q>
where
    Q: 'static + WorldQuery,
{
    q: Query<'w, 's, Q, ()>,
}

What went wrong

Got errors saying to add an unapplyable fix.

error[E0277]: the trait bound `Q: fetch::WorldQuery` is not satisfied
   --> crates/bevy_ecs/src/relation/operations.rs:99:10
    |
99  | #[derive(SystemParam)]
    |          ^^^^^^^^^^^ the trait `fetch::WorldQuery` is not implemented for `Q`
    |
note: required for `system::query::Query<'w, 's, Q>` to implement `system_param::SystemParam`
   --> crates/bevy_ecs/src/system/system_param.rs:165:72
    |
165 | impl<'w, 's, Q: WorldQuery + 'static, F: ReadOnlyWorldQuery + 'static> SystemParam
    |                                                                        ^^^^^^^^^^^
166 |     for Query<'w, 's, Q, F>
    |         ^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `SystemParam` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `Q`
    |
100 | pub struct Foo<'w, 's, Q: query::fetch::WorldQuery>
    |                         ++++++++++++++++++++++++++

Additional information

Changing the constraints to be within the generic params instead of the where clause like so makes this error go away.

#[derive(SystemParam)]
pub struct Foo<'w, 's, Q: 'static + WorldQuery> {
    q: Query<'w, 's, Q, ()>,
}
@iiYese iiYese added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 6, 2023
@JoJoJet JoJoJet added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Jan 6, 2023
bors bot pushed a commit that referenced this issue Jan 10, 2023
# Objective

- Fix #7103.
- The issue is caused because I forgot to add a where clause to a generated struct in #7056.

## Solution

- Add the where clause.
bors bot pushed a commit that referenced this issue Jan 10, 2023
# Objective

- Fix #7103.
- The issue is caused because I forgot to add a where clause to a generated struct in #7056.

## Solution

- Add the where clause.
@bors bors bot closed this as completed in fa40e2b Jan 10, 2023
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
# Objective

- Fix bevyengine#7103.
- The issue is caused because I forgot to add a where clause to a generated struct in bevyengine#7056.

## Solution

- Add the where clause.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Fix bevyengine#7103.
- The issue is caused because I forgot to add a where clause to a generated struct in bevyengine#7056.

## Solution

- Add the where clause.
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants