Skip to content

Unhelpful error message for malformed Bevy Query type parameters #89680

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

Open
alice-i-cecile opened this issue Oct 8, 2021 · 0 comments
Open
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-type-system Area: Type system D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alice-i-cecile
Copy link

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!

@alice-i-cecile alice-i-cecile added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 8, 2021
@fmease fmease added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. A-type-system Area: Type system labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-type-system Area: Type system D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants