Skip to content

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

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
SpecificProtagonist opened this issue Apr 14, 2024 · 3 comments
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@SpecificProtagonist
Copy link
Contributor

SpecificProtagonist commented Apr 14, 2024

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.

@SpecificProtagonist SpecificProtagonist added the C-bug Category: This is a bug. label Apr 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 14, 2024
@SpecificProtagonist SpecificProtagonist changed the title Recursion overflow when importing bevy_ecs error[E0275]: overflow evaluating the requirement… when importing bevy_ecs Apr 14, 2024
@jieyouxu jieyouxu added A-trait-system Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 15, 2024
@SpecificProtagonist
Copy link
Contributor Author

@jieyouxu I couldn't find any guidance on what consists an mcve, is the following enough?

//! ```cargo
//! [dependencies]
//! bevy_ecs = "0.13"
//! ```
fn main() {
    fn bar(_: impl IntoIterator<Item = ()>) {}
    bar(Some(()).iter().copied().collect());
    use bevy_ecs;
}

@jieyouxu
Copy link
Member

@jieyouxu I couldn't find any guidance on what consists an mcve, is the following enough?

//! ```cargo
//! [dependencies]
//! bevy_ecs = "0.13"
//! ```
fn main() {
    fn bar(_: impl IntoIterator<Item = ()>) {}
    bar(Some(()).iter().copied().collect());
    use bevy_ecs;
}

Basically we're trying to minimize it as small as possible, and as self contained as possible (without external deps is the ideal example). But any steps towards that are helpful.

@pacak
Copy link
Contributor

pacak commented Jun 30, 2024

No longer overflows in current nightly, bisection suggests that it was fixed in #123618.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants