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

No "consider borrowing here" suggestion for method on complex trait bound #89679

Open
alice-i-cecile opened this issue Oct 8, 2021 · 0 comments
Labels
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.

Comments

@alice-i-cecile
Copy link

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.

@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
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 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

1 participant