Skip to content

Associated constants in traits can not be used in const generics #60551

Open
@newpavlov

Description

@newpavlov

Initially reported here.

The following code:

trait Foo {
    const N: usize;
    fn foo() -> [u8; Self::N];
}

Playground

Results in a "no associated item named N found for type Self in the current scope" compilation error on current Nightly.

Note that associated constants in impl blocks work without any issues.

cc @varkor @yodaldevoid

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.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