Skip to content

Confusing error message when deriving PartialOrd for structs containing mutable slices #45888

Closed
@eira-fransham

Description

@eira-fransham

Minimal reproduction:

#[derive(Eq, PartialEq, PartialOrd)]
struct Foo<'a, T: 'a>(&'a mut [T]);

This produces the following error message repeated precisely 8 times. I cannot tell you why this is, I have no idea. I assume it's a failure in the PartialOrd derivation code that's not being reported correctly.

error[E0389]: cannot borrow data mutably in a `&` reference
 --> src/main.rs:2:23
  |
2 | struct Foo<'a, T: 'a>(&'a mut [T]);
  |                       ^^^^^^^^^^^^
  |                       |
  |                       assignment into an immutable reference
  |                       consider changing this to `&'a mut [T])`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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