mirror of
https://github.com/bevyengine/bevy
synced 2024-11-24 21:53:07 +00:00
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` ```
This commit is contained in:
parent
deda3f2522
commit
4362b52a01
1 changed files with 2 additions and 1 deletions
|
@ -272,7 +272,8 @@ use smallvec::SmallVec;
|
||||||
/// [`ReadOnly`]: Self::ReadOnly
|
/// [`ReadOnly`]: Self::ReadOnly
|
||||||
#[diagnostic::on_unimplemented(
|
#[diagnostic::on_unimplemented(
|
||||||
message = "`{Self}` is not valid to request as data in a `Query`",
|
message = "`{Self}` is not valid to request as data in a `Query`",
|
||||||
label = "invalid `Query` data"
|
label = "invalid `Query` data",
|
||||||
|
note = "if `{Self}` is a component type, try using `&{Self}` or `&mut {Self}`"
|
||||||
)]
|
)]
|
||||||
pub unsafe trait QueryData: WorldQuery {
|
pub unsafe trait QueryData: WorldQuery {
|
||||||
/// The read-only variant of this [`QueryData`], which satisfies the [`ReadOnlyQueryData`] trait.
|
/// The read-only variant of this [`QueryData`], which satisfies the [`ReadOnlyQueryData`] trait.
|
||||||
|
|
Loading…
Reference in a new issue