Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Recursion compilation failure #59

Closed
raviqqe opened this issue Feb 5, 2018 · 3 comments
Closed

Recursion compilation failure #59

raviqqe opened this issue Feb 5, 2018 · 3 comments

Comments

@raviqqe
Copy link
Contributor

raviqqe commented Feb 5, 2018

The code below fails to be compiled.

#![feature(proc_macro, conservative_impl_trait, generators)]

extern crate futures_await as futures;

use futures::prelude::*;

#[async]
fn foo() -> Result<(), ()> {
    Ok(await!(foo())?)
}

fn main() {
    foo().wait().unwrap();
}

Build log:

> cargo build
   Compiling tmp v0.1.0 (file:///home/raviqqe/tmp)
error[E0275]: overflow evaluating the requirement `impl futures::__rt::MyFuture<std::result::Result<(), ()>>`
  |
  = help: consider adding a `#![recursion_limit="128"]` attribute to your crate

error: aborting due to previous error

error: Could not compile `tmp`.

To learn more, run the command again with --verbose.

However, this may not be due to this crate but this issue.

@raviqqe
Copy link
Contributor Author

raviqqe commented Feb 5, 2018

Sorry. I found out it seems to be caused by the experimental impl Trait. The similar error happens with the following code. (Or is there no way to infer concrete types in these situations?)

#![feature(conservative_impl_trait)]

fn foo() -> impl Default {
    foo()
}

fn main() {
    foo();
}

Build log:

> cargo build
   Compiling tmp v0.1.0 (file:///home/raviqqe/tmp)
warning: function cannot return without recurring
 --> src/main.rs:3:1
  |
3 | fn foo() -> impl Default {
  | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recurring
4 |     foo()
  |     ----- recursive call site
  |
  = note: #[warn(unconditional_recursion)] on by default
  = help: a `loop` may express intention better if this is on purpose

error[E0275]: overflow evaluating the requirement `impl std::default::Default`
  |
  = help: consider adding a `#![recursion_limit="128"]` attribute to your crate

error: aborting due to previous error

error: Could not compile `tmp`.

To learn more, run the command again with --verbose.

Please close this if it's irrelevant.

@alexcrichton
Copy link
Owner

Thanks for the report! I agree though that since this is related to impl trait there's not much we can do here, so closing.

@raviqqe
Copy link
Contributor Author

raviqqe commented Feb 6, 2018

For others who stumbled upon the same issue, the only workaround I found is to use #[async(boxed)].

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants