mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 22:18:33 +00:00
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.
This commit is contained in:
parent
fb8af3aec3
commit
5afda8df6f
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
@ -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),*);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue