Skip to content
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

'rustc' has overflowed its stack error #39639

Closed
J-F-Liu opened this issue Feb 8, 2017 · 2 comments
Closed

'rustc' has overflowed its stack error #39639

J-F-Liu opened this issue Feb 8, 2017 · 2 comments

Comments

@J-F-Liu
Copy link

@J-F-Liu J-F-Liu commented Feb 8, 2017

I see this error also reported in other issues, but I think the cause is different. Here is my example code:

#![feature(conservative_impl_trait)]

trait Trait {
    fn method(&self, x: i32) -> i32;
}

impl<F> Trait for F
    where F: Fn(i32) -> i32
{
    fn method(&self, x: i32) -> i32 {
        if x > 0 { self(x - 1) } else { 0 }
    }
}

fn call<T: Trait, F: Fn() -> T>(f: F) -> impl Trait {
    move |x: i32| f().method(x)
}

fn expr() -> impl Trait {
    call(expr)
    // move |x: i32| expr().method(x)
}

fn main() {
    println!("{:?}", expr().method(2));
}
rustc 1.17.0-nightly (ea7a6486a 2017-02-04)

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow

If you uncomment move || expr().method() and comment call(expr) build can success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants