Open
Description
Using Bevy (see minimal repo here, the following code provides an unhelpful error message. The compiler does not notice that &A
meets the trait bounds required and suggest a fix.
use bevy::prelude::*;
// The user requested A in the system, rather than &A
fn missing_reference_in_query_system(query: Query<A, With<B>>) {}
fn main() {
App::new().add_system(missing_reference_in_query_system)).run();
}
The error message is
the trait bound `A: WorldQuery` is not satisfied
the trait `WorldQuery` is not implemented for `A`
Something along the lines of "The trait WorldQuery
is implemented for &A
, consider borrowing here." would go a long way to improve this.
Basic attempts at minimally reproducing this give the correct error message: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c762dafa29c2c0bc89425661f383917b. This also works with needs_ref
as a standalone function.