Skip to content

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

Closed
@spinda

Description

@spinda

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-type-systemArea: Type systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions