bevyengine / bevyengine/bevy

Generic type info not captured when `#[reflect(type_path = false]`

Open
#24,379 0 comments 0 reactions 0 assignees View on GitHub
A-Reflection C-Bug D-Complex D-Macros
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version and features

Bevy 0.19.0-dev

## What you did

```rust
#[derive(Reflect, Clone)]
#[reflect(type_path = false]
struct Foo(T);

impl TypePath for Foo {
fn type_path() -> &'static str {
todo!()
}

fn short_type_path() -> &'static str {
todo!()
}
}
```

## What went wrong

As found in https://github.com/bevyengine/bevy/issues/24235#issuecomment-4511382982, it seems we are not generating the `Typed` impl with generic type information even though `T: TypePath` is added by the fact that `T` is an active field.

Ideally, if we can generate generic type information, we should. Although, this may complicate the rules a user may understand (i.e. "opting out of `TypePath` means no generic information" becomes "opting out of `TypePath` _might_ mean no generic information").

I think paired with the solution posted in https://github.com/bevyengine/bevy/issues/24235#issuecomment-4511479411, it should be possible. It will probably just require some more complex logic in the macro code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.