Skip to content

error[E0275]: overflow evaluating the requirement… when importing bevy_ecs #123925

Closed
@SpecificProtagonist

Description

@SpecificProtagonist

The following code correctly results in a compile error:

fn bar(_: impl IntoIterator<Item = ()>) {}
bar(Some(()).iter().copied().collect());
Correct compile error
error[E0283]: type annotations needed
 --> src/main.rs:3:34
  |
3 |     bar(Some(()).iter().copied().collect());
  |     ---                          ^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect`
  |     |
  |     required by a bound introduced by this call
  |
  = note: cannot satisfy `_: IntoIterator`
note: required by a bound in `bar`
 --> src/main.rs:2:20
  |
2 |     fn bar(_: impl IntoIterator<Item = ()>) {}
  |                    ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `bar`
help: consider specifying the generic argument
  |
3 |     bar(Some(()).iter().copied().collect::<Vec<_>>());
  |                                         ++++++++++
help: consider removing this method call, as the receiver has type `Copied<std::slice::Iter<'_, ()>>` and `Copied<std::slice::Iter<'_, ()>>: IntoIterator` trivially holds
  |
3 -     bar(Some(()).iter().copied().collect());
3 +     bar(Some(()).iter().copied());
  |

For more information about this error, try `rustc --explain E0283`.

I tried to add an unused use statement:

fn bar(_: impl IntoIterator<Item = ()>) {}
bar(Some(()).iter().copied().collect());
use bevy_ecs;

I expected to see this happen: The same compile error message.

Instead, this happened:

error[E0275]: overflow evaluating the requirement `&_: IntoIterator`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`tmp`)
  = note: required for `&Mut<'_, _>` to implement `IntoIterator`
  = note: 126 redundant requirements hidden
  = note: required for `&Mut<'_, Mut<'_, Mut<'_, Mut<'_, Mut<'_, Mut<'_, Mut<'_, Mut<'_, ...>>>>>>>>` to implement `IntoIterator`
  = note: the full name for the type has been written to '/home/vj/tmp/target/debug/deps/tmp-75de6303a4de5154.long-type-2937239491554411468.txt'
  = note: consider using `--verbose` to print the full type name to the console

The exact type varies (e.g. Mut, Res, Local).

This happens for any use x; where x is or depends on bevy_ecs version "^0.9".
There is also a bevy_ecs-specifc workaround in the compiler, but its not related as it is part of well-formedness checking and the error persists when renaming ParamSet.

What makes this bug annoying is that the error message doesn't give any indication as to where the code that causes the error (line 2 into above example) is.

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (0bf471f33 2024-04-13)
binary: rustc
commit-hash: 0bf471f339837af930ec90ef5e1e9cb232e99f29
commit-date: 2024-04-13
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

Also tried with 1.77.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions