Skip to content

Tuples containing references no longer pass PartialEq bounds check for all lifetimes of the other reference #112895

Closed
@smwoj

Description

@smwoj

Code

I tried this code:

trait T {
    type Key<'a>: for<'b> PartialEq<Self::Key<'b>>
    where
        Self: 'a;
}

impl T for () {
    type Key<'a> = (&'a str, u32);
}

It used to compile on 1.69, so I expected it to compile under 1.70, but it failed with the following error

error: implementation of `PartialEq` is not general enough
 --> src/lib.rs:8:20
  |
8 |     type Key<'a> = (&'a str, u32);
  |                    ^^^^^^^^^^^^^^ implementation of `PartialEq` is not general enough
  |
  = note: `(&'a str, u32)` must implement `PartialEq<(&'0 str, u32)>`, for any lifetime `'0`...
  = note: ...but it actually implements `PartialEq`

The same happens for structs that contain a reference and derive PartialEq.

(godbolt link)

Version it worked on

1.69

Version with regression

1.70

rustc --version --verbose:

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions