-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fixed derived reflect outputting incorrect where clause. Fixes #7989 #7991
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
Do you mind adding a minimum reproduction to the tests in |
I have no problem doing this, but it appears from the test cases: handle::Handle<T>: Reflect` is not satisfied
error: expected one of `{`, lifetime, or type, found `,`
--> crates/bevy_asset/src/handle.rs:105:21
|
105 | #[derive(Component, Reflect, FromReflect)]
| ^^^^^^^ expected one of `{`, lifetime, or type
|
= note: this error originates in the derive macro `Reflect` (in Nightly builds, run with -Z macro-backtrace for more info) Seems the fix also unfixed some things. Trying to reason about the differences here but I'm not seeing why these similar cases end up breaking in different ways. |
I think I got it working by doing the following:
|
|
||
let where_from_reflect_clause = extend_where_clause( | ||
where_clause, | ||
&WhereClauseOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to import this type
#(#field_types: #bevy_reflect_path::FromReflect,)* | ||
}); | ||
|
||
let where_from_reflect_clause = extend_where_clause( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be done for enums as well
Closing in favor of #8014 |
# Objective Fixes #7989 Based on #7991 by @CoffeeVampir3 ## Solution There were three parts to this issue: 1. `extend_where_clause` did not account for the optionality of a where clause's trailing comma ```rust // OKAY struct Foo<T> where T: Asset, {/* ... */} // ERROR struct Foo<T> where T: Asset {/* ... */} ``` 2. `FromReflect` derive logic was not actively using `extend_where_clause` which led to some inconsistencies (enums weren't adding _any_ additional bounds even) 3. Using `extend_where_clause` in the `FromReflect` derive logic meant we had to optionally add `Default` bounds to ignored fields iff the entire item itself was not already `Default` (otherwise the definition for `Handle<T>` wouldn't compile since `HandleType` doesn't impl `Default` but `Handle<T>` itself does) --- ## Changelog - Fixed issue where a missing trailing comma could break the reflection derives
# Objective Fixes #7989 Based on #7991 by @CoffeeVampir3 ## Solution There were three parts to this issue: 1. `extend_where_clause` did not account for the optionality of a where clause's trailing comma ```rust // OKAY struct Foo<T> where T: Asset, {/* ... */} // ERROR struct Foo<T> where T: Asset {/* ... */} ``` 2. `FromReflect` derive logic was not actively using `extend_where_clause` which led to some inconsistencies (enums weren't adding _any_ additional bounds even) 3. Using `extend_where_clause` in the `FromReflect` derive logic meant we had to optionally add `Default` bounds to ignored fields iff the entire item itself was not already `Default` (otherwise the definition for `Handle<T>` wouldn't compile since `HandleType` doesn't impl `Default` but `Handle<T>` itself does) --- ## Changelog - Fixed issue where a missing trailing comma could break the reflection derives
Objective
Solution
Their is no change or migration required for this fix.