Skip to content

Add missing reverse PartialEq impls for Cow - #160973

Closed
kiana1kaslana wants to merge 2 commits into
rust-lang:mainfrom
kiana1kaslana:cow_partialeq_reverse
Closed

Add missing reverse PartialEq impls for Cow#160973
kiana1kaslana wants to merge 2 commits into
rust-lang:mainfrom
kiana1kaslana:cow_partialeq_reverse

Conversation

@kiana1kaslana

@kiana1kaslana kiana1kaslana commented Aug 12, 2026

Copy link
Copy Markdown

Closes #152830

Implements the Cow-related cases that #152972 doesn't cover:

  • impl PartialEq<Cow<'_, [U]>> for Vec<T, A>
  • impl PartialEq<Cow<'_, [U]>> for &[T]
  • impl PartialEq<Cow<'_, [U]>> for &mut [T]

Without these, expressions like vec == cow or slice == cow fail to compile.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 12, 2026
@rustbot

rustbot commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @clarfonthey (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from JohnTitor, Mark-Simulacrum, clarfonthey, nia-e

@rustbot

This comment has been minimized.

Vec, &[T] and &mut [T] already implement PartialEq against Cow<'_, [U]>,
but the reverse direction is missing, so `vec == cow`, `slice == cow`
and `mut_slice == cow` all fail to compile.

Add the three reverse impls to fill the remaining gap from issue 152830,
which was partially addressed by the recent VecDeque companion PR 152972.
@kiana1kaslana
kiana1kaslana force-pushed the cow_partialeq_reverse branch from 86bb69c to b3383b6 Compare August 12, 2026 09:39
@rust-log-analyzer

This comment has been minimized.

Adding `impl PartialEq<Cow<'_, [U]>>` for `&[T]` and `&mut [T]` shifts
the trait help message in two UI tests, which now list the new impls
and push two older entries into "N others":
- tests/ui/consts/too_generic_eval_ice.current.stderr
- tests/ui/macros/assert-ne-no-invalid-help-issue-146204.stderr

No source changes; only the expected stderr snapshots were regenerated.
@clarfonthey

Copy link
Copy Markdown
Contributor

I remember mentioning this during the libs meaning, but don't actually remember why it came up since this isn't nominated.

My general opinion is we should have these, but I do question whether they weren't added initially because of inference failures, and not just because we forgot them. So, it makes sense to do a crater run first.

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 12, 2026
Add missing reverse PartialEq impls for Cow
@rust-bors

rust-bors Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0638027 (0638027fc267e2ac327148556d875936927466d2)
Base parent: ab8058a (ab8058aa09e8c14b86b3d06c08ade66f863d22fe)

@clarfonthey

Copy link
Copy Markdown
Contributor

@craterbot check

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-160973 created and queued.
🤖 Automatically detected try build 0638027
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2026
@rust-bors

rust-bors Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #161566) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

@clarfonthey

Copy link
Copy Markdown
Contributor

FWIW: The crater runs are delayed since the release crater runs are the ones that are prioritised right now. I don't think we need to cancel the running job since it'll still be useful for whether these impls specifically cause regressions.

@kiana1kaslana

Copy link
Copy Markdown
Author

Closing — #156160 (which went in via #161566) added the same impls, so this is no longer needed. Thanks to @clarfonthey for the review and the crater run, sorry for the churn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-crater Status: Waiting on a crater run to be completed. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PartialEq implementations are missing for symmetric comparisons between certain collections

5 participants