Skip to content

fn's can be used as const generics #84238

Closed
@DutchGhost

Description

@DutchGhost

The following code fails to compile, because using function pointers as const generics is forbidden:

#![feature(const_generics)]

struct A<const F: fn()>;

However, if the function pointer is inside an array, it suddenly compiles:

#![feature(const_generics)]

struct B<const F: [fn(); 1]>;

Is this intentional, or should it also be forbidden?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-adt_const_params`#![feature(adt_const_params)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions