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

Reflect derive macros don't support self-referential types #8971

Closed
alice-i-cecile opened this issue Jun 27, 2023 · 1 comment
Closed

Reflect derive macros don't support self-referential types #8971

alice-i-cecile opened this issue Jun 27, 2023 · 1 comment
Labels
A-Reflection Runtime information about types C-Bug An unexpected or incorrect behavior

Comments

@alice-i-cecile
Copy link
Member

One issue this brings up (and that this PR does not need to be the one to fix) is that we apparently don't support self-referential types. The following won't compile:

#[derive(Reflect, FromReflect)]
struct Foo {
  foo: Vec<Foo>
}
Errors
error[E0275]: overflow evaluating the requirement `tests::recursive_typed_storage_does_not_hang::Foo: type_path::TypePath`
    --> crates/bevy_reflect/src/lib.rs:1856:18
     |
1856 |         #[derive(Reflect, FromReflect)]
     |                  ^^^^^^^
     |
note: required for `Vec<tests::recursive_typed_storage_does_not_hang::Foo>` to implement `reflect::Reflect`
    --> crates/bevy_reflect/src/impls/std.rs:326:41
     |
326  |           impl<T: FromReflect + TypePath> Reflect for $ty {
     |                                 --------  ^^^^^^^     ^^^
     |                                 |
     |                                 unsatisfied trait bound introduced here
...
error[E0275]: overflow evaluating the requirement `tests::recursive_typed_storage_does_not_hang::Foo: from_reflect::FromReflect`
    --> crates/bevy_reflect/src/lib.rs:1856:27
     |
1856 |         #[derive(Reflect, FromReflect)]
     |                           ^^^^^^^^^^^
     |
note: required for `Vec<tests::recursive_typed_storage_does_not_hang::Foo>` to implement `from_reflect::FromReflect`
    --> crates/bevy_reflect/src/impls/std.rs:410:41
     |
410  |           impl<T: FromReflect + TypePath> FromReflect for $ty {
     |                   -----------             ^^^^^^^^^^^     ^^^
     |                   |
     |                   unsatisfied trait bound introduced here
...

Originally posted by @MrGVSV in #8957 (review)

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Reflection Runtime information about types labels Jun 27, 2023
@NiklasEi
Copy link
Member

This looks like a duplicate of #8965

@alice-i-cecile alice-i-cecile closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

2 participants