Skip to content

ICE when using const_fn in trait #54954

Closed
@tuxzz

Description

@tuxzz

This code

#![feature(const_fn)]

const ARR_LEN: usize = Tt::const_val::<[i8; 123]>();

trait Tt {
    const fn const_val<T: Sized>() -> usize {
        core::mem::size_of::<T>()
    }
}

fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
    z
}

fn main() {
    let _ = f([1f32; ARR_LEN]);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsI-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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions