Skip to content

implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N], &[T; N] and &mut [T; N] - #152972

Open
iAeternus wants to merge 3 commits into
rust-lang:mainfrom
iAeternus:fix-vecdeque-partialeq-symmetry
Open

implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N], &[T; N] and &mut [T; N]#152972
iAeternus wants to merge 3 commits into
rust-lang:mainfrom
iAeternus:fix-vecdeque-partialeq-symmetry

Conversation

@iAeternus

@iAeternus iAeternus commented Feb 22, 2026

Copy link
Copy Markdown

This PR is a response to #152830. It implement PartialEq<VecDeque> for Vec, &[T], &mut [T], [T; N] and &mut [T; N]. To be symmetrical with the standard library's __impl_slice_eq1, I added the __impl_slice_eq2 macro to generate the implementation. Additionally, I added the reverse equality unit test (test_partial_eq_vecdeque_reverse), modified too_generic_eval_ice.current.stderr, and passed the local tests.
This PR does not involve the comparison between Cow vs Vec and Cow vs &mut [T].
PS:
This is my first time participating in this project. If there are any mistakes, please feel free to correct me.

@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 Feb 22, 2026
@rustbot

rustbot commented Feb 22, 2026

Copy link
Copy Markdown
Collaborator

r? @joboet

rustbot has assigned @joboet.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates
  • Random selection from Mark-Simulacrum, jhpratt, joboet

@rust-log-analyzer

This comment has been minimized.

@workingjubilee

Copy link
Copy Markdown
Member

...who says "corrigendum"? This isn't an academics paper, this is a PR. Your PR's description should be as succinct as you can make it, and written by hand in your own words. See https://forge.rust-lang.org/how-to-start-contributing.html#etiquette

@workingjubilee

Copy link
Copy Markdown
Member

This PR is already addressed by #149045

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 22, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 22, 2026
@workingjubilee

Copy link
Copy Markdown
Member

Wait, this isn't addressed by that, this is VecDeque not Vec.

@workingjubilee workingjubilee added T-libs-api [DEPRECATED; DO NOT USE] and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 22, 2026
@rust-log-analyzer

This comment has been minimized.

@joboet

joboet commented Feb 25, 2026

Copy link
Copy Markdown
Member

r? libs-api

This will need an FCP.

This is my first time participating in this project. If there are any mistakes, please feel free to correct me.

Welcome! As it stands, the PR description is very bloated and reads like the LLM-generated robot-speak that it is (if you read it through, every information is repeated twice). That comes across as quite rude; after all, why should anyone spend time on your work if you didn't invest your?

So please, write your contributions yourself. As far as I can tell from your profile, English isn't your first language (it isn't for me either). Using translation tools is completely fine, but please make sure that the generated output is close to what you had originally written. Try prompting the LLM to keep that in mind – context matters, even and especially for mindless stochastic parrots. And in the end, even the most nuanced prompt cannot and should not replace a manual review of the output.

@rustbot author
until then.

@rustbot rustbot assigned dtolnay and unassigned joboet Feb 25, 2026
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2026
@rustbot

rustbot commented Feb 25, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@iAeternus

Copy link
Copy Markdown
Author

r? libs-api

This will need an FCP.

This is my first time participating in this project. If there are any mistakes, please feel free to correct me.

Welcome! As it stands, the PR description is very bloated and reads like the LLM-generated robot-speak that it is (if you read it through, every information is repeated twice). That comes across as quite rude; after all, why should anyone spend time on your work if you didn't invest your?

So please, write your contributions yourself. As far as I can tell from your profile, English isn't your first language (it isn't for me either). Using translation tools is completely fine, but please make sure that the generated output is close to what you had originally written. Try prompting the LLM to keep that in mind – context matters, even and especially for mindless stochastic parrots. And in the end, even the most nuanced prompt cannot and should not replace a manual review of the output.

@rustbot author until then.

Thank you for your suggestion. I have rewritten the PR description. From now on, I will describe the PR in my own words.

@iAeternus iAeternus changed the title alloc: make VecDeque partial equality symmetric with vec/slice/array implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N] and &mut [T; N] Feb 26, 2026
@iAeternus

Copy link
Copy Markdown
Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 26, 2026
@iAeternus

Copy link
Copy Markdown
Author

Starting a crater run to check if this breaks type inference in the ecosystem.

@bors try

@rust-bors

rust-bors Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@iAeternus: 🔑 Insufficient privileges: not in try users

@clarfonthey clarfonthey added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed T-libs-api [DEPRECATED; DO NOT USE] labels Aug 12, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 22, 2026
…, r=Mark-Simulacrum

feat: add symmetric PartialEq impls for Vec, &[T], &mut [T] versus Cow<'_, [T]>

add the missing reverse `PartialEq<Cow<'_, [U]>>` impls for `Vec<T, A>`, `&[T]`, and `&mut [T]`, essentially mirroring the existing forwards in `library/alloc/src/vec/partial_eq.rs`

partially addresses rust-lang#152830. The `VecDeque` half of that issue is being handled separately by rust-lang#152972, so there is no overlap with this PR

also fyi: verified locally with `./x test library/alloctests --stage 1` and the new `test_partial_eq_cow_symmetric` test passes alongside the existing alloc test suite
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 22, 2026
…, r=Mark-Simulacrum

feat: add symmetric PartialEq impls for Vec, &[T], &mut [T] versus Cow<'_, [T]>

add the missing reverse `PartialEq<Cow<'_, [U]>>` impls for `Vec<T, A>`, `&[T]`, and `&mut [T]`, essentially mirroring the existing forwards in `library/alloc/src/vec/partial_eq.rs`

partially addresses rust-lang#152830. The `VecDeque` half of that issue is being handled separately by rust-lang#152972, so there is no overlap with this PR

also fyi: verified locally with `./x test library/alloctests --stage 1` and the new `test_partial_eq_cow_symmetric` test passes alongside the existing alloc test suite
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 22, 2026
…, r=Mark-Simulacrum

feat: add symmetric PartialEq impls for Vec, &[T], &mut [T] versus Cow<'_, [T]>

add the missing reverse `PartialEq<Cow<'_, [U]>>` impls for `Vec<T, A>`, `&[T]`, and `&mut [T]`, essentially mirroring the existing forwards in `library/alloc/src/vec/partial_eq.rs`

partially addresses rust-lang#152830. The `VecDeque` half of that issue is being handled separately by rust-lang#152972, so there is no overlap with this PR

also fyi: verified locally with `./x test library/alloctests --stage 1` and the new `test_partial_eq_cow_symmetric` test passes alongside the existing alloc test suite
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 22, 2026
…, r=Mark-Simulacrum

feat: add symmetric PartialEq impls for Vec, &[T], &mut [T] versus Cow<'_, [T]>

add the missing reverse `PartialEq<Cow<'_, [U]>>` impls for `Vec<T, A>`, `&[T]`, and `&mut [T]`, essentially mirroring the existing forwards in `library/alloc/src/vec/partial_eq.rs`

partially addresses rust-lang#152830. The `VecDeque` half of that issue is being handled separately by rust-lang#152972, so there is no overlap with this PR

also fyi: verified locally with `./x test library/alloctests --stage 1` and the new `test_partial_eq_cow_symmetric` test passes alongside the existing alloc test suite
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 22, 2026
…, r=Mark-Simulacrum

feat: add symmetric PartialEq impls for Vec, &[T], &mut [T] versus Cow<'_, [T]>

add the missing reverse `PartialEq<Cow<'_, [U]>>` impls for `Vec<T, A>`, `&[T]`, and `&mut [T]`, essentially mirroring the existing forwards in `library/alloc/src/vec/partial_eq.rs`

partially addresses rust-lang#152830. The `VecDeque` half of that issue is being handled separately by rust-lang#152972, so there is no overlap with this PR

also fyi: verified locally with `./x test library/alloctests --stage 1` and the new `test_partial_eq_cow_symmetric` test passes alongside the existing alloc test suite
rust-bors Bot pushed a commit that referenced this pull request Aug 23, 2026
Rollup merge of #156160 - kx0101:cow-vec-symmetric-partialeq, r=Mark-Simulacrum

feat: add symmetric PartialEq impls for Vec, &[T], &mut [T] versus Cow<'_, [T]>

add the missing reverse `PartialEq<Cow<'_, [U]>>` impls for `Vec<T, A>`, `&[T]`, and `&mut [T]`, essentially mirroring the existing forwards in `library/alloc/src/vec/partial_eq.rs`

partially addresses #152830. The `VecDeque` half of that issue is being handled separately by #152972, so there is no overlap with this PR

also fyi: verified locally with `./x test library/alloctests --stage 1` and the new `test_partial_eq_cow_symmetric` test passes alongside the existing alloc test suite
@rust-bors

This comment has been minimized.

github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Aug 24, 2026
…Simulacrum

feat: add symmetric PartialEq impls for Vec, &[T], &mut [T] versus Cow<'_, [T]>

add the missing reverse `PartialEq<Cow<'_, [U]>>` impls for `Vec<T, A>`, `&[T]`, and `&mut [T]`, essentially mirroring the existing forwards in `library/alloc/src/vec/partial_eq.rs`

partially addresses rust-lang/rust#152830. The `VecDeque` half of that issue is being handled separately by rust-lang/rust#152972, so there is no overlap with this PR

also fyi: verified locally with `./x test library/alloctests --stage 1` and the new `test_partial_eq_cow_symmetric` test passes alongside the existing alloc test suite
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Aug 24, 2026
…Simulacrum

feat: add symmetric PartialEq impls for Vec, &[T], &mut [T] versus Cow<'_, [T]>

add the missing reverse `PartialEq<Cow<'_, [U]>>` impls for `Vec<T, A>`, `&[T]`, and `&mut [T]`, essentially mirroring the existing forwards in `library/alloc/src/vec/partial_eq.rs`

partially addresses rust-lang/rust#152830. The `VecDeque` half of that issue is being handled separately by rust-lang/rust#152972, so there is no overlap with this PR

also fyi: verified locally with `./x test library/alloctests --stage 1` and the new `test_partial_eq_cow_symmetric` test passes alongside the existing alloc test suite
@iAeternus
iAeternus force-pushed the fix-vecdeque-partialeq-symmetry branch from e0d2a84 to b50d79a Compare August 25, 2026 01:28
@rustbot

rustbot commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@iAeternus

Copy link
Copy Markdown
Author

I have re-examined whether __impl_slice_eq2! is necessary in this PR. __impl_slice_eq1! assumes that self is a VecDeque, since it calls self.as_slices(). In the reversed PartialEq implementations, Vec, slices, and arrays are on the self side, while VecDeque is on the other side. Therefore, the existing __impl_slice_eq1! cannot be reused simply by swapping the macro parameters.
I considered three possible approaches:

  1. Add a separate __impl_slice_eq2! macro.
  2. Add another rule to __impl_slice_eq1!, for example: ([$($vars:tt)*] reverse $lhs:ty, $rhs:ty, $($constraints:tt)*) and invoke it as: __impl_slice_eq1! { [] reverse Vec<T, A>, VecDeque<U, A>, }
  3. Extract the duplicated logic from __impl_slice_eq1! and __impl_slice_eq2! into a helper.

I chose the first approach because, for such a small patch, a separate macro for the reversed comparison is straightforward and easy to understand. The other approaches introduce additional complexity without providing much benefit here. Given the standard library's preference for keeping the implementation simple and localized, I think the first approach is sufficient.

@iAeternus iAeternus changed the title implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N] and &mut [T; N] implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N], &[T; N] and &mut [T; N] Aug 25, 2026
@iAeternus

Copy link
Copy Markdown
Author

Updated the PR title to include the missing &[T; N]. This implementation was already included in the PR; it was simply omitted from the title.

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants