Skip to content

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

Open

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)

Activity

  1. added
    A-const-genericsArea: const generics (parameters and arguments)
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    and removed on Jan 17, 2021
  2. camelid commented on Jan 17, 2021

    @camelid
    Member

    It seems const_evaluatable_checked is not required to repro? EDIT: actually it is required :)

  3. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    and removed on Jun 24, 2022
  4. lcnr commented on Jun 24, 2022

    @lcnr
    Contributor

    triaged in https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/.60F-generic_const_exprs.60.20triage/near/287323105, if we want const evaluatable bounds this error is expected (though with a better error message). Whether these bounds are needed is tracked in rust-lang/project-const-generics#41

  5. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Apr 5, 2023
  6. removed
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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)]`P-lowLow priorityT-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