Skip to content

Commit

Permalink
Fix all_tuples macro for non-0/1 starts (#4002)
Browse files Browse the repository at this point in the history
# Objective
`all_tuples` panics when the start count is set to anything other than 0 or 1. Fix this bug.

## Solution
Originally part of #2381, this PR fixes the slice indexing used by the proc macro.
  • Loading branch information
james7132 committed Feb 21, 2022
1 parent fb8af3a commit 5afda8d
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 @@ -46,7 +46,7 @@ impl Parse for AllTuples {
#[proc_macro]
pub fn all_tuples(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as AllTuples);
let len = (input.start..=input.end).count();
let len = input.end - input.start;
let mut ident_tuples = Vec::with_capacity(len);
for i in input.start..=input.end {
let idents = input
Expand All @@ -66,7 +66,7 @@ pub fn all_tuples(input: TokenStream) -> TokenStream {

let macro_ident = &input.macro_ident;
let invocations = (input.start..=input.end).map(|i| {
let ident_tuples = &ident_tuples[0..i];
let ident_tuples = &ident_tuples[0..i - input.start];
quote! {
#macro_ident!(#(#ident_tuples),*);
}
Expand Down

0 comments on commit 5afda8d

Please sign in to comment.