Skip to content

Commit 2a2ce6e

Browse files
lcnrmockersf
authored andcommitted
remove reliance on a trait solver inference bug (#18840)
The parameter `In` of `call_inner` is completely unconstrained by its arguments and return type. We are only able to infer it by assuming that the only associated type equal to `In::Param<'_>` is `In::Param<'_>` itself. It could just as well be some other associated type which only normalizes to `In::Param<'_>`. This will change with the next-generation trait solver and was encountered by a crater run rust-lang/rust#133502 cc rust-lang/trait-system-refactor-initiative#168 I couldn't think of a cleaner alternative here. I first tried to just provide `In` as an explicit type parameter. This is also kinda ugly as I need to provide a variable number of them and `${ignore(..)}` is currently still unstable rust-lang/rust#83527. Sorry for the inconvenience. Also fun that this function exists to avoid a separate solver bug in the first place 😅
1 parent 495798c commit 2a2ce6e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

crates/bevy_ecs/src/system/exclusive_function_system.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ macro_rules! impl_exclusive_system_function {
284284
// without using this function. It fails to recognize that `func`
285285
// is a function, potentially because of the multiple impls of `FnMut`
286286
fn call_inner<In: SystemInput, Out, $($param,)*>(
287+
_: PhantomData<In>,
287288
mut f: impl FnMut(In::Param<'_>, &mut World, $($param,)*) -> Out,
288289
input: In::Inner<'_>,
289290
world: &mut World,
@@ -292,7 +293,7 @@ macro_rules! impl_exclusive_system_function {
292293
f(In::wrap(input), world, $($param,)*)
293294
}
294295
let ($($param,)*) = param_value;
295-
call_inner(self, input, world, $($param),*)
296+
call_inner(PhantomData::<In>, self, input, world, $($param),*)
296297
}
297298
}
298299
};

crates/bevy_ecs/src/system/function_system.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -972,14 +972,15 @@ macro_rules! impl_system_function {
972972
#[inline]
973973
fn run(&mut self, input: In::Inner<'_>, param_value: SystemParamItem< ($($param,)*)>) -> Out {
974974
fn call_inner<In: SystemInput, Out, $($param,)*>(
975+
_: PhantomData<In>,
975976
mut f: impl FnMut(In::Param<'_>, $($param,)*)->Out,
976977
input: In::Inner<'_>,
977978
$($param: $param,)*
978979
)->Out{
979980
f(In::wrap(input), $($param,)*)
980981
}
981982
let ($($param,)*) = param_value;
982-
call_inner(self, input, $($param),*)
983+
call_inner(PhantomData::<In>, self, input, $($param),*)
983984
}
984985
}
985986
};

0 commit comments

Comments
 (0)