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

Fix nested generics in Reflect derive #10791

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

MrGVSV
Copy link
Member

@MrGVSV MrGVSV commented Nov 29, 2023

Objective

Issue raised on Discord

Currently the following code fails due to a missing TypePath bound:

#[derive(Reflect)] struct Foo<T>(T);
#[derive(Reflect)] struct Bar<T>(Foo<T>);
#[derive(Reflect)] struct Baz<T>(Bar<Foo<T>>);

Solution

Add TypePath to the per-field bounds instead of just the generic type parameter bounds.

Related Work

It should be noted that #9046 would help make these kinds of issues easier to work around and/or avoid entirely.


Changelog

  • Fixes missing TypePath requirement when deriving Reflect on nested generics

@MrGVSV MrGVSV added C-Bug An unexpected or incorrect behavior A-Reflection Runtime information about types labels Nov 29, 2023
@MrGVSV MrGVSV added this to the 0.12.1 milestone Nov 29, 2023
@cart cart added this pull request to the merge queue Nov 29, 2023
Merged via the queue into bevyengine:main with commit daa8bf2 Nov 29, 2023
25 checks passed
@MrGVSV MrGVSV deleted the reflect-nested-generics branch November 29, 2023 01:59
cart pushed a commit that referenced this pull request Nov 30, 2023
# Objective

> Issue raised on
[Discord](https://discord.com/channels/691052431525675048/1002362493634629796/1179182488787103776)

Currently the following code fails due to a missing `TypePath` bound:

```rust
#[derive(Reflect)] struct Foo<T>(T);
#[derive(Reflect)] struct Bar<T>(Foo<T>);
#[derive(Reflect)] struct Baz<T>(Bar<Foo<T>>);
```

## Solution

Add `TypePath` to the per-field bounds instead of _just_ the generic
type parameter bounds.

### Related Work

It should be noted that #9046 would help make these kinds of issues
easier to work around and/or avoid entirely.

---

## Changelog

- Fixes missing `TypePath` requirement when deriving `Reflect` on nested
generics
james7132 pushed a commit to james7132/bevy that referenced this pull request Dec 1, 2023
# Objective

> Issue raised on
[Discord](https://discord.com/channels/691052431525675048/1002362493634629796/1179182488787103776)

Currently the following code fails due to a missing `TypePath` bound:

```rust
#[derive(Reflect)] struct Foo<T>(T);
#[derive(Reflect)] struct Bar<T>(Foo<T>);
#[derive(Reflect)] struct Baz<T>(Bar<Foo<T>>);
```

## Solution

Add `TypePath` to the per-field bounds instead of _just_ the generic
type parameter bounds.

### Related Work

It should be noted that bevyengine#9046 would help make these kinds of issues
easier to work around and/or avoid entirely.

---

## Changelog

- Fixes missing `TypePath` requirement when deriving `Reflect` on nested
generics
github-merge-queue bot pushed a commit that referenced this pull request Dec 24, 2023
# Objective

- Provides an alternate solution to the one implemented in #10791
without breaking changes.

## Solution

- Changes the bounds of macro-generated `TypePath` implementations to
universally ignore the types of fields, rather than use the same bounds
as other implementations. I think this is a more holistic solution than
#10791 because it totally erases the finicky bounds we currently
generate, helping to untangle the reflection trait system.
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
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants