Skip to content

Closures in const generics cause ICE #63322

Closed
@Tyler-Hardin

Description

@Tyler-Hardin

Pretty straightforward. The idea is to plug logic into a template. This seems like something that should/could work.

#![feature(const_generics)]

fn test<const F: &'static dyn Fn(u32) -> u32>(i: u32) -> u32 {
    F(i)
}

const F: &'static dyn Fn(u32) -> u32 = &|x| x*x;

fn main () {
    println!("{}", test::<{F}>(5));
}

Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7eefeb472380da1061af1be06967d30a

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions