Skip to content

Using associated constants for generics is not considered using a type generic #80977

Closed
@clarfonthey

Description

@clarfonthey

Filing in addition to #80976 because this seems to be a separate issue. Includes the same example below. Essentially, even though the associated constant To::DIM is being used in the definition of the struct, the compiler marks To as being unused since no types related to it are being used.

#![feature(const_generics, const_evaluatable_checked)]

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)C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions