Skip to content

[feature(adt_const_params)] Bar doesn't derive both PartialEq and Eq #97278

Closed
@psionic12

Description

@psionic12

I'v read the issue and the issue, and it seems that neither is my case.

rust version: rustc 1.62.0-nightly (a707f40 2022-04-29)

I tried this code:

#![feature(adt_const_params)]

use std::sync::Arc;

#[derive(PartialEq, Eq)]
enum Bar {
    Bar(Arc<i32>)
}

fn test<const BAR: Bar>() {}

I expected to see this the code to be compiled, but it's not:

error[E0741]: `Bar` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
  --> src\main.rs:16:20
   |
16 | fn test<const BAR: Bar>() {}
   |                    ^^^ `Bar` doesn't derive both `PartialEq` and `Eq`

My guess is that the type Arc doesn't implement StructuralPartialEq, and I tried to use the feature newtype to wrap around the Arc, but still not working

So is it a bug or is there some limitations? Is there anyway I can make my code compile?

Metadata

Metadata

Assignees

No one assigned

    Labels

    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