Skip to content

Inconsistent bound requirements on arrays with generic sizes #79778

Closed
@calebzulawski

Description

@calebzulawski

I'm working on integrating const generics into stdsimd. We want to support two types of bit masks. The first has an entire mask per lane, e.g.:

struct Mask32<const LANES: usize>([u32; LANES]);

The other type of mask only uses a single bit per lane, e.g.:

struct BitMask<const LANES: usize>([u8; (LANES + 7) / 8]);

This doesn't work, however, and errors with error: unconstrained generic constant. After finding #68436, I was able to get it working with:

struct BitMask<const LANES: usize>([u8; (LANES + 7) / 8]) where [u8; (LANES + 7) / 8]: Sized;

This seems inconsistent since the two types are negligibly different. Also, since this type will be public, the bound bleeds into the interface which is undesirable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions