Skip to content

Unhelpful error message for malformed Bevy Query type parameters #89680

Open
@alice-i-cecile

Description

@alice-i-cecile

Following the reproduction here, this code:

use bevy::prelude::*;

#[derive(Component)]
struct A;

#[derive(Component)]
struct B;

// The user needs to include both &A and &B in the first type parameter of Query
fn missing_brackets_in_query_system(query: Query<&A, &B>) {}

fn main() {
    App::new()
        .add_system(missing_brackets_in_query_system)
        .run()
}

Produces the following error:

type mismatch resolving `for<'w, 's> <ReadFetch<B> as Fetch<'w, 's>>::Item == bool`
required because of the requirements on the impl of `FilterFetch` for `ReadFetch<B>`

In this case, the user should be grouping &A, &B into the first type argument of Query using our all_tuples-impl'ed macro.
The compiler however sees that &B is used in the place of the query filter, and complains that it's an invalid query due to missing internal traits.

Obviously, implementing FilterFetch or ReadFetch for B is not the approach the user should be taking to solve this problem!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions