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

[Merged by Bors] - Make the SystemParam derive macro more flexible #6694

Closed
wants to merge 11 commits into from
11 changes: 8 additions & 3 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,14 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
let w = format_ident!("w");
let s = format_ident!("s");
if ident != &w && ident != &s {
return syn::Error::new_spanned(lt, "invalid lifetime name: expected `'w` or `'s`")
.into_compile_error()
.into();
return syn::Error::new_spanned(
lt,
r#"invalid lifetime name: expected `'w` or `'s`
'w -- refers to data stored in the World.
's -- refers to data stored in the SystemParam's state.'"#,
)
.into_compile_error()
.into();
Comment on lines +383 to +390
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@james7132 do you think this is an improvement?

This usage is called out in the docs, but IMO the best way of teaching this is to just let users do it wrong, then have the error tell them the right way of doing it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better to me. Thanks!

}
}

Expand Down