rust-lang/rust

Infinite size checker doesn't see through impl Trait, leading to rustc overflow

spinda opened this issue · 3 comments

Test case:

#![feature(conservative_impl_trait)]

trait Quux {}

fn foo() -> impl Quux {
    struct Foo<T>(T);
    impl<T> Quux for Foo<T> {}
    Foo(bar())
}

fn bar() -> impl Quux {
    struct Bar<T>(T);
    impl<T> Quux for Bar<T> {}
    Bar(foo())
}

// effectively:
//     struct Foo(Bar);
//     struct Bar(Foo);
// should produce an error about infinite size

fn main() { foo(); }

Output:

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

rustc --version --verbose:

rustc 1.15.0-nightly (03bdaade2 2016-11-27)
binary: rustc
commit-hash: 03bdaade2a0c39118a5be927c667776a5de0d681
commit-date: 2016-11-27
host: x86_64-unknown-linux-gnu
release: 1.15.0-nightly
LLVM version: 3.9

References for Minimal impl Trait: RFC rust-lang/rfcs#1522, tracking issue #34511.

Can this be tagged A-impl-trait too please? Otherwise it's hard to find before filing duplicates.

This is now fixed on the latest nightly.