Skip to content

We allow infinitely expanding types behind pointer indirection #158908

Description

@lcnr

This compiles

struct Foo<T> {
    y: T,
    x: Option<*const Foo<(T,)>>,
}

fn main() {
    let x = Foo {
        y: 1u32,
        x: None,
    };
}

It feels quite brittle however, e.g. the following does not:

struct Foo<T> {
    y: T,
    // We recur due to drop checking
    x: Option<Box<Foo<(T,)>>>,
}

fn main() {
    let x = Foo {
        y: 1u32,
        x: None,
    };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-types-nominatedNominated for discussion during a types team meeting.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions