Skip to content

Incorrect error suggestion when using a type that does not recursively derive PartialEq, Eq #76183

Closed
@CDirkx

Description

@CDirkx

The following code

#![feature(const_generics)]
#![feature(structural_match)]

struct Inner;

#[derive(PartialEq, Eq)]
struct Outer {
    inner: Inner
}

struct S<const O: Outer>;
const C : S<{ Outer { inner: Inner } }> = S;

results in the error

error[E0741]: `Outer` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
  --> src/lib.rs:11:19
   |
   | struct S<const O: Outer>;
   |                   ^^^^^ `Outer` doesn't derive both `PartialEq` and `Eq`

Which is not correct: Outer does derive PartialEq and Eq.

The true error is that Inner does not derive the traits (or implements StructuralEq and StructuralPartialEq), however it is probably not a good idea to leak this type in the error message, as it is an implementation detail?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.T-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