Skip to content

bevy_ecs regression: normalization where-bounds > alias-bounds #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
compiler-errors opened this issue Apr 11, 2025 · 4 comments
Closed
Assignees
Labels
from-crater A regression found via a crater run, not part of our test suite

Comments

@compiler-errors
Copy link
Member

Not yet minimized

https://crater-reports.s3.amazonaws.com/pr-133502-1/try%23fa8e241660363f48d64b66b05eea58c93ab828fb/reg/bevy_app-0.16.0-rc.3/log.txt

[INFO] [stdout] error[E0283]: type annotations needed: cannot satisfy `MaybeLocation: FromReflect`
[INFO] [stdout]     --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.16.0-rc.3/src/event/base.rs:118:12
[INFO] [stdout]      |
[INFO] [stdout] 118  | pub struct EventId<E: Event> {
[INFO] [stdout]      |            ^^^^^^^^^^^^^^^^^
[INFO] [stdout]      |
[INFO] [stdout] note: multiple `impl`s or `where` clauses satisfying `MaybeLocation: FromReflect` found
[INFO] [stdout]     --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.16.0-rc.3/src/change_detection.rs:1197:45
[INFO] [stdout]      |
[INFO] [stdout] 1197 | #[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
[INFO] [stdout]      |                                             ^^^^^^^
[INFO] [stdout]      |
[INFO] [stdout]     ::: /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.16.0-rc.3/src/event/base.rs:115:12
[INFO] [stdout]      |
[INFO] [stdout] 115  |     derive(Reflect),
[INFO] [stdout]      |            ^^^^^^^
[INFO] [stdout] note: required for `EventId<E>` to implement `GetTypeRegistration`
[INFO] [stdout]     --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.16.0-rc.3/src/event/base.rs:115:12
[INFO] [stdout]      |
[INFO] [stdout] 115  |     derive(Reflect),
[INFO] [stdout]      |            ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
[INFO] [stdout] ...
[INFO] [stdout] 118  | pub struct EventId<E: Event> {
[INFO] [stdout]      |            ^^^^^^^^^^^^^^^^^
[INFO] [stdout]      = note: this error originates in the derive macro `Reflect` (in Nightly builds, run with -Z macro-backtrace for more info)

Tons of ambiguities when building bevy_ecs.

@lcnr lcnr added the from-crater A regression found via a crater run, not part of our test suite label Apr 14, 2025
@lcnr
Copy link
Contributor

lcnr commented Apr 14, 2025

at least one of the errors is

fn foo<I, B>(x: I)
where
    I: IntoIterator,
    I::IntoIter: Iterator<Item = ()>,
    
{
    x.into_iter().next();
}

or further minimized

trait Iterator {
    type Item;
}

trait IntoIterator {
    type Item;
    type IntoIter: Iterator<Item = Self::Item>;
}

fn normalize<I: Iterator<Item = ()>>() {}

fn foo<I>()
where
    I: IntoIterator,
    I::IntoIter: Iterator<Item = ()>,
{
    normalize::<I::IntoIter>();
}

@lcnr
Copy link
Contributor

lcnr commented Apr 14, 2025

caused by not preferring where-bounds over alias bounds for projection goals: https://github.com/rust-lang/rust/blob/5961e5ba3daa20d98f549eb9029105ae50c13aed/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs#L803-L826

we've got Iterator<Item = ()> where-bound and Iterator<Item = Self::Assoc> alias-bound

have to eat lunch, but the fix for that issue is easy :3

@lcnr
Copy link
Contributor

lcnr commented Apr 14, 2025

"type annotations needed: cannot satisfy MaybeLocation: FromReflect"

caused by rust-lang/rust#139791 afaict. The only remaining issue are 2 variants of this one (and once for each tuple size)

error[E0283]: type annotations needed
   --> crates/bevy_ecs/src/system/exclusive_function_system.rs:295:17
    |
295 |                 call_inner(self, input, world, $($param),*)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
...
302 | all_tuples!(impl_exclusive_system_function, 0, 16, F);
    | ----------------------------------------------------- in this macro invocation
    |
    = note: cannot satisfy `_: input::SystemInput`
    = help: the following types implement trait `input::SystemInput`:

@lcnr
Copy link
Contributor

lcnr commented Apr 14, 2025

the last regressions are intended

        impl<In, Out, Func, $($param: SystemParam),*> SystemParamFunction<(HasSystemInput, fn(In, $($param,)*) -> Out)> for Func
        where
            Func: Send + Sync + 'static,
            for <'a> &'a mut Func:
                FnMut(In, $($param),*) -> Out +
                FnMut(In::Param<'_>, $(SystemParamItem<$param>),*) -> Out,
            In: SystemInput + 'static,
            Out: 'static
        {
            type In = In;
            type Out = Out;
            type Param = ($($param,)*);
            #[inline]
            fn run(&mut self, input: In::Inner<'_>, param_value: SystemParamItem< ($($param,)*)>) -> Out {
                fn call_inner<In: SystemInput, Out, $($param,)*>(
                    mut f: impl FnMut(In::Param<'_>, $($param,)*)->Out,
                    input: In,
                    $($param: $param,)*
                )->Out{
                    f(input, $($param,)*)
                }
                let ($($param,)*) = param_value;
                call_inner(self, In::wrap(input), $($param),*)
            }
        }

the call to call_inner does not constrain In. This previously compiled as we incorrectly relate arguments of higher ranked aliases in the old solver.

Open PR in bevyengine/bevy#18840

@lcnr lcnr self-assigned this Apr 14, 2025
@lcnr lcnr moved this from unknown to in progress in -Znext-solver=globally Apr 14, 2025
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 15, 2025
…r=compiler-errors

normalize: prefer `ParamEnv` over `AliasBound` candidates

cc rust-lang/trait-system-refactor-initiative#175 not the only issue affecting bevy sadly

r? `@compiler-errors`
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 15, 2025
…r=compiler-errors

normalize: prefer `ParamEnv` over `AliasBound` candidates

cc rust-lang/trait-system-refactor-initiative#175 not the only issue affecting bevy sadly

r? ``@compiler-errors``
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 15, 2025
Rollup merge of rust-lang#139798 - lcnr:where-bounds-gt-alias-bound, r=compiler-errors

normalize: prefer `ParamEnv` over `AliasBound` candidates

cc rust-lang/trait-system-refactor-initiative#175 not the only issue affecting bevy sadly

r? ``@compiler-errors``
@lcnr lcnr moved this from in progress to done in -Znext-solver=globally Apr 16, 2025
@lcnr lcnr closed this as completed by moving to done in -Znext-solver=globally Apr 16, 2025
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this issue Apr 17, 2025
…r-errors

normalize: prefer `ParamEnv` over `AliasBound` candidates

cc rust-lang/trait-system-refactor-initiative#175 not the only issue affecting bevy sadly

r? ``@compiler-errors``
@lcnr lcnr changed the title bevy_ecs regression bevy_ecs regression: normalization where-bounds > alias-bounds Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from-crater A regression found via a crater run, not part of our test suite
Projects
Development

No branches or pull requests

2 participants