Skip to content

Indefinitely hangs on hidden "overflow evaluating the requirement" errors when the complexity is too high. #92822

Open
@Wopple

Description

@Wopple

Minimal Example

main.rs

use std::pin::Pin;
use futures::Future;

trait MyTrait {
    type Value;
    type Future;
}

impl<S> MyTrait for &S where S: MyTrait {}

struct MyStruct<S>;

impl MyTrait for MyStruct<dyn MyTrait<
    Value = usize,
    Future = Pin<Box<dyn Future<Output = Option<usize>>>>,
>>
    where Self::Future: 'static
{
    type Value = usize;
    type Future = Pin<Box<dyn Future<Output = Option<Self::Value>>>>;
}

fn main() {}

Cargo.toml

[package]
name = "rust-playground"
version = "0.1.0"
edition = "2021"

[dependencies]
futures = "0.3.14"

Meta

rustc --version --verbose:

rustc 1.59.0-nightly (0fb1c371d 2021-12-06)
binary: rustc
commit-hash: 0fb1c371d4a14f9ce7a721d8aea683a6e6774f6c
commit-date: 2021-12-06
host: aarch64-apple-darwin
release: 1.59.0-nightly
LLVM version: 13.0.0

Error output

It doesn't produce error output, the compiler hangs indefinitely. However, simplifying the example in any way seems to uncover a bunch of "overflow evaluating the requirement" errors. For example, by commenting out the first implementation of the trait, one of the errors is:

error[E0275]: overflow evaluating the requirement `<MyStruct<(dyn MyTrait<Value = usize, Future = Pin<Box<(dyn futures::Future<Output = Option<usize>> + 'static)>>> + 'static)> as MyTrait>::Future == _`
  --> src/main.rs:13:1
   |
13 | / impl MyTrait for MyStruct<dyn MyTrait<
14 | |     Value = usize,
15 | |     Future = Pin<Box<dyn Future<Output = Option<usize>>>>,
16 | | >>
...  |
20 | |     type Future = Pin<Box<dyn Future<Output = Option<Self::Value>>>>;
21 | | }
   | |_^
   |
note: required because of the requirements on the impl of `MyTrait` for `MyStruct<(dyn MyTrait<Value = usize, Future = Pin<Box<(dyn futures::Future<Output = Option<usize>> + 'static)>>> + 'static)>`
  --> src/main.rs:13:6
   |
13 |   impl MyTrait for MyStruct<dyn MyTrait<
   |  ______^^^^^^^_____^
14 | |     Value = usize,
15 | |     Future = Pin<Box<dyn Future<Output = Option<usize>>>>,
16 | | >>
   | |__^

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jan 12, 2022
added
I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
and removed
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
on Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-compilerRelevant to the compiler 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

        Participants

        @Wopple@JohnTitor

        Issue actions

          Indefinitely hangs on hidden "overflow evaluating the requirement" errors when the complexity is too high. · Issue #92822 · rust-lang/rust