Skip to content

min_const_generics allows defining new types in const argument #75864

Closed
@Aaron1011

Description

@Aaron1011

I recently discovered that the following code compiles:

#![feature(min_const_generics)]
struct Bar<const C: bool>;

struct Foo {
    outer: Bar<{
        struct Inner {
            field: bool
        }
        true
    }>,
}

It looks like an AnonConst is allowed to contain arbitrary expressions (as long as no const or type parameters are used), which means that new types can be defined.

I'm not certain whether this should be allowed or not. However, I haven't seen this discussed before, so I thought it was worth bringing up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions