Skip to content

Commit

Permalink
Fix type parameter name conflicts of derive(Bundle) (#4636)
Browse files Browse the repository at this point in the history
# Objective

This code currently fails to compile with error ``the name `T` is already used for a generic parameter in this item's generic parameters``, because `T` is also used in code generated by `derive(Bundle)`.

```rust
#[derive(Bundle)]
struct MyBundle<T: Component> {
    component: T,
}
```

## Solution

Add double underscores to type parameter names in `derive(Bundle)`.
  • Loading branch information
infmagic2047 committed May 2, 2022
1 parent e49542b commit 2c14582
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
}

#[allow(unused_variables, unused_mut, non_snake_case)]
unsafe fn from_components<T, F>(ctx: &mut T, mut func: F) -> Self
unsafe fn from_components<__T, __F>(ctx: &mut __T, mut func: __F) -> Self
where
F: FnMut(&mut T) -> #ecs_path::ptr::OwningPtr<'_>
__F: FnMut(&mut __T) -> #ecs_path::ptr::OwningPtr<'_>
{
Self {
#(#field_from_components)*
Expand Down

0 comments on commit 2c14582

Please sign in to comment.