Skip to content

Commit

Permalink
SystemParam Derive fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MinerSebas committed Sep 17, 2021
1 parent 42409fc commit 90dfd7f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use syn::{
punctuated::Punctuated,
token::Comma,
Data, DataStruct, DeriveInput, Field, Fields, GenericParam, Ident, Index, LitInt, Path, Result,
Token,
Token, TypeParam,
};

struct AllTuples {
Expand Down Expand Up @@ -361,7 +361,13 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
.collect();

let mut punctuated_generics = Punctuated::<_, Token![,]>::new();
punctuated_generics.extend(lifetimeless_generics.iter());
punctuated_generics.extend(lifetimeless_generics.iter().map(|g| match g {
GenericParam::Type(g) => GenericParam::Type(TypeParam {
default: None,
..g.clone()
}),
_ => panic!(),
}));

let mut punctuated_generic_idents = Punctuated::<_, Token![,]>::new();
punctuated_generic_idents.extend(lifetimeless_generics.iter().map(|g| match g {
Expand Down Expand Up @@ -406,7 +412,7 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
}
}

impl #impl_generics #path::system::SystemParamFetch<'w, 's> for #fetch_struct_name <(#(<#field_types as #path::system::SystemParam>::Fetch,)*), #punctuated_generic_idents> {
impl #impl_generics #path::system::SystemParamFetch<'w, 's> for #fetch_struct_name <(#(<#field_types as #path::system::SystemParam>::Fetch,)*), #punctuated_generic_idents> #where_clause {
type Item = #struct_name#ty_generics;
unsafe fn get_param(
state: &'s mut Self,
Expand Down

0 comments on commit 90dfd7f

Please sign in to comment.