Skip to content

Additional bounds are required for const generics using associated constants #80976

Open
@clarfonthey

Description

@clarfonthey

Example below. Based on the description in #76560, I'd expect to not be required to add [(); From::DIM]: and [(); To::DIM] bounds to Transform because the associated consts are inherent to the trait's definition and thus are public APIs.

#![feature(generic_const_exprs)]

trait Vector {
    type Scalar;
    const DIM: usize;
}

struct Transform<From, To>
where
    From: Vector,
    To: Vector<Scalar = From::Scalar>,
{
    columns: [[From::Scalar; From::DIM]; To::DIM],
}

(Playground)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsF-generic_const_exprs`#![feature(generic_const_exprs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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