Skip to content

Tricky type definition can cause inhabitedness check to go into an infinite loop. #39489

Closed
@canndrew

Description

@canndrew

This code:

struct Foo<'a, T: 'a> {
    ph: std::marker::PhantomData<T>,
    foo: &'a Foo<'a, (T, T)>,
}

fn wub(f: Foo<!>) {
    match f {}
}

Causes rustc to stack overflow. This should be pretty easy to "fix" by just putting a recursion limit in is_uninhabited_from and returning false when it gets hit. What's a suitable limit here? Presumably there are other limits like this in other places in the compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions