-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.