Skip to content

Commit 5afda8d

Browse files
committed
Fix all_tuples macro for non-0/1 starts (#4002)
# 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.
1 parent fb8af3a commit 5afda8d

File tree

1 file changed

+2
-2
lines changed
  • crates/bevy_ecs/macros/src

1 file changed

+2
-2
lines changed

crates/bevy_ecs/macros/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Parse for AllTuples {
4646
#[proc_macro]
4747
pub fn all_tuples(input: TokenStream) -> TokenStream {
4848
let input = parse_macro_input!(input as AllTuples);
49-
let len = (input.start..=input.end).count();
49+
let len = input.end - input.start;
5050
let mut ident_tuples = Vec::with_capacity(len);
5151
for i in input.start..=input.end {
5252
let idents = input
@@ -66,7 +66,7 @@ pub fn all_tuples(input: TokenStream) -> TokenStream {
6666

6767
let macro_ident = &input.macro_ident;
6868
let invocations = (input.start..=input.end).map(|i| {
69-
let ident_tuples = &ident_tuples[0..i];
69+
let ident_tuples = &ident_tuples[0..i - input.start];
7070
quote! {
7171
#macro_ident!(#(#ident_tuples),*);
7272
}

0 commit comments

Comments
 (0)