bevy/crates/bevy_ecs/src/query
Chris Russell 4362b52a01
Add a note to the on_unimplemented message for QueryData recommending &T and &mut T. (#16449)
# Objective

A new user is likely to try `Query<Component>` instead of
`Query<&Component>`. The error message should guide them to the right
solution.

## Solution

Add a note to the on_unimplemented message for `QueryData` recommending
`&T` and `&mut T`.

The full error message now looks like: 

```
error[E0277]: `A` is not valid to request as data in a `Query`
   --> crates\bevy_ecs\src\query\world_query.rs:260:18
    |
260 | fn system(query: Query<A>) {}
    |                  ^^^^^^^^ invalid `Query` data
    |
    = help: the trait `fetch::QueryData` is not implemented for `A`
    = note: if `A` is a component type, try using `&A` or `&mut A`
    = help: the following other types implement trait `fetch::QueryData`:
              &'__w mut T
              &Archetype
              &T
              ()
              (F,)
              (F0, F1)
              (F0, F1, F2)
              (F0, F1, F2, F3)
            and 41 others
note: required by a bound in `system::query::Query`
   --> crates\bevy_ecs\src\system\query.rs:362:37
    |
362 | pub struct Query<'world, 'state, D: QueryData, F: QueryFilter = ()> {
    |                                     ^^^^^^^^^ required by this bound in `Query`
```
2024-11-21 03:52:10 +00:00
..
access.rs undeprecate component_reads_and_writes (#16357) 2024-11-11 23:28:16 +00:00
builder.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
error.rs QueryEntityError: Use short name for components (#16032) 2024-10-20 17:56:43 +00:00
fetch.rs Add a note to the on_unimplemented message for QueryData recommending &T and &mut T. (#16449) 2024-11-21 03:52:10 +00:00
filter.rs More #[doc(fake_variadic)] goodness (#16108) 2024-10-27 19:01:50 +00:00
iter.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
mod.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
par_iter.rs Fix query transmute from table to archetype iteration unsoundness (#14615) 2024-08-27 00:58:40 +00:00
state.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
world_query.rs Add query reborrowing (#14690) 2024-08-15 17:38:56 +00:00