mirror of
https://github.com/bevyengine/bevy
synced 2024-12-22 19:13:08 +00:00
8039f34b0d
# Objective The current `QueryData` derive panics when it encounters an error. Additionally, it doesn't provide the clearest error message: ```rust #[derive(QueryData)] #[query_data(mut)] struct Foo { // ... } ``` ``` error: proc-macro derive panicked --> src/foo.rs:16:10 | 16 | #[derive(QueryData)] | ^^^^^^^^^ | = help: message: Invalid `query_data` attribute format ``` ## Solution Updated the derive logic to not panic and gave a bit more detail in the error message. This is makes the error message just a bit clearer and maintains the correct span: ``` error: invalid attribute, expected `mutable` or `derive` --> src/foo.rs:17:14 | 17 | #[query_data(mut)] | ^^^ ``` ## Testing You can test locally by running the following in `crates/bevy_ecs/compile_fail`: ``` cargo test --target-dir ../../../target ``` |
||
---|---|---|
.. | ||
entity_ref_mut_lifetime_safety.rs | ||
entity_ref_mut_lifetime_safety.stderr | ||
query_exact_sized_iterator_safety.rs | ||
query_exact_sized_iterator_safety.stderr | ||
query_iter_combinations_mut_iterator_safety.rs | ||
query_iter_combinations_mut_iterator_safety.stderr | ||
query_iter_many_mut_iterator_safety.rs | ||
query_iter_many_mut_iterator_safety.stderr | ||
query_lifetime_safety.rs | ||
query_lifetime_safety.stderr | ||
query_to_readonly.rs | ||
query_to_readonly.stderr | ||
query_transmute_safety.rs | ||
query_transmute_safety.stderr | ||
system_param_derive_readonly.rs | ||
system_param_derive_readonly.stderr | ||
system_query_get_lifetime_safety.rs | ||
system_query_get_lifetime_safety.stderr | ||
system_query_get_many_lifetime_safety.rs | ||
system_query_get_many_lifetime_safety.stderr | ||
system_query_get_many_mut_lifetime_safety.rs | ||
system_query_get_many_mut_lifetime_safety.stderr | ||
system_query_iter_lifetime_safety.rs | ||
system_query_iter_lifetime_safety.stderr | ||
system_query_iter_many_mut_lifetime_safety.rs | ||
system_query_iter_many_mut_lifetime_safety.stderr | ||
system_query_set_get_lifetime_safety.rs | ||
system_query_set_get_lifetime_safety.stderr | ||
system_query_set_iter_lifetime_safety.rs | ||
system_query_set_iter_lifetime_safety.stderr | ||
system_state_get_lifetime_safety.rs | ||
system_state_get_lifetime_safety.stderr | ||
system_state_iter_lifetime_safety.rs | ||
system_state_iter_lifetime_safety.stderr | ||
system_state_iter_mut_overlap_safety.rs | ||
system_state_iter_mut_overlap_safety.stderr | ||
world_query_derive.rs | ||
world_query_derive.stderr |