Skip to content

Commit 2c2f0ba

Browse files
Remove refactor that broke test
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
1 parent 6cb6ee2 commit 2c2f0ba

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

src/chain/fork_clone_builder.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*
1616
*/
1717

18-
use bevy::prelude::Entity;
1918
use bevy::utils::all_tuples;
20-
use smallvec::SmallVec;
2119

2220
use crate::{
2321
Chain, UnusedTarget, AddOperation, ForkClone, ForkTargetStorage, Builder,
@@ -45,18 +43,19 @@ macro_rules! impl_forkclonebuilder_for_tuple {
4543
source: Output<R>,
4644
builder: &mut Builder,
4745
) -> Self::Outputs {
48-
let mut targets = SmallVec::<[Entity; 8]>::new();
49-
let ($($F,)*) = self;
50-
let u =
51-
(
46+
let targets =
47+
[
5248
$(
5349
{
54-
let target = builder.commands.spawn(UnusedTarget).id();
55-
targets.push(target);
56-
($F)(Chain::new(target, builder))
50+
// Variable is only used to make sure this cycle is repeated once
51+
// for each instance of the $T type, but the type itself is not
52+
// used.
53+
#[allow(unused)]
54+
let $F = std::marker::PhantomData::<$F>;
55+
builder.commands.spawn(UnusedTarget).id()
5756
},
5857
)*
59-
);
58+
];
6059

6160
builder.commands.add(AddOperation::new(
6261
Some(source.scope()),
@@ -65,7 +64,20 @@ macro_rules! impl_forkclonebuilder_for_tuple {
6564
ForkTargetStorage::from_iter(targets)
6665
)
6766
));
68-
u
67+
let ($($F,)*) = self;
68+
// The compiler throws a warning when implementing this for
69+
// tuple sizes that wouldn't use the result of the first _idx = _idx + 1
70+
// so we add a leading underscore to suppress the warning
71+
let mut _idx = 0;
72+
(
73+
$(
74+
{
75+
let res = ($F)(Chain::new(targets[_idx], builder));
76+
_idx = _idx + 1;
77+
res
78+
},
79+
)*
80+
)
6981
}
7082
}
7183
}

0 commit comments

Comments
 (0)