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

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


None yet
5 participants
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:


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 {
    // 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.


This comment has been minimized.

Copy link

cyplo commented Jun 30, 2017

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


This comment has been minimized.

Copy link

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