Skip to content

Manual PartialEq impl not found for const generics. #94661

Closed as not planned
Closed as not planned
@jafioti

Description

@jafioti

I tried this code:

#[derive(Eq)]
pub enum DimType {
    Static(usize),
    Dynamic
}

impl PartialEq for DimType {
    fn eq(&self, other: &Self) -> bool {
        match self {
            DimType::Static(s) => match other {
                DimType::Static(t) => s == t,
                DimType::Dynamic => true,
            },
            DimType::Dynamic => true,
        }
    }
}

I expected to see this happen: I expected to be able to use DimType as a const generic type. I am able to use it when I derive PartialEq and Eq, but when I manually derive PartialEq it doesn't work.

Instead, this happened: I get an error: tensor::DimType must be annotated with #[derive(PartialEq, Eq)] to be used as the type of a const parameter

Meta

rustc --version --verbose:

rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.61.0-nightly (c274e4969 2022-03-05)`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions