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

Comments

Projects
None yet
5 participants
@J-F-Liu
Copy link

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.

@cyplo

This comment has been minimized.

Copy link
Contributor

cyplo commented Jun 30, 2017

still happening now with rustc 1.20.0-nightly (f590a44 2017-06-27)

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Jan 5, 2018

Dup of #39555 and #38064

@cramertj cramertj closed this Jan 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment